我需要使用 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 Copyright (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-输出.nse 用于使用 nmap 和 sqlite3。
我有错误:
$ sudo nmap --script=sqlite-output.nse localhost
[sudo] password for alex:
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 ?
答案1
Nmap 使用 Lua 5.2,而不是 5.1。版本不兼容。
编辑:刚刚看到您确实在 Lua 5.2 中使用 lua-sql-sqlite3。但是 Nmap 正在您的问题中打印的位置(前缀)中寻找它/usr/local
。 Ubuntu 软件包安装在/usr
前缀中。你也许可以通过这样做来让它工作sudo ln -s /usr/lib/lua/5.2/luasql /usr/local/lib/lua/5.2/luasql