Commits

Tim Tomes  committed a2813cf

added socket timeout option.

  • Participants
  • Parent commits 1510244

Comments (0)

Files changed (2)

     phantom.exit(0);
 };
 // set connection timeout below
-var timer = window.setTimeout(callback, 5000, 'timeout');
+var timer = window.setTimeout(callback, parseInt(phantom.args[2]), 'timeout');
 page.open(url, callback);

File peepingtom.py

     parser.add_option('-l', help='File input mode. Path to input file.', dest='list_file', type='string', action='store')
     parser.add_option('-n', help='Nessus input mode. Path to Nessus XML file.', dest='nessus_file', type='string', action='store')
     parser.add_option('-s', help='Single input mode. Path to target, remote URL or local path.', dest='target', type='string', action='store')
+    parser.add_option('-t', help='Socket timeout in seconds. Default is 5 seconds.', dest='timeout', type='int', action='store')
     (opts, args) = parser.parse_args()
 
     # process options
     else:
         print '[!] Input mode required.'
         return
+    timeout = opts.timeout if opts.timeout else 5
 
     print '[*] Analyzing %d targets.' % (len(targets))
 
             filename = '%s.png' % re.sub('\W','',target)
             filepath = '%s/%s' % (directory, filename)
             print '[*] %s' % (target)
-            getCapture(target, filepath)
+            getCapture(target, filepath, timeout)
             target_data = {}
             target_data['url'] = target
             target_data['path'] = filename
             target_data['hash'] = hashlib.md5(open(filepath).read()).hexdigest() if os.path.exists(filepath) else 'z'*32
-            target_data['headers'] = getHeaders(target)
+            target_data['headers'] = getHeaders(target, timeout)
             db['targets'].append(target_data)
     except Exception as e:
         print '[!] %s' % (e.__str__())
         return "https"
     return "http"
 
-def getCapture(url, filename):
-    cmd = './phantomjs --ignore-ssl-errors=yes ./capture.js %s %s' % (url, filename)
+def getCapture(url, filename, timeout):
+    cmd = './phantomjs --ignore-ssl-errors=yes ./capture.js %s %s %d' % (url, filename, timeout*1000)
     returncode, response = runCommand(cmd)
     return returncode
 
-def getHeaders(url):
-    cmd = 'curl -sILk %s' % (url)
+def getHeaders(url, timeout):
+    cmd = 'curl -sILk %s --connect-timeout %d' % (url, timeout)
     returncode, response = runCommand(cmd)
     return response