Author: kost
Date: 2008-10-26 10:06:38 +0100 (Sun, 26 Oct 2008)
New Revision: 1625
Modified:
trunk/openvas-plugins/ChangeLog
trunk/openvas-plugins/scripts/pnscan.nasl
trunk/openvas-plugins/scripts/portbunny.nasl
Log:
Support for all port range specifications (including default), portbunny hang
debugged and found out it's problem in portbunny itself, so sent the patch to
the author (introduced new option -u)
Modified: trunk/openvas-plugins/ChangeLog
===================================================================
--- trunk/openvas-plugins/ChangeLog 2008-10-24 21:54:40 UTC (rev 1624)
+++ trunk/openvas-plugins/ChangeLog 2008-10-26 09:06:38 UTC (rev 1625)
@@ -1,3 +1,10 @@
+2008-10-26 Vlatko Kosturjak <[EMAIL PROTECTED]>
+
+ * scripts/pnscan.nasl, scripts/portbunny.nasl:
+ Support for all port range specifications (including default),
+ portbunny hang debugged and found out it's problem in portbunny
+ itself, so sent the patch to the author (introduced new option -u)
+
2008-10-24 Vlatko Kosturjak <[EMAIL PROTECTED]>
* scripts/eyeos_command_execution.nasl:
Modified: trunk/openvas-plugins/scripts/pnscan.nasl
===================================================================
--- trunk/openvas-plugins/scripts/pnscan.nasl 2008-10-24 21:54:40 UTC (rev
1624)
+++ trunk/openvas-plugins/scripts/pnscan.nasl 2008-10-26 09:06:38 UTC (rev
1625)
@@ -15,7 +15,7 @@
if(description)
{
script_id(80001);
- script_version ("1.12");
+ script_version ("1.20");
name["english"] = "pnscan (NASL wrapper)";
script_name(english:name["english"]);
@@ -61,6 +61,28 @@
else
esc_ip = strcat(esc_ip, ip[i]);
+prange = get_preference("port_range");
+if (! prange) prange = "1-65535";
+if (prange == "default" )
+{
+ n = 0;
+ str = "";
+ while ( port = scanner_get_port(n) )
+ {
+ if ( n > 0 ) str += "," + string(port);
+ else str = string(port);
+ n ++;
+ }
+ prange=str;
+}
+
+portrangelist=split(prange,sep:",",keep:FALSE);
+
+n_ports = 0;
+oports[0]=0;
+
+foreach pr (portrangelist) {
+
i = 0;
argv[i++] = "pnscan";
argv[i++] = "-l";
@@ -72,8 +94,6 @@
if ( p) argv[i++] = "-n "+p;
argv[i++] = ip;
- pr = get_preference("port_range");
- if (! pr) pr = "1:65535";
# replace patterns like 1-65535 to 1:65535
pr2 = ereg_replace (string:pr, pattern:"-",replace:":",icase:FALSE);
argv[i++] = pr2;
@@ -84,27 +104,32 @@
# 127.0.0.1 : 22 : TXT : SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
# 127.0.0.1 : 3306 : HEX : 40 00 00 00 0a 35 2e 30 2e 35 31 61 2d 33 75
62 75 6e 74 75 35 2e 31 00 30 00 00 00 2f 26 6f 21 50 50 22 58 00 2c a2 08 02
00 00 00 00 00 00 00 00 00 00 00 00 00 00 72 56 39 5a 39 4b 50 2d 32
-n_ports = 0;
+ foreach line(split(res))
+ {
+ v = eregmatch(string: line, pattern: '^'+esc_ip+' *: *([0-9]+)
*:([^:]*): *(.*)$');
+ if (! isnull(v))
+ {
+ port = v[1];
+ if (isnull(oports[port])) {
+ n_ports++;
+ oports[port]=port;
+ proto = "tcp";
+ scanner_add_port(proto: proto, port: port);
+ }
+ }
+ }
-foreach line(split(res))
-{
- v = eregmatch(string: line, pattern: '^'+esc_ip+' *: *([0-9]+) *:([^:]*):
*(.*)$');
- if (! isnull(v))
- {
- scanner_status(current: ++ n_ports, total: 65535 * 2);
- port = v[1];
- proto = "tcp";
- scanner_add_port(proto: proto, port: port);
- }
}
-if (n_ports != 0)
-{
- set_kb_item(name: "Host/scanned", value: TRUE);
- set_kb_item(name: 'Host/scanners/pnscan', value: TRUE);
- if (pr2 == '1:65535')
- set_kb_item(name: "Host/full_scan", value: TRUE);
+if (n_ports == 0) {
+ security_note(port:0,proto:"tcp",data:"Host does not have any TCP port
open which is specified in port range");
}
-scanner_status(current: 65535 * 2, total: 65535 * 2);
+set_kb_item(name: "Host/scanned", value: TRUE);
+set_kb_item(name: 'Host/scanners/pnscan', value: TRUE);
+if (pr2 == '1:65535')
+ set_kb_item(name: "Host/full_scan", value: TRUE);
+scanner_status(current: 65535, total: 65535);
+
+exit (0);
Modified: trunk/openvas-plugins/scripts/portbunny.nasl
===================================================================
--- trunk/openvas-plugins/scripts/portbunny.nasl 2008-10-24 21:54:40 UTC
(rev 1624)
+++ trunk/openvas-plugins/scripts/portbunny.nasl 2008-10-26 09:06:38 UTC
(rev 1625)
@@ -3,7 +3,6 @@
# Distributed under GPL v2+
#
# TODO:
-# - fix hang of portbunny UI
# - report back banners grabbed
# - script_oid
# - sign the script
@@ -16,7 +15,7 @@
if(description)
{
script_id(80002);
- script_version ("1.11");
+ script_version ("1.20");
name["english"] = "portbunny (NASL wrapper)";
script_name(english:name["english"]);
@@ -66,6 +65,7 @@
i = 0;
argv[i++] = "portbunny";
+ argv[i++] = "-u";
p = script_get_preference("Wait longer for triggers to return");
if ( p) argv[i++] = "-w";
@@ -73,6 +73,18 @@
argv[i++] = ip;
pr = get_preference("port_range");
if (! pr) pr = "1-65535";
+ if (pr == "default" )
+ {
+ n = 0;
+ str = "";
+ while ( port = scanner_get_port(n) )
+ {
+ if ( n > 0 ) str += "," + string(port);
+ else str = string(port);
+ n ++;
+ }
+ pr=str;
+ }
argv[i++] = "-p";
argv[i++] = pr;
@@ -90,31 +102,33 @@
n_ports = 0;
-
foreach line(split(res))
{
- v = eregmatch(string: line, pattern: '^'+esc_ip+' *([0-9]+) *([A-Z]*)
*(.*)$');
+ v = eregmatch(string: line, pattern: '^'+esc_ip+'[ \t]*([0-9]+)[
\t]*([A-Z]+)[ \t]*([A-Za-z0-9]*)');
# debug
- display (":");
- if (isnull(v)) display ("null:"+esc_ip);
- else display (v[1]);
- display ("\n");
- if (! isnull(v) && v[3] == "OPEN")
+# display (":");
+# if (isnull(v)) display ("null:"+esc_ip);
+# else display (v[1]+":"+v[2]+":"+v[3]);
+# display ("\n");
+ if (! isnull(v) && v[2] == "OPEN")
{
- scanner_status(current: ++ n_ports, total: 65535);
+ n_ports++;
port = v[1];
proto = "tcp";
scanner_add_port(proto: proto, port: port);
}
}
-if (n_ports != 0)
+if (n_ports == 0)
{
- set_kb_item(name: "Host/scanned", value: TRUE);
- set_kb_item(name: 'Host/scanners/portbunny', value: TRUE);
- if (pr == '1-65535')
- set_kb_item(name: "Host/full_scan", value: TRUE);
+ security_note(port:0, proto:"tcp",data:"Host does not have any open TCP
port");
}
+set_kb_item(name: "Host/scanned", value: TRUE);
+set_kb_item(name: 'Host/scanners/portbunny', value: TRUE);
+if (pr == '1-65535')
+ set_kb_item(name: "Host/full_scan", value: TRUE);
+
scanner_status(current: 65535, total: 65535);
+exit (0);
_______________________________________________
Openvas-commits mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits