Lua、nmap、sqlite3 和 Ubuntu - module 'luasql.sqlite3' 未找到

我需要使用 nmap 和 sqlite3,并在 Ubuntu 上安装了 lua 5.1 和 lua-sql-sqlite3:

sudo apt-get install lua5.1; sudo apt-get install lua-sql-sqlite3

现在,当我执行以下操作时:

$ lua
Lua 5.2.1  版权所有 (C) 1994-2012 Lua.org, PUC-Rio
> drv = require "luasql.sqlite3"
> print(drv._VERSION)
LuaSQL 2.3.0

一切都很顺利,但当我尝试使用以下命令行运行 nmap nse scrint 时:

require "luasql.sqlite3"

我使用此 nse 脚本 sqlite-output.nse 来使用 nmap 和 sqlite3。

我遇到了错误:

$ sudo nmap --script=sqlite-output.nse localhost
[sudo] 密码:

Starting Nmap 7.01 ( https://nmap.org ) at 2016-03-13 04:16 EET
NSE: Failed to load sqlite-output.nse:
sqlite-output.nse:7: module 'luasql.sqlite3' not found:
    NSE failed to find nselib/luasql/sqlite3.lua in search paths.
    no field package.preload['luasql.sqlite3']
    no file '/usr/local/share/lua/5.2/luasql/sqlite3.lua'
    no file '/usr/local/share/lua/5.2/luasql/sqlite3/init.lua'
    no file '/usr/local/lib/lua/5.2/luasql/sqlite3.lua'
    no file '/usr/local/lib/lua/5.2/luasql/sqlite3/init.lua'
    no file './luasql/sqlite3.lua'
    no file '/usr/local/lib/lua/5.2/luasql/sqlite3.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './luasql/sqlite3.so'
    no file '/usr/local/lib/lua/5.2/luasql.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './luasql.so'
stack traceback:
    [C]: in function 'require'
    sqlite-output.nse:7: in function <sqlite-output.nse:1>
NSE: failed to initialize the script engine:
/usr/local/bin/../share/nmap/nse_main.lua:600: could not load script
stack traceback:
    [C]: in function 'error'
    /usr/local/bin/../share/nmap/nse_main.lua:600: in function 'new'
    /usr/local/bin/../share/nmap/nse_main.lua:805: in function 'get_chosen_scripts'
    /usr/local/bin/../share/nmap/nse_main.lua:1249: in main chunk
    [C]: in ?
点赞
用户4113745
用户4113745

当你在文件系统中搜索"luasql",它被安装在哪里了?在我的机器上看起来像这样:

micha@squeak:~$ sudo find / -name luasql
/usr/lib/x86_64-linux-gnu/lua/5.2/luasql
/usr/lib/x86_64-linux-gnu/lua/5.1/luasql

nmap是从Ubuntu仓库安装还是自己编译的?

编辑:如果你的lua库不在nmap的搜索路径中,你可以创建一个软链接,像这样:

sudo ln -s /usr/lib/x86_64-linux-gnu/lua /usr/local/lib/lua
2016-03-13 14:34:26