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

Function capture_host

Python/modules/selenium_module.py:92–299  ·  view source on GitHub ↗

Screenshots a single host, saves information, and returns a complete HTTP Object Args: cli_parsed (ArgumentParser): Command Line Object http_object (HTTPTableObject): Object containing data relating to current URL driver (FirefoxDriver): webdriver instance ua

(cli_parsed, http_object, driver, ua=None)

Source from the content-addressed store, hash-verified

90
91
92def capture_host(cli_parsed, http_object, driver, ua=None):
93 """Screenshots a single host, saves information, and returns
94 a complete HTTP Object
95
96 Args:
97 cli_parsed (ArgumentParser): Command Line Object
98 http_object (HTTPTableObject): Object containing data relating to current URL
99 driver (FirefoxDriver): webdriver instance
100 ua (String, optional): Optional user agent string
101
102 Returns:
103 HTTPTableObject: Complete http_object
104 """
105
106 # Attempt to take the screenshot
107 try:
108 # If cookie is presented we need to avoid cookie-averse error. To do so, we need to get the page twice.
109 driver.get(http_object.remote_system)
110 if cli_parsed.cookies is not None:
111 for cookie in cli_parsed.cookies:
112 driver.add_cookie(cookie)
113 driver.get(http_object.remote_system)
114 except KeyboardInterrupt:
115 print('[*] Skipping: {0}'.format(http_object.remote_system))
116 http_object.error_state = 'Skipped'
117 http_object.page_title = 'Page Skipped by User'
118 except TimeoutException:
119 print('[*] Hit timeout limit when connecting to {0}, retrying'.format(http_object.remote_system))
120 driver.quit()
121 driver = create_driver(cli_parsed, ua)
122 http_object.error_state = 'Timeout'
123 except http.client.BadStatusLine:
124 print('[*] Bad status line when connecting to {0}'.format(http_object.remote_system))
125 http_object.error_state = 'BadStatus'
126 return http_object, driver
127 except WebDriverException:
128 print('[*] WebDriverError when connecting to {0}'.format(http_object.remote_system))
129 http_object.error_state = 'BadStatus'
130 return http_object, driver
131
132 # Dismiss any alerts present on the page
133 # Will not work for basic auth dialogs!
134 try:
135 alert = driver.switch_to.alert
136 alert.dismiss()
137 except Exception as e:
138 pass
139
140 # If we hit a timeout earlier, retry once
141 if http_object.error_state == 'Timeout':
142 retry_counter = 0
143 return_status = False
144 while retry_counter < cli_parsed.max_retries:
145 http_object.error_state = None
146 try:
147 driver.get(http_object.remote_system)
148 if cli_parsed.cookies is not None:
149 for cookie in cli_parsed.cookies:

Callers 2

single_modeFunction · 0.85
worker_threadFunction · 0.85

Calls 2

do_delayFunction · 0.90
create_driverFunction · 0.85

Tested by

no test coverage detected