Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions lib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,35 @@ def get_request(url, config):
anything else
If a RequestException occurs, then we will return an empty html response body. This will cancel the root detection.
"""
try:
response = {}
if config['auth']:
r = requests.get(url, timeout=config['timeout'], headers=config['headers'], auth=(config['auth'][0], config['auth'][1]), verify=False)
else:
r = requests.get(url, timeout=config['timeout'], headers=config['headers'], cookies=config['cookies'], verify=False)
response['status_code'] = r.status_code
response['html'] = r.text
response['headers'] = r.headers
response['cookies'] = r.cookies
response['url'] = r.url
return response
except requests.exceptions.Timeout as e:
print(e)
print(Fore.RED + '[x] Connection error\n Please make sure you provided the right URL\n' + Fore.RESET)
exit(-1)
except requests.exceptions.RequestException as e:
print(Fore.RED + str(e) + Fore.RESET)
# Return an empty response['html'] element.
# If this error occurs within the first request made (TYPO3 detection), then all following scans will be canceled
response['html'] = ''
return response
for retry in range(1,4):
try:
response = {}
if config['auth']:
r = requests.get(url, timeout=config['timeout'], headers=config['headers'], auth=(config['auth'][0], config['auth'][1]), verify=False)
else:
r = requests.get(url, timeout=config['timeout'], headers=config['headers'], cookies=config['cookies'], verify=False)
response['status_code'] = r.status_code
response['html'] = r.text
response['headers'] = r.headers
response['cookies'] = r.cookies
response['url'] = r.url
return response
except requests.exceptions.Timeout as e:
print(e)
print(Fore.RED + '[x] Connection error\n Please make sure you provided the right URL\n' + Fore.RESET)
if retry != 3:
continue
else:
exit(-1)
except requests.exceptions.RequestException as e:
print(Fore.RED + str(e) + Fore.RESET)
# Return an empty response['html'] element.
# If this error occurs within the first request made (TYPO3 detection), then all following scans will be canceled
response['html'] = ''
if retry != 3:
continue
else:
return response

def head_request(url, config):
"""
Expand Down