mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
added a CLI debugger
This commit is contained in:
@@ -274,6 +274,7 @@ void NmapOps::Initialize() {
|
||||
script = 0;
|
||||
scriptversion = 0;
|
||||
scripttrace = 0;
|
||||
scriptdebug = 0;
|
||||
scriptupdatedb = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -328,6 +328,7 @@ class NmapOps {
|
||||
char *scriptargs;
|
||||
int scriptversion;
|
||||
int scripttrace;
|
||||
int scriptdebug;
|
||||
int scriptupdatedb;
|
||||
void chooseScripts(char* argument);
|
||||
std::vector<std::string> chosenScripts;
|
||||
|
||||
4
libpcre/aclocal.m4
vendored
4
libpcre/aclocal.m4
vendored
@@ -11,8 +11,8 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
m4_if(m4_PACKAGE_VERSION, [2.61],,
|
||||
[m4_fatal([this file was generated for autoconf 2.61.
|
||||
m4_if(m4_PACKAGE_VERSION, [2.60],,
|
||||
[m4_fatal([this file was generated for autoconf 2.60.
|
||||
You have another version of autoconf. If you want to use that,
|
||||
you should regenerate the build system entirely.], [63])])
|
||||
|
||||
|
||||
617
libpcre/configure
vendored
617
libpcre/configure
vendored
File diff suppressed because it is too large
Load Diff
7
nmap.cc
7
nmap.cc
@@ -627,6 +627,8 @@ int nmap_main(int argc, char *argv[]) {
|
||||
{"script", required_argument, 0, 0},
|
||||
{"script-trace", no_argument, 0, 0},
|
||||
{"script_trace", no_argument, 0, 0},
|
||||
{"script-debug", no_argument, 0, 0},
|
||||
{"script_debug", no_argument, 0, 0},
|
||||
{"script-updatedb", no_argument, 0, 0},
|
||||
{"script_updatedb", no_argument, 0, 0},
|
||||
{"script-args",required_argument,0,0},
|
||||
@@ -666,8 +668,11 @@ int nmap_main(int argc, char *argv[]) {
|
||||
o.scriptargs=strdup(optarg);
|
||||
if(script_check_args()!=0)
|
||||
fatal("Error parsing --script-args\n");
|
||||
}else if (optcmp(long_options[option_index].name, "script-trace") == 0) {
|
||||
} else if (optcmp(long_options[option_index].name, "script-trace") == 0) {
|
||||
o.scripttrace = 1;
|
||||
} else if (optcmp(long_options[option_index].name, "script-debug") == 0) {
|
||||
o.scriptdebug = 1;
|
||||
o.noninteractive = true;
|
||||
} else if (optcmp(long_options[option_index].name, "script-updatedb") == 0){
|
||||
o.scriptupdatedb = 1;
|
||||
} else
|
||||
|
||||
@@ -207,6 +207,9 @@ void tty_init()
|
||||
{
|
||||
struct termios ti;
|
||||
|
||||
if(o.noninteractive)
|
||||
return;
|
||||
|
||||
if (tty_fd)
|
||||
return;
|
||||
|
||||
|
||||
22
nse_init.cc
22
nse_init.cc
@@ -30,6 +30,7 @@ int init_fetchfile(char *result, size_t result_max_len, char* file);
|
||||
int init_fetchfile_absolute(char *path, size_t path_len, char *file);
|
||||
int init_updatedb(lua_State* l);
|
||||
int init_pick_default_categories(std::vector<std::string>& chosenScripts);
|
||||
int init_debugger(lua_State* l);
|
||||
|
||||
int check_extension(const char* ext, const char* path);
|
||||
|
||||
@@ -58,15 +59,34 @@ int init_lua(lua_State* l) {
|
||||
SCRIPT_ENGINE_LUA_TRY(lua_pcall(l, 1, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
/* publish the nmap bindings to the script */
|
||||
lua_newtable(l);
|
||||
SCRIPT_ENGINE_TRY(set_nmaplib(l));
|
||||
lua_setglobal(l, "nmap");
|
||||
SCRIPT_ENGINE_TRY(init_setlualibpath(l));
|
||||
|
||||
SCRIPT_ENGINE_TRY(init_debugger(l));
|
||||
|
||||
return SCRIPT_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int init_debugger(lua_State* l) {
|
||||
|
||||
if(o.scriptdebug > 0) {
|
||||
luaL_loadstring(l, "require 'debugger'");
|
||||
SCRIPT_ENGINE_TRY(lua_pcall(l, 0, 0, 0));
|
||||
} else {
|
||||
char* debugger_dummy = "\
|
||||
package.loaded['debugger'] = true\n\
|
||||
pause = function() end\n";
|
||||
|
||||
luaL_loadstring(l, debugger_dummy);
|
||||
SCRIPT_ENGINE_TRY(lua_pcall(l, 0, 0, 0));
|
||||
}
|
||||
|
||||
return SCRIPT_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
/*sets two variables, which control where lua looks for modules (implemented in C or lua */
|
||||
int init_setlualibpath(lua_State* l){
|
||||
char path[MAX_FILENAME_LEN];
|
||||
|
||||
1342
nselib/debugger.lua
Normal file
1342
nselib/debugger.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,8 @@ end
|
||||
action = function(host, port)
|
||||
local data, result, title, protocol
|
||||
|
||||
pause("test")
|
||||
|
||||
data = http.get( host, port, '/' )
|
||||
result = data.body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user