diff --git a/nse_init.cc b/nse_init.cc index 276f5e7aa..e55247efc 100644 --- a/nse_init.cc +++ b/nse_init.cc @@ -346,6 +346,21 @@ int init_setargs (lua_State *L) return 0; } +/* Sorts the table at the given stack index (by calling table.sort). */ +static void table_sort(lua_State *L, int index) +{ + /* table.sort sorts in place. We modify the original by calling the function + on a copied reference to the table */ + lua_pushvalue(L, index); + /* Get table.sort. */ + lua_getglobal(L, "table"); + lua_getfield(L, -1, "sort"); + lua_replace(L, -2); + /* Put the (copy of the) table after the function. */ + lua_insert(L, -2); + lua_call(L, 1, 0); +} + /* int init_updatedb (lua_State *L) * * Loads all the files in ./scripts and puts them in the database. @@ -371,6 +386,9 @@ int init_updatedb (lua_State *L) lua_pushinteger(L, FILES); lua_call(L, 2, 1); // get all the .nse files in ./scripts + /* Sort what we get from nse_scandir so that script.db diffs are useful. */ + table_sort(L, 1); + // we rely on the fact that nmap_fetchfile returned a string which leaves enough room // to append the db filename (see call to nmap_fetchfile above) strncat(path, SCRIPT_ENGINE_DATABASE, MAX_FILENAME_LEN-1); diff --git a/scripts/script.db b/scripts/script.db index 80d8e7457..f2eeea159 100644 --- a/scripts/script.db +++ b/scripts/script.db @@ -1,109 +1,109 @@ -Entry{ category = "auth", filename = "xampp-default-auth.nse" } -Entry{ category = "vuln", filename = "xampp-default-auth.nse" } +Entry{ category = "discovery", filename = "asn-query.nse" } +Entry{ category = "external", filename = "asn-query.nse" } +Entry{ category = "default", filename = "auth-owners.nse" } +Entry{ category = "safe", filename = "auth-owners.nse" } +Entry{ category = "malware", filename = "auth-spoof.nse" } +Entry{ category = "discovery", filename = "banner.nse" } +Entry{ category = "safe", filename = "banner.nse" } +Entry{ category = "discovery", filename = "daytime.nse" } +Entry{ category = "external", filename = "dns-random-srcport.nse" } +Entry{ category = "intrusive", filename = "dns-random-srcport.nse" } +Entry{ category = "external", filename = "dns-random-txid.nse" } +Entry{ category = "intrusive", filename = "dns-random-txid.nse" } Entry{ category = "default", filename = "dns-recursion.nse" } Entry{ category = "intrusive", filename = "dns-recursion.nse" } -Entry{ category = "discovery", filename = "daytime.nse" } -Entry{ category = "demo", filename = "smtp-open-relay.nse" } -Entry{ category = "intrusive", filename = "snmp-brute.nse" } -Entry{ category = "auth", filename = "snmp-brute.nse" } +Entry{ category = "default", filename = "dns-zone-transfer.nse" } +Entry{ category = "intrusive", filename = "dns-zone-transfer.nse" } +Entry{ category = "discovery", filename = "dns-zone-transfer.nse" } +Entry{ category = "default", filename = "finger.nse" } +Entry{ category = "discovery", filename = "finger.nse" } +Entry{ category = "default", filename = "ftp-anon.nse" } +Entry{ category = "auth", filename = "ftp-anon.nse" } +Entry{ category = "safe", filename = "ftp-anon.nse" } +Entry{ category = "default", filename = "ftp-bounce.nse" } +Entry{ category = "intrusive", filename = "ftp-bounce.nse" } +Entry{ category = "default", filename = "html-title.nse" } +Entry{ category = "discovery", filename = "html-title.nse" } +Entry{ category = "safe", filename = "html-title.nse" } +Entry{ category = "default", filename = "http-auth.nse" } +Entry{ category = "auth", filename = "http-auth.nse" } +Entry{ category = "intrusive", filename = "http-auth.nse" } Entry{ category = "default", filename = "http-open-proxy.nse" } Entry{ category = "discovery", filename = "http-open-proxy.nse" } Entry{ category = "external", filename = "http-open-proxy.nse" } Entry{ category = "intrusive", filename = "http-open-proxy.nse" } -Entry{ category = "intrusive", filename = "smb-check-vulns.nse" } +Entry{ category = "intrusive", filename = "http-passwd.nse" } +Entry{ category = "vuln", filename = "http-passwd.nse" } +Entry{ category = "discovery", filename = "http-trace.nse" } +Entry{ category = "version", filename = "iax2-version.nse" } +Entry{ category = "default", filename = "irc-info.nse" } +Entry{ category = "discovery", filename = "irc-info.nse" } +Entry{ category = "default", filename = "ms-sql-info.nse" } +Entry{ category = "discovery", filename = "ms-sql-info.nse" } +Entry{ category = "intrusive", filename = "ms-sql-info.nse" } Entry{ category = "default", filename = "mysql-info.nse" } Entry{ category = "discovery", filename = "mysql-info.nse" } Entry{ category = "safe", filename = "mysql-info.nse" } +Entry{ category = "default", filename = "nbstat.nse" } +Entry{ category = "discovery", filename = "nbstat.nse" } +Entry{ category = "safe", filename = "nbstat.nse" } Entry{ category = "intrusive", filename = "pop3-brute.nse" } Entry{ category = "auth", filename = "pop3-brute.nse" } -Entry{ category = "malware", filename = "auth-spoof.nse" } -Entry{ category = "default", filename = "ftp-bounce.nse" } -Entry{ category = "intrusive", filename = "ftp-bounce.nse" } -Entry{ category = "default", filename = "irc-info.nse" } -Entry{ category = "discovery", filename = "irc-info.nse" } -Entry{ category = "discovery", filename = "sniffer-detect.nse" } +Entry{ category = "default", filename = "pop3-capabilities.nse" } Entry{ category = "version", filename = "pptp-version.nse" } -Entry{ category = "discovery", filename = "smb-enum-sessions.nse" } -Entry{ category = "intrusive", filename = "smb-enum-sessions.nse" } -Entry{ category = "default", filename = "finger.nse" } -Entry{ category = "discovery", filename = "finger.nse" } -Entry{ category = "discovery", filename = "whois.nse" } -Entry{ category = "external", filename = "whois.nse" } -Entry{ category = "safe", filename = "whois.nse" } +Entry{ category = "default", filename = "realvnc-auth-bypass.nse" } +Entry{ category = "vuln", filename = "realvnc-auth-bypass.nse" } +Entry{ category = "default", filename = "robots.txt.nse" } +Entry{ category = "discovery", filename = "robots.txt.nse" } +Entry{ category = "safe", filename = "robots.txt.nse" } +Entry{ category = "default", filename = "rpcinfo.nse" } +Entry{ category = "safe", filename = "rpcinfo.nse" } +Entry{ category = "discovery", filename = "rpcinfo.nse" } +Entry{ category = "version", filename = "skypev2-version.nse" } +Entry{ category = "intrusive", filename = "smb-check-vulns.nse" } Entry{ category = "discovery", filename = "smb-enum-domains.nse" } Entry{ category = "intrusive", filename = "smb-enum-domains.nse" } -Entry{ category = "discovery", filename = "http-trace.nse" } -Entry{ category = "default", filename = "upnp-info.nse" } -Entry{ category = "safe", filename = "upnp-info.nse" } -Entry{ category = "default", filename = "http-auth.nse" } -Entry{ category = "auth", filename = "http-auth.nse" } -Entry{ category = "intrusive", filename = "http-auth.nse" } -Entry{ category = "intrusive", filename = "http-passwd.nse" } -Entry{ category = "vuln", filename = "http-passwd.nse" } +Entry{ category = "discovery", filename = "smb-enum-sessions.nse" } +Entry{ category = "intrusive", filename = "smb-enum-sessions.nse" } +Entry{ category = "discovery", filename = "smb-enum-shares.nse" } +Entry{ category = "intrusive", filename = "smb-enum-shares.nse" } +Entry{ category = "discovery", filename = "smb-enum-users.nse" } +Entry{ category = "intrusive", filename = "smb-enum-users.nse" } +Entry{ category = "default", filename = "smb-os-discovery.nse" } +Entry{ category = "discovery", filename = "smb-os-discovery.nse" } +Entry{ category = "safe", filename = "smb-os-discovery.nse" } +Entry{ category = "discovery", filename = "smb-security-mode.nse" } +Entry{ category = "safe", filename = "smb-security-mode.nse" } +Entry{ category = "discovery", filename = "smb-server-stats.nse" } +Entry{ category = "intrusive", filename = "smb-server-stats.nse" } +Entry{ category = "discovery", filename = "smb-system-info.nse" } +Entry{ category = "intrusive", filename = "smb-system-info.nse" } +Entry{ category = "default", filename = "smtp-commands.nse" } +Entry{ category = "discovery", filename = "smtp-commands.nse" } +Entry{ category = "safe", filename = "smtp-commands.nse" } +Entry{ category = "demo", filename = "smtp-open-relay.nse" } +Entry{ category = "malware", filename = "smtp-strangeport.nse" } +Entry{ category = "discovery", filename = "sniffer-detect.nse" } +Entry{ category = "intrusive", filename = "snmp-brute.nse" } +Entry{ category = "auth", filename = "snmp-brute.nse" } +Entry{ category = "default", filename = "snmp-sysdescr.nse" } +Entry{ category = "discovery", filename = "snmp-sysdescr.nse" } +Entry{ category = "safe", filename = "snmp-sysdescr.nse" } Entry{ category = "intrusive", filename = "sql-injection.nse" } Entry{ category = "vuln", filename = "sql-injection.nse" } Entry{ category = "safe", filename = "ssh-hostkey.nse" } Entry{ category = "default", filename = "ssh-hostkey.nse" } Entry{ category = "intrusive", filename = "ssh-hostkey.nse" } -Entry{ category = "default", filename = "smtp-commands.nse" } -Entry{ category = "discovery", filename = "smtp-commands.nse" } -Entry{ category = "safe", filename = "smtp-commands.nse" } -Entry{ category = "discovery", filename = "asn-query.nse" } -Entry{ category = "external", filename = "asn-query.nse" } -Entry{ category = "version", filename = "iax2-version.nse" } -Entry{ category = "default", filename = "ms-sql-info.nse" } -Entry{ category = "discovery", filename = "ms-sql-info.nse" } -Entry{ category = "intrusive", filename = "ms-sql-info.nse" } Entry{ category = "default", filename = "sshv1.nse" } Entry{ category = "safe", filename = "sshv1.nse" } -Entry{ category = "default", filename = "nbstat.nse" } -Entry{ category = "discovery", filename = "nbstat.nse" } -Entry{ category = "safe", filename = "nbstat.nse" } -Entry{ category = "auth", filename = "telnet-brute.nse" } -Entry{ category = "intrusive", filename = "telnet-brute.nse" } -Entry{ category = "default", filename = "rpcinfo.nse" } -Entry{ category = "safe", filename = "rpcinfo.nse" } -Entry{ category = "discovery", filename = "rpcinfo.nse" } -Entry{ category = "default", filename = "realvnc-auth-bypass.nse" } -Entry{ category = "vuln", filename = "realvnc-auth-bypass.nse" } -Entry{ category = "external", filename = "dns-random-srcport.nse" } -Entry{ category = "intrusive", filename = "dns-random-srcport.nse" } -Entry{ category = "discovery", filename = "smb-system-info.nse" } -Entry{ category = "intrusive", filename = "smb-system-info.nse" } -Entry{ category = "default", filename = "pop3-capabilities.nse" } -Entry{ category = "discovery", filename = "smb-enum-shares.nse" } -Entry{ category = "intrusive", filename = "smb-enum-shares.nse" } Entry{ category = "default", filename = "sslv2.nse" } Entry{ category = "safe", filename = "sslv2.nse" } -Entry{ category = "external", filename = "dns-random-txid.nse" } -Entry{ category = "intrusive", filename = "dns-random-txid.nse" } -Entry{ category = "default", filename = "snmp-sysdescr.nse" } -Entry{ category = "discovery", filename = "snmp-sysdescr.nse" } -Entry{ category = "safe", filename = "snmp-sysdescr.nse" } -Entry{ category = "discovery", filename = "smb-server-stats.nse" } -Entry{ category = "intrusive", filename = "smb-server-stats.nse" } -Entry{ category = "discovery", filename = "smb-enum-users.nse" } -Entry{ category = "intrusive", filename = "smb-enum-users.nse" } -Entry{ category = "default", filename = "ftp-anon.nse" } -Entry{ category = "auth", filename = "ftp-anon.nse" } -Entry{ category = "safe", filename = "ftp-anon.nse" } -Entry{ category = "default", filename = "dns-zone-transfer.nse" } -Entry{ category = "intrusive", filename = "dns-zone-transfer.nse" } -Entry{ category = "discovery", filename = "dns-zone-transfer.nse" } -Entry{ category = "default", filename = "smb-os-discovery.nse" } -Entry{ category = "discovery", filename = "smb-os-discovery.nse" } -Entry{ category = "safe", filename = "smb-os-discovery.nse" } -Entry{ category = "default", filename = "html-title.nse" } -Entry{ category = "discovery", filename = "html-title.nse" } -Entry{ category = "safe", filename = "html-title.nse" } -Entry{ category = "version", filename = "skypev2-version.nse" } -Entry{ category = "default", filename = "robots.txt.nse" } -Entry{ category = "discovery", filename = "robots.txt.nse" } -Entry{ category = "safe", filename = "robots.txt.nse" } -Entry{ category = "discovery", filename = "smb-security-mode.nse" } -Entry{ category = "safe", filename = "smb-security-mode.nse" } -Entry{ category = "malware", filename = "smtp-strangeport.nse" } -Entry{ category = "default", filename = "auth-owners.nse" } -Entry{ category = "safe", filename = "auth-owners.nse" } -Entry{ category = "discovery", filename = "banner.nse" } -Entry{ category = "safe", filename = "banner.nse" } +Entry{ category = "auth", filename = "telnet-brute.nse" } +Entry{ category = "intrusive", filename = "telnet-brute.nse" } +Entry{ category = "default", filename = "upnp-info.nse" } +Entry{ category = "safe", filename = "upnp-info.nse" } +Entry{ category = "discovery", filename = "whois.nse" } +Entry{ category = "external", filename = "whois.nse" } +Entry{ category = "safe", filename = "whois.nse" } +Entry{ category = "auth", filename = "xampp-default-auth.nse" } +Entry{ category = "vuln", filename = "xampp-default-auth.nse" }