1
0
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:
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;
scriptversion = 0;
scripttrace = 0;
scriptdebug = 0;
scriptupdatedb = 0;
#endif
}

View File

@@ -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
View File

@@ -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

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-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

View File

@@ -207,6 +207,9 @@ void tty_init()
{
struct termios ti;
if(o.noninteractive)
return;
if (tty_fd)
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_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

File diff suppressed because it is too large Load Diff

View File

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