-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdirwaf.py
141 lines (103 loc) Β· 4.61 KB
/
dirwaf.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
#!/usr/bin/env python3
# encoding:utf8
import requests
import random
from time import time
import optparse
import threadpool
__author__ = 'whois'
__date__ = '19/09/26'
__prog__ = "bypass waf with random ip"
__version__ = '2.0'
purp = '\033[95m'
blue = '\033[94m'
red = '\033[31m'
yellow = '\033[93m'
end = '\033[0m'
banner = red + """
ββββββ ββββββββββ βββ βββ ββββββ ββββββββ
ββββββββββββββββββββββ βββββββββββββββββββ
βββ βββββββββββββββββ ββ βββββββββββββββββ
βββ ββββββββββββββββββββββββββββββββββββββ
ββββββββββββββ ββββββββββββββββ ββββββ
βββββββ ββββββ βββ ββββββββ βββ ββββββ
""" + yellow + """
code by whois""" + end
with open('/Users/tianxia/DeathNote/Coder/Python/PySec/pytxt/user-agents.txt', 'r') as f:
agents_list = [ line.rstrip() for line in f.readlines()]
# δ½Ώη¨δ»£ηζ± θ·εip
# https://github.com/jhao104/proxy_pool
def get_proxy():
json = requests.get("http://118.24.52.95/get_all/").json()
for p in jsion:
print(p.get("proxy"))
def scan(web_file):
headers = {
'Upgrade-Insecure-Requests': '1',
'User-Agent': random.choice(agents_list),
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Accept-Encoding': 'gzip,deflate',
'Connection': 'close',
}
proxy_ip = random.choice(proxy_ip_list)
url = TARGET + '/' + web_file
try:
r = requests.get(url, headers=headers, timeout=12, proxies={"http":"http://{0}".format(proxy_ip)})
if r.status_code not in [404,400,500,501,502,503,504,505]:
print(red + "["+str(r.status_code)+"]" + "\t" + purp + str(len(r.content)) + "\t" + yellow + url + "\t" + blue + proxy_ip + end)
except Exception as e:
# print(e)
pass
def main():
global proxy_ip_list
global TARGET
parser = optparse.OptionParser(
usage="Usage: %prog [options]",
version="{0}: v{1} ({2})".format(__prog__, __version__, __author__),
epilog=yellow + """[Ex] python3 dirwaf.py -u http://1.1.1.1
[Ex] python3 dirwaf.py -u http://1.1.1.1 -t 10 -w w.txt -p proxy.txt""" + end,
)
parser.add_option("-u", "--url", dest="url",
help="Target url")
parser.add_option("-p", "--proxy", dest="proxy",
help="proxy ip list")
parser.add_option("-w", "--wordlist", dest="wordlist",
help="wordlist")
parser.add_option("-t", "--thread", dest="thread", type='int',
help="Specify threads default 12")
parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False,
help="verbose mode")
(options, args) = parser.parse_args()
if options.url == None:
print(banner)
parser.print_help()
exit(1)
THREAD = 8 if not options.thread else options.thread
WEBPATH = "/Users/tianxia/Pentest/PassList/Webpath/fuckyou.txt" if not options.wordlist else options.wordlist
IPFILES = "/Users/tianxia/DeathNote/Coder/Python/PySec/output/proxy_ip.txt" if not options.proxy else options.proxy
with open(IPFILES, 'r') as f:
proxy_ip_list = [ line.rstrip() for line in f.readlines() ]
TARGET = options.url
if 'http' not in TARGET:
print("[x] Perhaps you meant http://{0}".format(TARGET))
exit(1)
if options.verbose:
print("[+] Load webpath {0}".format(WEBPATH))
print("[+] Load proxy_ip_file {0}".format(IPFILES))
print("[+] Scan with {0} threads\n".format(THREAD))
with open(WEBPATH, 'r') as f:
lines = f.read().splitlines()
try:
time_start = time()
pool = threadpool.ThreadPool(THREAD)
requests = threadpool.makeRequests(scan, lines)
[pool.putRequest(req) for req in requests]
pool.wait()
time_end = time() - time_start
print(blue + "\nScan End Time is {0}\n".format(time_end))
except KeyboardInterrupt:
print(red + "[-] Ctrl+C")
exit(1)
if __name__ == '__main__':
main()