From 88b0e212df33be14d21511ed1cdfa6957db81265 Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 11 Aug 2007 04:16:56 +0000 Subject: [PATCH] merge soc07 r4906 - NSE bugfixes --- nse_init.cc | 6 ++++ nselib/shortport.lua | 78 ++++++++++++++++++++++++-------------------- scripts/script.db | 58 ++++++++++++++++++-------------- 3 files changed, 81 insertions(+), 61 deletions(-) diff --git a/nse_init.cc b/nse_init.cc index b55a009df..0b4ddc692 100644 --- a/nse_init.cc +++ b/nse_init.cc @@ -267,6 +267,12 @@ int init_updatedb(lua_State* l) { ) lua_newtable(l); + /*give the script global namespace access*/ + lua_newtable(l); + lua_getglobal(l, "_G"); + lua_setfield(l, -2, "__index"); + lua_setmetatable(l, -2); + for(iter = files.begin(); iter != files.end(); iter++) { c_iter = strdup((*iter).c_str()); if(check_extension(SCRIPT_ENGINE_EXTENSION, c_iter) == MATCH diff --git a/nselib/shortport.lua b/nselib/shortport.lua index 3cf65656d..9c8a9b0ba 100644 --- a/nselib/shortport.lua +++ b/nselib/shortport.lua @@ -1,43 +1,49 @@ module(...) -protorule = function(porttab, service, proto, state) - state = state or "open" - proto = proto or "tcp" - if porttab.service==service - and porttab.protocol == proto - and porttab.state == state - then - return true; - else - return false; - end -end - -portnumber = function(porttab, number, proto, state) - state = state or "open" - proto = proto or "tcp" - if porttab.number==number - and porttab.protocol == proto - and porttab.state ==state - then - return true; - else - return false; - end - -end - -port_in_list = function(porttab, proto, ...) - if not porttab.protocol==proto - then - return false - end - for i, v in ipairs{...} do - if porttab.number == v then - return true +protorule = function(service, proto, state) + return function(host,port) + state = state or "open" + proto = proto or "tcp" + if port.service==service + and port.protocol == proto + and port.state == state + then + return true; + else + return false; end end - return false +end + +portnumber = function(number, proto, state) + return function(host,port) + state = state or "open" + proto = proto or "tcp" + if port.number==number + and port.protocol == proto + and port.state ==state + then + return true; + else + return false; + end + end +end + +port_in_list = function(proto, ...) + local list={...} + return function(host,port) + if not port.protocol==proto + then + return false + end + for _, v in ipairs(list) do + if port.number == v then + return true + end + end + return false + end end port_or_service = function(number, service, proto, state) diff --git a/scripts/script.db b/scripts/script.db index 19a34d9cb..ed282eee8 100644 --- a/scripts/script.db +++ b/scripts/script.db @@ -1,25 +1,33 @@ -Entry{ category = "intrusive", filename = "./scripts//dns-test-open-recursion.nse" } -Entry{ category = "backdoor", filename = "./scripts//RealVNC_auth_bypass.nse" } -Entry{ category = "safe", filename = "./scripts//showOwner.nse" } -Entry{ category = "intrusive", filename = "./scripts//SSLv2-support.nse" } -Entry{ category = "malware", filename = "./scripts//ircZombieTest.nse" } -Entry{ category = "version", filename = "./scripts//skype_v2-version.nse" } -Entry{ category = "demo", filename = "./scripts//echoTest.nse" } -Entry{ category = "discovery", filename = "./scripts//ripeQuery.nse" } -Entry{ category = "demo", filename = "./scripts//chargenTest.nse" } -Entry{ category = "backdoor", filename = "./scripts//strangeSMTPport.nse" } -Entry{ category = "demo", filename = "./scripts//showSMTPVersion.nse" } -Entry{ category = "demo", filename = "./scripts//showHTMLTitle.nse" } -Entry{ category = "safe", filename = "./scripts//showHTMLTitle.nse" } -Entry{ category = "backdoor", filename = "./scripts//mswindowsShell.nse" } -Entry{ category = "intrusive", filename = "./scripts//anonFTP.nse" } -Entry{ category = "malware", filename = "./scripts//kibuvDetection.nse" } -Entry{ category = "malware", filename = "./scripts//SMTP_openrelay_test.nse" } -Entry{ category = "discovery", filename = "./scripts//nbstat.nse" } -Entry{ category = "safe", filename = "./scripts//nbstat.nse" } -Entry{ category = "", filename = "./scripts//showHTTPVersion.nse" } -Entry{ category = "intrusive", filename = "./scripts//SSHv1-support.nse" } -Entry{ category = "intrusive", filename = "./scripts//ftpbounce.nse" } -Entry{ category = "vulnerability", filename = "./scripts//xamppDefaultPass.nse" } -Entry{ category = "demo", filename = "./scripts//showSSHVersion.nse" } -Entry{ category = "demo", filename = "./scripts//daytimeTest.nse" } +Entry{ category = "intrusive", filename = "SSLv2-support.nse" } +Entry{ category = "discovery", filename = "finger.nse" } +Entry{ category = "demo", filename = "showSSHVersion.nse" } +Entry{ category = "vulnerability", filename = "xamppDefaultPass.nse" } +Entry{ category = "intrusive", filename = "HTTPAuth.nse" } +Entry{ category = "intrusive", filename = "dns-test-open-recursion.nse" } +Entry{ category = "demo", filename = "showHTMLTitle.nse" } +Entry{ category = "safe", filename = "showHTMLTitle.nse" } +Entry{ category = "discovery", filename = "nbstat.nse" } +Entry{ category = "safe", filename = "nbstat.nse" } +Entry{ category = "backdoor", filename = "mswindowsShell.nse" } +Entry{ category = "demo", filename = "showSMTPVersion.nse" } +Entry{ category = "safe", filename = "showOwner.nse" } +Entry{ category = "backdoor", filename = "RealVNC_auth_bypass.nse" } +Entry{ category = "demo", filename = "daytimeTest.nse" } +Entry{ category = "", filename = "showHTTPVersion.nse" } +Entry{ category = "demo", filename = "chargenTest.nse" } +Entry{ category = "intrusive", filename = "SSHv1-support.nse" } +Entry{ category = "discovery", filename = "MSSQLm.nse" } +Entry{ category = "intrusive", filename = "MSSQLm.nse" } +Entry{ category = "demo", filename = "echoTest.nse" } +Entry{ category = "version", filename = "skype_v2-version.nse" } +Entry{ category = "intrusive", filename = "SMTP_openrelay_test.nse" } +Entry{ category = "intrusive", filename = "anonFTP.nse" } +Entry{ category = "discovery", filename = "ripeQuery.nse" } +Entry{ category = "backdoor", filename = "strangeSMTPport.nse" } +Entry{ category = "discovery", filename = "SNMPsysdesr.nse" } +Entry{ category = "safe", filename = "SNMPsysdesr.nse" } +Entry{ category = "malware", filename = "ircZombieTest.nse" } +Entry{ category = "intrusive", filename = "ftpbounce.nse" } +Entry{ category = "discovery", filename = "SMTPcommands.nse" } +Entry{ category = "intrusive", filename = "SMTPcommands.nse" } +Entry{ category = "malware", filename = "kibuvDetection.nse" }