| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 169cba4 commit 58b6d41
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,10 @@ | |||
| 27 | 27 | import signal | |
| 28 | 28 | import shutil | |
| 29 | 29 | import hashlib | |
| 30 | + from pyvirtualdisplay import Display | ||
| 31 | + from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | ||
| 32 | + | ||
| 33 | + | ||
| 30 | 34 | ||
| 31 | 35 | try: | |
| 32 | 36 | from urllib.parse import quote | |
@@ -163,13 +167,15 @@ def parseGnmap(inFile, autodetect): | |||
| 163 | 167 | def setupBrowserProfile(headless,proxy): | |
| 164 | 168 | browser = None | |
| 165 | 169 | if(proxy is not None): | |
| 166 | - service_args=['--ignore-ssl-errors=true','--ssl-protocol=tlsv1','--proxy='+proxy,'--proxy-type=socks5'] | ||
| 170 | + service_args=['--ignore-ssl-errors=true','--ssl-protocol=any','--proxy='+proxy,'--proxy-type=socks5'] | ||
| 167 | 171 | else: | |
| 168 | - service_args=['--ignore-ssl-errors=true','--ssl-protocol=tlsv1'] | ||
| 172 | + service_args=['--ignore-ssl-errors=true','--ssl-protocol=any'] | ||
| 169 | 173 | ||
| 170 | 174 | while(browser is None): | |
| 171 | 175 | try: | |
| 172 | 176 | if(not headless): | |
| 177 | + capabilities = DesiredCapabilities.FIREFOX | ||
| 178 | + capabilities['acceptSslCerts'] = True | ||
| 173 | 179 | fp = webdriver.FirefoxProfile() | |
| 174 | 180 | fp.set_preference("webdriver.accept.untrusted.certs",True) | |
| 175 | 181 | fp.set_preference("security.enable_java", False) | |
@@ -179,9 +185,11 @@ def setupBrowserProfile(headless,proxy): | |||
| 179 | 185 | fp.set_preference("network.proxy.socks",proxyItems[0]) | |
| 180 | 186 | fp.set_preference("network.proxy.socks_port",int(proxyItems[1])) | |
| 181 | 187 | fp.set_preference("network.proxy.type",1) | |
| 182 | - browser = webdriver.Firefox(fp) | ||
| 188 | + browser = webdriver.Firefox(firefox_profile=fp,capabilities=capabilities) | ||
| 183 | 189 | else: | |
| 184 | 190 | browser = webdriver.PhantomJS(service_args=service_args, executable_path="phantomjs") | |
| 191 | + browser.set_window_size(1024, 768) | ||
| 192 | + | ||
| 185 | 193 | except Exception as e: | |
| 186 | 194 | print e | |
| 187 | 195 | time.sleep(1) | |
@@ -206,14 +214,21 @@ def worker(urlQueue, tout, debug, headless, doProfile, vhosts, subs, extraHosts, | |||
| 206 | 214 | print '[*] Starting worker' | |
| 207 | 215 | ||
| 208 | 216 | browser = None | |
| 217 | + display = None | ||
| 209 | 218 | try: | |
| 219 | + if(tryGUIOnFail or not headless): | ||
| 220 | + display = Display(visible=0, size=(800, 600)) | ||
| 221 | + display.start() | ||
| 222 | + | ||
| 210 | 223 | browser = setupBrowserProfile(headless,proxy) | |
| 211 | 224 | ||
| 212 | 225 | except: | |
| 213 | 226 | print "[-] Oh no! Couldn't create the browser, Selenium blew up" | |
| 214 | 227 | exc_type, exc_value, exc_traceback = sys.exc_info() | |
| 215 | 228 | lines = traceback.format_exception(exc_type, exc_value, exc_traceback) | |
| 216 | 229 | print ''.join('!! ' + line for line in lines) | |
| 230 | + browser.quit() | ||
| 231 | + display.stop() | ||
| 217 | 232 | return | |
| 218 | 233 | ||
| 219 | 234 | while True: | |
@@ -268,50 +283,68 @@ def worker(urlQueue, tout, debug, headless, doProfile, vhosts, subs, extraHosts, | |||
| 268 | 283 | hash_basket[resp_hash] = screenshotName | |
| 269 | 284 | ||
| 270 | 285 | ||
| 271 | - browser.set_window_size(1024, 768) | ||
| 286 | + #browser.set_window_size(1024, 768) | ||
| 272 | 287 | browser.set_page_load_timeout((tout)) | |
| 273 | 288 | old_url = browser.current_url | |
| 274 | 289 | browser.get(curUrl[0].strip()) | |
| 275 | 290 | if(browser.current_url == old_url): | |
| 276 | 291 | print "[-] Error fetching in browser but successfully fetched with Requests: "+curUrl[0] | |
| 277 | 292 | if(headless): | |
| 293 | + browser2 = None | ||
| 278 | 294 | if(debug): | |
| 279 | 295 | print "[+] Trying with sslv3 instead of TLS - known phantomjs bug: "+curUrl[0] | |
| 280 | - browser2 = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'], executable_path="phantomjs") | ||
| 281 | - old_url = browser2.current_url | ||
| 282 | - browser2.get(curUrl[0].strip()) | ||
| 283 | - if(browser2.current_url == old_url): | ||
| 284 | - if(debug): | ||
| 285 | - print "[-] Didn't work with SSLv3 either..."+curUrl[0] | ||
| 286 | - browser2.close() | ||
| 296 | + if(proxy is not None): | ||
| 297 | + browser2 = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true','--proxy='+proxy,'--proxy-type=socks5'], executable_path="phantomjs") | ||
| 287 | 298 | else: | |
| 288 | - print '[+] Saving: '+screenshotName | ||
| 289 | - html_source = browser2.page_source | ||
| 290 | - f = open(screenshotName+".html",'w') | ||
| 291 | - f.write(html_source) | ||
| 292 | - f.close() | ||
| 293 | - browser2.save_screenshot(screenshotName+".png") | ||
| 294 | - browser2.close() | ||
| 295 | - continue | ||
| 299 | + browser2 = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'], executable_path="phantomjs") | ||
| 300 | + #print "Launched browser2: "+str(browser2.service.process.pid) | ||
| 301 | + | ||
| 302 | + old_url = browser2.current_url | ||
| 303 | + try: | ||
| 304 | + browser2.get(curUrl[0].strip()) | ||
| 305 | + if(browser2.current_url == old_url): | ||
| 306 | + if(debug): | ||
| 307 | + print "[-] Didn't work with SSLv3 either..."+curUrl[0] | ||
| 308 | + browser2.quit() | ||
| 309 | + else: | ||
| 310 | + print '[+] Saving: '+screenshotName | ||
| 311 | + html_source = browser2.page_source | ||
| 312 | + f = open(screenshotName+".html",'w') | ||
| 313 | + f.write(html_source) | ||
| 314 | + f.close() | ||
| 315 | + browser2.save_screenshot(screenshotName+".png") | ||
| 316 | + browser2.quit() | ||
| 317 | + continue | ||
| 318 | + except: | ||
| 319 | + browser2.quit() | ||
| 320 | + print "[-] Didn't work with SSLv3 either - exception..."+curUrl[0] | ||
| 296 | 321 | ||
| 297 | 322 | if(tryGUIOnFail and headless): | |
| 323 | + display = Display(visible=0, size=(1024, 768)) | ||
| 324 | + display.start() | ||
| 298 | 325 | print "[+] Attempting to fetch with FireFox: "+curUrl[0] | |
| 299 | 326 | browser2 = setupBrowserProfile(False,proxy) | |
| 300 | 327 | old_url = browser2.current_url | |
| 301 | - browser2.get(curUrl[0].strip()) | ||
| 302 | - if(browser2.current_url == old_url): | ||
| 328 | + try: | ||
| 329 | + browser2.get(curUrl[0].strip()) | ||
| 330 | + if(browser2.current_url == old_url): | ||
| 331 | + print "[-] Error fetching in GUI browser as well..."+curUrl[0] | ||
| 332 | + browser2.quit() | ||
| 333 | + continue | ||
| 334 | + else: | ||
| 335 | + print '[+] Saving: '+screenshotName | ||
| 336 | + html_source = browser2.page_source | ||
| 337 | + f = open(screenshotName+".html",'w') | ||
| 338 | + f.write(html_source) | ||
| 339 | + f.close() | ||
| 340 | + browser2.save_screenshot(screenshotName+".png") | ||
| 341 | + browser2.quit() | ||
| 342 | + continue | ||
| 343 | + except: | ||
| 344 | + browser2.quit() | ||
| 345 | + display.stop() | ||
| 303 | 346 | print "[-] Error fetching in GUI browser as well..."+curUrl[0] | |
| 304 | - browser2.close() | ||
| 305 | - continue | ||
| 306 | - else: | ||
| 307 | - print '[+] Saving: '+screenshotName | ||
| 308 | - html_source = browser2.page_source | ||
| 309 | - f = open(screenshotName+".html",'w') | ||
| 310 | - f.write(html_source) | ||
| 311 | - f.close() | ||
| 312 | - browser2.save_screenshot(screenshotName+".png") | ||
| 313 | - browser2.close() | ||
| 314 | - continue | ||
| 347 | + | ||
| 315 | 348 | else: | |
| 316 | 349 | continue | |
| 317 | 350 | ||
@@ -331,11 +364,12 @@ def worker(urlQueue, tout, debug, headless, doProfile, vhosts, subs, extraHosts, | |||
| 331 | 364 | if(debug): | |
| 332 | 365 | exc_type, exc_value, exc_traceback = sys.exc_info() | |
| 333 | 366 | lines = traceback.format_exception(exc_type, exc_value, exc_traceback) | |
| 334 | - print ''.join('!! ' + line for line in lines) | ||
| 367 | + print ''.join('!! ' + line for line in lines) | ||
| 335 | 368 | browser.quit() | |
| 336 | 369 | browser = setupBrowserProfile(headless,proxy) | |
| 337 | 370 | continue | |
| 338 | - | ||
| 371 | + browser.quit() | ||
| 372 | + display.stop() | ||
| 339 | 373 | ||
| 340 | 374 | def doGet(*args, **kwargs): | |
| 341 | 375 | url = args[0] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | # Error out if one fails | |
| 7 | 7 | set -e | |
| 8 | 8 | ||
| 9 | - apt-get install -y swig swig3.0 libssl-dev python-dev libjpeg-dev | ||
| 9 | + apt-get install -y swig swig3.0 libssl-dev python-dev libjpeg-dev xvfb | ||
| 10 | 10 | ||
| 11 | 11 | # Newer version in PyPI | |
| 12 | 12 | #apt-get install -y python-requests | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,3 +5,4 @@ beautifulsoup4 | |||
| 5 | 5 | pillow | |
| 6 | 6 | requesocks | |
| 7 | 7 | python-libnmap | |
| 8 | + pyvirtualdisplay | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments