-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrivIntruder.py
58 lines (51 loc) · 1.92 KB
/
PrivIntruder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
import sys
from termcolor import colored
def run(action, cookie):
accessed_urls=[]
denied_urls=[]
risk_list=["admin", "database", "config","bin"]
risk_flag=False
with open('urls.txt', 'r') as urls:
for url in urls:
risk_color = "white"
if (action == 0):
response = requests.get(url.strip())
else:
response = requests.get(url.strip(), cookies=cookie)
if(len(response.history)>0):
response.status_code=response.history[0].status_code
if response.status_code == 200:
color="green"
if any (w in url.strip() for w in risk_list):
risk_factor = True;
risk_color="red"
accessed_urls.append(url.strip())
elif (response.status_code == 401 or response.status_code == 403):
color="red"
denied_urls.append(url.strip())
else:
color="white"
print colored(url.strip(), risk_color) + ' =>> ' + colored(str(response.status_code),color)
answer= raw_input ('[-] ==== Accessed '+ str(len(accessed_urls))+' urls, would you like to save results? (Y/N) === [-]\n')
if (answer.lower() == 'y'):
output_file=raw_input('[-] === Enter Output Filename === [-]\n')
with open(output_file, 'w') as o:
for u in accessed_urls:
o.write(url)
else:
sys.exit()
if(len(sys.argv)<2):
option='0'
else:
option = sys.argv[1]
if (option == '0'):
print '[+] ==== Running without cookies ====\n'
run(0, '')
elif (option == '1'):
print '[+] ==== Running with cookies enabled ====\n'
cookie = {}
cookie_name = raw_input('[-] Enter Cookie Name\n')
cookie_value = raw_input('[-] Enter Cookie Value\n')
cookie[cookie_name] = cookie_value;
run(1,cookie) #run with cookies