1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

added a CLI debugger

This commit is contained in:
diman
2008-02-03 14:21:36 +00:00
parent 7c6a4479bb
commit 2d9bc1b43d
9 changed files with 1797 additions and 202 deletions

View File

@@ -274,6 +274,7 @@ void NmapOps::Initialize() {
script = 0; script = 0;
scriptversion = 0; scriptversion = 0;
scripttrace = 0; scripttrace = 0;
scriptdebug = 0;
scriptupdatedb = 0; scriptupdatedb = 0;
#endif #endif
} }

View File

@@ -328,6 +328,7 @@ class NmapOps {
char *scriptargs; char *scriptargs;
int scriptversion; int scriptversion;
int scripttrace; int scripttrace;
int scriptdebug;
int scriptupdatedb; int scriptupdatedb;
void chooseScripts(char* argument); void chooseScripts(char* argument);
std::vector<std::string> chosenScripts; std::vector<std::string> chosenScripts;

4
libpcre/aclocal.m4 vendored
View File

@@ -11,8 +11,8 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. # PARTICULAR PURPOSE.
m4_if(m4_PACKAGE_VERSION, [2.61],, m4_if(m4_PACKAGE_VERSION, [2.60],,
[m4_fatal([this file was generated for autoconf 2.61. [m4_fatal([this file was generated for autoconf 2.60.
You have another version of autoconf. If you want to use that, You have another version of autoconf. If you want to use that,
you should regenerate the build system entirely.], [63])]) you should regenerate the build system entirely.], [63])])

617
libpcre/configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -627,6 +627,8 @@ int nmap_main(int argc, char *argv[]) {
{"script", required_argument, 0, 0}, {"script", required_argument, 0, 0},
{"script-trace", no_argument, 0, 0}, {"script-trace", no_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_updatedb", no_argument, 0, 0}, {"script_updatedb", no_argument, 0, 0},
{"script-args",required_argument,0,0}, {"script-args",required_argument,0,0},
@@ -668,6 +670,9 @@ int nmap_main(int argc, char *argv[]) {
fatal("Error parsing --script-args\n"); 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; 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){ } else if (optcmp(long_options[option_index].name, "script-updatedb") == 0){
o.scriptupdatedb = 1; o.scriptupdatedb = 1;
} else } else

View File

@@ -207,6 +207,9 @@ void tty_init()
{ {
struct termios ti; struct termios ti;
if(o.noninteractive)
return;
if (tty_fd) if (tty_fd)
return; return;

View File

@@ -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_fetchfile_absolute(char *path, size_t path_len, char *file);
int init_updatedb(lua_State* l); int init_updatedb(lua_State* l);
int init_pick_default_categories(std::vector<std::string>& chosenScripts); 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); int check_extension(const char* ext, const char* path);
@@ -58,12 +59,31 @@ int init_lua(lua_State* l) {
SCRIPT_ENGINE_LUA_TRY(lua_pcall(l, 1, 0, 0)); SCRIPT_ENGINE_LUA_TRY(lua_pcall(l, 1, 0, 0));
} }
/* publish the nmap bindings to the script */ /* publish the nmap bindings to the script */
lua_newtable(l); lua_newtable(l);
SCRIPT_ENGINE_TRY(set_nmaplib(l)); SCRIPT_ENGINE_TRY(set_nmaplib(l));
lua_setglobal(l, "nmap"); lua_setglobal(l, "nmap");
SCRIPT_ENGINE_TRY(init_setlualibpath(l)); 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; return SCRIPT_ENGINE_SUCCESS;
} }

1342
nselib/debugger.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,8 @@ end
action = function(host, port) action = function(host, port)
local data, result, title, protocol local data, result, title, protocol
pause("test")
data = http.get( host, port, '/' ) data = http.get( host, port, '/' )
result = data.body result = data.body