-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·100 lines (79 loc) · 2.57 KB
/
main.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
#!/usr/bin/env python3
import getopt
import os
import re
import sys
from requests.exceptions import MissingSchema
from bypass import WAFBypass
from table_out import table_payload_zone, table_status_count_accuracy
from urllib3 import connectionpool, poolmanager
def patch_http_connection_pool(**constructor_kwargs):
"""
This allows to override the default parameters of the
HTTPConnectionPool constructor.
For example, to increase the pool size to fix problems
with "HttpConnectionPool is full, discarding connection"
"""
class MyHTTPConnectionPool(connectionpool.HTTPConnectionPool):
def __init__(self, *args, **kwargs):
kwargs.update(constructor_kwargs)
super(MyHTTPConnectionPool, self).__init__(*args, **kwargs)
poolmanager.pool_classes_by_scheme['http'] = MyHTTPConnectionPool
class MyHTTPSConnectionPool(connectionpool.HTTPSConnectionPool):
def __init__(self, *args, **kwargs):
kwargs.update(constructor_kwargs)
super(MyHTTPSConnectionPool, self).__init__(*args, **kwargs)
poolmanager.pool_classes_by_scheme['https'] = MyHTTPSConnectionPool
# Increasing max pool size
patch_http_connection_pool(maxsize=50)
# Init args
host = ''
proxy = ''
# Processing args from cmd
try:
# read args from input
launch_args = sys.argv[1:]
# input to lowercase
for i in range(len(launch_args)):
launch_args[i] = launch_args[i].lower()
# options
launch_args_options = ['host=', 'proxy=']
# parsing args
optlist, values = getopt.getopt(launch_args, '', launch_args_options)
for k, v in optlist:
if k == '--host':
host = str(v)
# check host's schema
if not re.search(r'^http[s]?://', host):
host = 'http://' + host
elif k == '--proxy':
proxy = str(v)
except Exception as e:
print('An error occurred while processing the target/proxy: {}'.format(e))
sys.exit()
# check host
if not host:
print("ERROR: the host is not set. Syntax: main.py --host=example.com:80 --proxy='http://proxy.example.com:3128'")
sys.exit()
# create log. dir
try:
log_dir = '/tmp/waf-bypass-log/'
os.mkdir(log_dir)
except OSError:
pass
print('\n')
print('##')
print('# Target: ', host)
print('# Proxy: ', proxy)
print('##')
print('\n')
test = WAFBypass(host, proxy)
try:
test.start_test()
table_status_count_accuracy()
table_payload_zone()
except KeyboardInterrupt:
print('\nKeyboard Interrupt')
except MissingSchema:
print('The protocol is not set for TARGET or PROXY')
print("\n")