- minor bug fixes

This commit is contained in:
Barak Hoffer 2015-10-08 13:30:36 +03:00
parent b5b8423df7
commit 35859c1a21
4 changed files with 14 additions and 8 deletions

View File

@ -101,10 +101,10 @@ class Configuration(object):
singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}" singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}"
# how long to wait between scan iterations # how long to wait between scan iterations
timeout_between_iterations = 120 timeout_between_iterations = 10
# how many scan iterations to perform on each run # how many scan iterations to perform on each run
max_iterations = 5 max_iterations = 3
scanner_class = TcpScanner scanner_class = TcpScanner
finger_classes = (PingScanner, SSHFinger, SMBFinger) finger_classes = (PingScanner, SSHFinger, SMBFinger)
@ -130,11 +130,11 @@ class Configuration(object):
#range_class = RelativeRange #range_class = RelativeRange
range_size = 8 range_size = 8
range_class = FixedRange range_class = FixedRange
range_fixed = ("10.0.0.9", "10.0.0.13", "192.168.1.100", "192.168.1.87") range_fixed = ("10.0.0.9", "10.0.0.13", "192.168.1.87")
# TCP Scanner # TCP Scanner
tcp_target_ports = [22, 445, 135, 3389] tcp_target_ports = [22, 445, 135, 3389]
tcp_scan_timeout = 1000 # 1000 Milliseconds tcp_scan_timeout = 3000 # 3000 Milliseconds
tcp_scan_interval = 200 tcp_scan_interval = 200
tcp_scan_get_banner = True tcp_scan_get_banner = True

View File

@ -43,7 +43,7 @@ class NetworkScanner(object):
victims_count = 0 victims_count = 0
for range in self._ranges: for range in self._ranges:
LOG.debug("Scanning for potantional victims in the network %r", range) LOG.debug("Scanning for potential victims in the network %r", range)
for victim in range: for victim in range:
# skip self IP address # skip self IP address
if victim.ip_addr in self._ip_addresses: if victim.ip_addr in self._ip_addresses:
@ -53,7 +53,7 @@ class NetworkScanner(object):
# if scanner detect machine is up, add it to victims list # if scanner detect machine is up, add it to victims list
if scanner.is_host_alive(victim): if scanner.is_host_alive(victim):
LOG.debug("Found potational victim: %r", victim) LOG.debug("Found potential victim: %r", victim)
victims_count += 1 victims_count += 1
yield victim yield victim

View File

@ -26,7 +26,7 @@ class TcpScanner(HostScanner, HostFinger):
is_open, banner = check_port_tcp(host.ip_addr, is_open, banner = check_port_tcp(host.ip_addr,
target_port, target_port,
self._config.tcp_scan_interval / 1000.0, self._config.tcp_scan_timeout / 1000.0,
self._config.tcp_scan_get_banner) self._config.tcp_scan_get_banner)
if is_open: if is_open:

View File

@ -1,17 +1,23 @@
import socket import socket
import select import select
import logging
DEFAULT_TIMEOUT = 10 DEFAULT_TIMEOUT = 10
BANNER_READ = 1024 BANNER_READ = 1024
LOG = logging.getLogger(__name__)
def check_port_tcp(ip, port, timeout=DEFAULT_TIMEOUT, get_banner=False): def check_port_tcp(ip, port, timeout=DEFAULT_TIMEOUT, get_banner=False):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout) sock.settimeout(timeout)
try: try:
sock.connect((ip, port)) sock.connect((ip, port))
except socket.error: except socket.timeout:
return (False, None) return (False, None)
except socket.error, exc:
LOG.debug("Check port: %s:%s, Exception: %s", ip, port, exc)
return (False, None)
banner = None banner = None