add: configurable timeout for scanning
fix: target spliting
This commit is contained in:
@@ -33,7 +33,7 @@ __banner__ = """
|
|||||||
____ _ _ ___ ____ _ ____ ___ ____ ____ ____
|
____ _ _ ___ ____ _ ____ ___ ____ ____ ____
|
||||||
|___ |\ | | |___ | |___ | |__| | | |__/
|
|___ |\ | | |___ | |___ | |__| | | |__/
|
||||||
|___ | \| | |___ |___ |___ | | | |__| | \\
|
|___ | \| | |___ |___ |___ | | | |__| | \\
|
||||||
"""
|
""" # Font name: Cyberlarge
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Generic global config
|
# Generic global config
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import logging
|
|||||||
from modules import IModule
|
from modules import IModule
|
||||||
|
|
||||||
from libs.core.structs import CommonData
|
from libs.core.structs import CommonData
|
||||||
from libs.core.models import StringField, BoolField, IntegerField
|
from libs.core.models import StringField, BoolField, IntegerField, FloatField
|
||||||
|
|
||||||
from .scan_main import action_scan_main
|
from .scan_main import action_scan_main
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ class ModuleModel(CommonData):
|
|||||||
own_ips = BoolField(label="Try to find all IPs registered for this company")
|
own_ips = BoolField(label="Try to find all IPs registered for this company")
|
||||||
concurrency = IntegerField(label="maximum parallels scans", default=10)
|
concurrency = IntegerField(label="maximum parallels scans", default=10)
|
||||||
output = StringField(label="output file, in JSON format")
|
output = StringField(label="output file, in JSON format")
|
||||||
|
timeout = FloatField(label="timeout for socket connections", default=0.2)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def _do_scan(config, sem, host):
|
|||||||
|
|
||||||
# Try to check if port is open
|
# Try to check if port is open
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.settimeout(1)
|
s.settimeout(config.timeout)
|
||||||
|
|
||||||
result = s.connect_ex((host, int(port)))
|
result = s.connect_ex((host, int(port)))
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ def _do_scan(config, sem, host):
|
|||||||
|
|
||||||
# Is port open?
|
# Is port open?
|
||||||
if result == 0:
|
if result == 0:
|
||||||
log.error(" ) Port '%s' is open in '%s'" % (port, host))
|
log.info(" <i> Port '%s' is open in '%s'" % (port, host))
|
||||||
|
|
||||||
if handle(host, port, config) is True:
|
if handle(host, port, config) is True:
|
||||||
log.error(" <!!> Open '%s' server found in port '%s'" % (server_type, port))
|
log.error(" <!!> Open '%s' server found in port '%s' at '%s'" % (server_type, port, host))
|
||||||
|
|
||||||
OPEN_SERVICES[host][server_type] = dict(
|
OPEN_SERVICES[host][server_type] = dict(
|
||||||
state="open",
|
state="open",
|
||||||
@@ -121,6 +121,19 @@ def action_scan_main(config):
|
|||||||
for t in threads:
|
for t in threads:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Display results
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
if OPEN_SERVICES:
|
||||||
|
log.error(" - Open services found:")
|
||||||
|
for host, content in six.iteritems(OPEN_SERVICES):
|
||||||
|
log.error(" -> Host - %s" % host)
|
||||||
|
for server_type, server_info in six.iteritems(content):
|
||||||
|
log.error(" * %s/TCP [%s]" % (server_info['port'], server_type))
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(" - No open services found")
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Export results
|
# Export results
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -139,7 +152,7 @@ def build_targets(config):
|
|||||||
results = set()
|
results = set()
|
||||||
|
|
||||||
# Split targets
|
# Split targets
|
||||||
for t in config.target.split("-"):
|
for t in config.target.split(","):
|
||||||
try:
|
try:
|
||||||
results.update(str(x) for x in ipaddress.ip_network(t, strict=False))
|
results.update(str(x) for x in ipaddress.ip_network(t, strict=False))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user