|
1 | 1 | #!/usr/bin/python3 |
2 | | -""" |
3 | | -Installation on Ubuntu: |
4 | | -apt-get install python-requests python-m2crypto phantomjs |
5 | | -If you run into: 'module' object has no attribute 'PhantomJS' |
6 | | -then pip install selenium (or pip install --upgrade selenium) |
7 | | -""" |
8 | 2 |
|
9 | 3 | from selenium import webdriver |
10 | 4 | from urllib.parse import urlparse |
@@ -185,28 +179,28 @@ def setupBrowserProfile(headless, proxy): |
185 | 179 |
|
186 | 180 | while browser is None: |
187 | 181 | try: |
188 | | - if not headless: |
189 | | - capabilities = DesiredCapabilities.FIREFOX |
190 | | - capabilities["acceptSslCerts"] = True |
191 | | - fp = webdriver.FirefoxProfile() |
192 | | - fp.set_preference("webdriver.accept.untrusted.certs", True) |
193 | | - fp.set_preference("security.enable_java", False) |
194 | | - fp.set_preference("webdriver.load.strategy", "fast") |
195 | | - if proxy is not None: |
196 | | - proxyItems = proxy.split(":") |
197 | | - fp.set_preference("network.proxy.socks", proxyItems[0]) |
198 | | - fp.set_preference("network.proxy.socks_port", |
199 | | - int(proxyItems[1])) |
200 | | - fp.set_preference("network.proxy.type", 1) |
201 | | - browser = webdriver.Firefox(firefox_profile=fp, |
202 | | - capabilities=capabilities) |
203 | | - else: |
204 | | - capabilities = DesiredCapabilities.FIREFOX |
205 | | - capabilities["acceptSslCerts"] = True |
206 | | - fireFoxOptions = webdriver.FirefoxOptions() |
| 182 | + capabilities = DesiredCapabilities.FIREFOX |
| 183 | + capabilities["acceptSslCerts"] = True |
| 184 | + fp = webdriver.FirefoxProfile() |
| 185 | + fp.set_preference("webdriver.accept.untrusted.certs", True) |
| 186 | + fp.set_preference("security.enable_java", False) |
| 187 | + fp.set_preference("webdriver.load.strategy", "fast") |
| 188 | + if proxy is not None: |
| 189 | + proxyItems = proxy.split(":") |
| 190 | + fp.set_preference("network.proxy.socks", proxyItems[0]) |
| 191 | + fp.set_preference("network.proxy.socks_port", |
| 192 | + int(proxyItems[1])) |
| 193 | + fp.set_preference("network.proxy.type", 1) |
| 194 | + |
| 195 | + fireFoxOptions = webdriver.FirefoxOptions() |
| 196 | + |
| 197 | + if headless: |
207 | 198 | fireFoxOptions.set_headless() |
208 | | - browser = webdriver.Firefox(firefox_options=fireFoxOptions, capabilities=capabilities) |
209 | | - browser.set_window_size(1024, 768) |
| 199 | + |
| 200 | + browser = webdriver.Firefox(firefox_profile=fp, |
| 201 | + capabilities=capabilities, |
| 202 | + options=fireFoxOptions) |
| 203 | + browser.set_window_size(1024, 768) |
210 | 204 |
|
211 | 205 | except Exception as e: |
212 | 206 | print(e) |
@@ -339,61 +333,13 @@ def worker( |
339 | 333 | if smartFetch: |
340 | 334 | hash_basket[resp_hash] = screenshotName |
341 | 335 |
|
342 | | - # browser.set_window_size(1024, 768) |
343 | 336 | browser.set_page_load_timeout((tout)) |
344 | 337 | old_url = browser.current_url |
345 | 338 | browser.get(curUrl[0].strip()) |
346 | 339 | if browser.current_url == old_url: |
347 | 340 | print( |
348 | 341 | "[-] Error fetching in browser but successfully fetched with Requests: " |
349 | 342 | + curUrl[0]) |
350 | | - if headless: |
351 | | - browser2 = None |
352 | | - if debug: |
353 | | - print( |
354 | | - "[+] Trying with sslv3 instead of TLS - known phantomjs bug: " |
355 | | - + curUrl[0]) |
356 | | - if proxy is not None: |
357 | | - browser2 = webdriver.PhantomJS( |
358 | | - service_args=[ |
359 | | - "--ignore-ssl-errors=true", |
360 | | - "--proxy=" + proxy, |
361 | | - "--proxy-type=socks5", |
362 | | - ], |
363 | | - executable_path="phantomjs", |
364 | | - ) |
365 | | - else: |
366 | | - browser2 = webdriver.PhantomJS( |
367 | | - service_args=["--ignore-ssl-errors=true"], |
368 | | - executable_path="phantomjs", |
369 | | - ) |
370 | | - # print "Launched browser2: "+str(browser2.service.process.pid) |
371 | | - |
372 | | - old_url = browser2.current_url |
373 | | - try: |
374 | | - browser2.get(curUrl[0].strip()) |
375 | | - if browser2.current_url == old_url: |
376 | | - if debug: |
377 | | - print( |
378 | | - "[-] Didn't work with SSLv3 either..." |
379 | | - + curUrl[0]) |
380 | | - browser2.quit() |
381 | | - else: |
382 | | - print("[+] Saving: " + screenshotName) |
383 | | - html_source = browser2.page_source |
384 | | - f = open(screenshotName + ".html", "w") |
385 | | - f.write(html_source) |
386 | | - f.close() |
387 | | - browser2.save_screenshot(screenshotName + |
388 | | - ".png") |
389 | | - browser2.quit() |
390 | | - continue |
391 | | - except: |
392 | | - browser2.quit() |
393 | | - print( |
394 | | - "[-] Didn't work with SSLv3 either - exception..." |
395 | | - + curUrl[0]) |
396 | | - |
397 | 343 | if tryGUIOnFail and headless: |
398 | 344 | display = Display(visible=0, size=(1024, 768)) |
399 | 345 | display.start() |
|
0 commit comments