MCPcopy Index your code
hub / github.com/RedSiege/EyeWitness / create_driver

Function create_driver

Python/modules/selenium_module.py:29–89  ·  view source on GitHub ↗

Creates a selenium FirefoxDriver Args: cli_parsed (ArgumentParser): Command Line Object user_agent (String, optional): Optional user-agent string Returns: FirefoxDriver: Selenium Firefox Webdriver

(cli_parsed, user_agent=None)

Source from the content-addressed store, hash-verified

27from modules.helpers import do_delay
28
29def create_driver(cli_parsed, user_agent=None):
30 """Creates a selenium FirefoxDriver
31
32 Args:
33 cli_parsed (ArgumentParser): Command Line Object
34 user_agent (String, optional): Optional user-agent string
35
36 Returns:
37 FirefoxDriver: Selenium Firefox Webdriver
38 """
39 profile = webdriver.FirefoxProfile()
40 # Load our custom firefox addon to handle basic auth.
41 extension_path = os.path.join(
42 os.path.dirname(os.path.realpath(__file__)),
43 '..', 'bin', 'dismissauth.xpi')
44 profile.add_extension(extension_path)
45 profile.accept_untrusted_certs = True
46
47 # This user agent case covers a user provided one
48 if cli_parsed.user_agent is not None:
49 profile.set_preference(
50 'general.useragent.override', cli_parsed.user_agent)
51
52 # This user agent case should only be hit when cycling
53 if user_agent is not None:
54 profile.set_preference('general.useragent.override', user_agent)
55
56 # Set up our proxy information directly in the firefox profile
57 if cli_parsed.proxy_ip is not None and cli_parsed.proxy_port is not None:
58 profile.set_preference('network.proxy.type', 1)
59 if "socks" in cli_parsed.proxy_type:
60 profile.set_preference('network.proxy.socks', cli_parsed.proxy_ip)
61 profile.set_preference('network.proxy.socks_port', cli_parsed.proxy_port)
62 else:
63 profile.set_preference('network.proxy.http', cli_parsed.proxy_ip)
64 profile.set_preference(
65 'network.proxy.http_port', cli_parsed.proxy_port)
66 profile.set_preference('network.proxy.ssl', cli_parsed.proxy_ip)
67 profile.set_preference('network.proxy.ssl_port', cli_parsed.proxy_port)
68
69 profile.set_preference('app.update.enabled', False)
70 profile.set_preference('browser.search.update', False)
71 profile.set_preference('extensions.update.enabled', False)
72
73 try:
74 capabilities = DesiredCapabilities.FIREFOX.copy()
75 capabilities.update({'acceptInsecureCerts': True})
76 options = Options()
77 options.add_argument("--headless")
78 profile.update_preferences()
79 driver = webdriver.Firefox(profile, capabilities=capabilities, options=options, service_log_path=cli_parsed.selenium_log_path)
80 driver.set_page_load_timeout(cli_parsed.timeout)
81 return driver
82 except Exception as e:
83 if 'Failed to find firefox binary' in str(e):
84 print('Firefox not found!')
85 print('You can fix this by installing Firefox/Iceweasel\
86 or using phantomjs/ghost')

Callers 3

single_modeFunction · 0.85
worker_threadFunction · 0.85
capture_hostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected