added a timeout option for vnc_login

pull/4/merge
lanjelot 12 years ago
parent eada497c57
commit 3714354e27

@ -1251,10 +1251,14 @@ Please read the README inside for more examples and usage information.
if 'free' in actions: if 'free' in actions:
self.register_free(payload, actions['free']) self.register_free(payload, actions['free'])
break
if 'retry' in actions and 'fail' not in actions: if 'fail' in actions:
break
if 'retry' in actions:
continue continue
break break
def monitor_progress(self): def monitor_progress(self):
@ -1302,7 +1306,7 @@ Please read the README inside for more examples and usage information.
if 'fail' in actions: if 'fail' in actions:
p.fail_count += 1 p.fail_count += 1
if 'quit' in actions: if 'quit' in actions and 'retry' not in actions:
raise SystemExit raise SystemExit
@ -1363,7 +1367,7 @@ Please read the README inside for more examples and usage information.
for i, p in enumerate(self.thread_progress): for i, p in enumerate(self.thread_progress):
total_count = p.done_count + p.skip_count total_count = p.done_count + p.skip_count
logger.info(' #{0}: {1:>3}% ({2}/{3}) {4}'.format( logger.info(' #{0}: {1:>3}% ({2}/{3}) {4}'.format(
i, i+1,
total_count * 100/(self.total_size/self.num_threads), total_count * 100/(self.total_size/self.num_threads),
total_count, total_count,
self.total_size/self.num_threads, self.total_size/self.num_threads,
@ -2173,7 +2177,7 @@ class POP_login(TCP_Cache):
fp = POP3(host, int(port), timeout=int(timeout)) fp = POP3(host, int(port), timeout=int(timeout))
else: else:
if not port: port = 995 if not port: port = 995
fp = POP3_SSL(host, int(port), timeout=int(timeout)) # timeout was New in python 2.7 fp = POP3_SSL(host, int(port)) # timeout=int(timeout)) # no timeout option in python2
return POP_Connection(fp, fp.welcome) return POP_Connection(fp, fp.welcome)
@ -2674,7 +2678,7 @@ class HTTP_fuzz(TCP_Cache):
fp.setopt(pycurl.CUSTOMREQUEST, method) fp.setopt(pycurl.CUSTOMREQUEST, method)
headers = [h.strip('\r') for h in header.split('\n') if h] headers = [h.strip('\r') for h in header.split('\n') if h]
fp.setopt(pycurl.HTTPHEADER, headers) # warning: this disables the use of "Expect: 100-continue" header fp.setopt(pycurl.HTTPHEADER, headers)
fp.perform() fp.perform()
@ -2723,8 +2727,8 @@ except ImportError:
class VNC_Error(Exception): pass class VNC_Error(Exception): pass
class VNC: class VNC:
def connect(self, host, port): def connect(self, host, port, timeout):
self.fp = socket.create_connection((host, port)) self.fp = socket.create_connection((host, port), timeout=timeout)
resp = self.fp.recv(99) # banner resp = self.fp.recv(99) # banner
logger.debug('banner: %s' % repr(resp)) logger.debug('banner: %s' % repr(resp))
@ -2772,7 +2776,7 @@ class VNC:
resp = resp[-16:] resp = resp[-16:]
if len(resp) != 16: if len(resp) != 16:
raise VNC_Error('Unexpected challenge size (unsupported authentication type ?)') raise VNC_Error('Unexpected challenge size (No authentication required? Unsupported authentication type?)')
logger.debug('challenge: %s' % repr(resp)) logger.debug('challenge: %s' % repr(resp))
pw = password.ljust(8, '\x00')[:8] # make sure it is 8 chars long, zero padded pw = password.ljust(8, '\x00')[:8] # make sure it is 8 chars long, zero padded
@ -2829,16 +2833,17 @@ class VNC_login:
('host', 'hostnames or subnets to target'), ('host', 'hostnames or subnets to target'),
('port', 'ports to target [5900]'), ('port', 'ports to target [5900]'),
('password', 'passwords to test'), ('password', 'passwords to test'),
('timeout', 'seconds to wait for a response [10]'),
) )
available_actions = () available_actions = ()
Response = Response_Base Response = Response_Base
def execute(self, host, port=None, password=None): def execute(self, host, port=None, password=None, timeout='10'):
v = VNC() v = VNC()
try: try:
code, mesg = 0, v.connect(host, int(port or 5900)) code, mesg = 0, v.connect(host, int(port or 5900), int(timeout))
if password is not None: if password is not None:
code, mesg = v.login(password) code, mesg = v.login(password)

Loading…
Cancel
Save