-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathops.py
executable file
·190 lines (174 loc) · 6.02 KB
/
ops.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
from colorama import Fore, Back, Style
import optparse
import os
import requests
def banner():
print(
Fore.BLUE,
"""
______________________
__ __ \__ __ \_ ___/
_ / / /_ /_/ /____ \\
/ /_/ /_ ____/____/ /
\____/ /_/ /____/
[ 0UR4N05 ([email protected]) ]
v 1.0
""",
)
print(Style.RESET_ALL)
parse()
def parse():
usage = "Usage: python3 ops.py -u [url] -w [wordlist]\n\n\nExamples:\npython3 ops.py -u \"http://example.com/index.php?token=junk&redirection=<url>&token=junk\" \npython3 ops.py -u http://example.com/ -w /usr/share/wordlists/word.txt -q \npython3 ops.py -u http://example.com/ -t 1 -c {'enwiki_session': '17ab96bd8ffbe8ca58a78657a918558'}\n\n"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-a", "--agent", dest="user_agent", help="User agent")
parser.add_option(
"-q",
"--quiet",
dest="quiet",
help="Only show vulnerable links",
action="store_true",
)
parser.add_option(
"-u",
"--url",
dest="url",
help="Target URL (if your link have parameters add a '<url>' to the vulnerable parameter",
)
parser.add_option(
"-t",
"--timeout",
dest="timeout",
help="Time out of waiting to a response(default is 4s)",
default=4,
)
parser.add_option(
"-w",
"--wordlist",
dest="wordlist",
help="Custom payloads wordlist (optional)",
default="./payloads/big_w.txt",
)
(options, args) = parser.parse_args()
global user_agent
global timeout
global quiet
url = options.url
user_agent = options.user_agent
wordlist = options.wordlist
if options.url is None:
parser.print_help()
exit()
timeout = int(options.timeout)
quiet = options.quiet
checking(url, wordlist)
# check the link
def checking(urlp, wordlistp):
if "http" or "https" in urlp:
print("[+]-Creating the wordlist")
wordlist(urlp, wordlistp)
else:
print("[!]-Url is not correct , please read the documentation")
exit()
def wordlist(urlw, wordlistp):
payloads = open(wordlistp, "r")
wordlist = open("./wordlists/wordlist.txt", "a+")
if "?" and "=" and "<url>" in urlw:
print("[+]-Parameters detected")
for line in payloads:
line = line.strip(" \n\t")
url = urlw.replace("<url>", line) + "\n"
wordlist.writelines(url)
payloads.close()
else:
print("testing")
for line in payloads:
wordlist_elements = urlw + line
wordlist.writelines(wordlist_elements)
payloads.close()
print("[+]-Wordlist done")
wordlist.close()
scan()
def scan():
print("[/]-Scan started")
wordlist_l = open("./wordlists/wordlist.txt", "r")
succesive_301_counter = 0
for line in wordlist_l:
r = requests.get(
line,
timeout=timeout,
allow_redirects=False,
headers={"User-Agent": user_agent},
)
status_code = str(r.status_code)
if quiet:
if r.status_code == 302:
res = "[" + status_code + "]--" + line
print(Fore.GREEN, res)
print(Style.RESET_ALL)
elif r.status_code == 301:
succesive_301_counter = succesive_301_counter + 1
if succesive_301_counter >= 20:
print(
"[+]-There is a lot of succesive 301 counter that can be just normal site redirections, please can you check the result or submit the official url"
)
choise = input("Continue? [y/n] : ")
if choise == "y":
continue
elif choise == "n":
exit()
else:
choise = input("Continue? [y/n] : ")
res = "[" + status_code + "]--" + line
print(Fore.YELLOW, res)
print(Style.RESET_ALL)
else:
if r.status_code == 302:
res = "[" + status_code + "]--" + line
print(Fore.GREEN, res, end=" ")
print(Style.RESET_ALL)
elif r.status_code == 301:
succesive_301_counter = succesive_301_counter + 1
if succesive_301_counter >= 20:
print(
"[+]-There is a lot of succesive 301 counter that can be just normal site redirections, please can you check the result or submit the official url"
)
choise = input("Continue? [y/n] : ")
if choise == "y":
continue
elif choise == "n":
exit()
else:
choise = input("Continue? [y/n] : ")
res = "[" + status_code + "]--" + line
print(Fore.YELLOW, res, end=" ")
print(Style.RESET_ALL)
else:
res = "[" + status_code + "]--" + line
print(Fore.RED, res, end=" ")
print(Style.RESET_ALL)
print(
"Colors meanings :\n",
Fore.GREEN,
"Green : Confirmed redirection\n",
Fore.YELLOW,
"Yellow : Suspecious redirection\n",
Fore.RED,
"Red : Not a redirection\n note: Please make sure to test the open redirect vulnerabilities before submitting them",
)
print(Style.RESET_ALL)
choise = input(
"\n[+]-Scan finished , wanna delete the generated wordlist? [y/n] : "
)
if choise == "n":
print(Fore.YELLOW, "[+]-Okey , BYE ")
exit()
elif choise == "y":
print(Fore.YELLOW, "[+]-Done")
os.remove("./wordlists/wordlist.txt")
else:
exit()
try:
banner()
except KeyboardInterrupt:
print(Fore.YELLOW, "\n[*]-OKEY ,BYEE")
os.remove("./wordlists/wordlist.txt")