-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcmdline.py
89 lines (76 loc) · 2.84 KB
/
cmdline.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
import argparse, shlex
"""
see mitmproxy/libmproxy/cmdline
we remove all unwanted parameters and add everything we need for HoneyProxy
"""
def suppress_option(parser, options):
if(type(options) == str):
options = [options]
for option in options:
for action in parser._actions:
if(option in action.option_strings):
action.help = argparse.SUPPRESS
return
print "Warning: Command line switch "+str(option)+" doesn't exist. Your version of mitmproxy might be incompatible."
def convert_arg_line_to_args(self, arg_line):
if arg_line.lstrip().startswith("#"):
return
for arg in shlex.split(arg_line):
if not arg.strip():
continue
yield arg
def suppress_group(parser, option):
for action_group in parser._action_groups:
if(option == action_group.title):
action_group.title = action_group.description = argparse.SUPPRESS
return
print "Warning: Command line group "+str(option)+" doesn't exist. Your version of mitmproxy might be incompatible."
def allow_overwrite(parser, option):
for action in parser._actions:
if(option in action.option_strings):
action.container.conflict_handler = "resolve"
def fix_options(parser):
'''Fix mitmproxy proxy options - we don't want all features to be present in HoneyProxy'''
parser.add_argument(
"--dump-dir",
action="store", type = str, dest="dumpdir", default=None,
help = "Folder to dump all response objects into"
)
parser.add_argument(
"--apiport",
action="store", type = int, dest="apiport", default=8082,
help = "WebSocket API service port."
)
parser.add_argument(
"--guiport",
action="store", type = int, dest="guiport", default=8081,
help = "GUI service port."
)
parser.add_argument(
"--api-auth",
action="store", type = str, dest="apiauth", default=None,
help = "API auth key / shared secret. Use NO_AUTH to disable authentication"
)
parser.add_argument(
"--no-gui",
action="store_true", dest="nogui",
help="Don't open GUI in browser"
)
parser.add_argument(
"--readonly",
action="store_true", dest="readonly",
help="Don't allow clients to modify files on disk (e.g. report scripts)"
)
suppress_option(parser,"-e")
suppress_option(parser,"-q")
suppress_option(parser,"-v")
#client replay
suppress_group(parser,"Client Replay")
suppress_option(parser,"-c")
#server replay
suppress_group(parser,"Server Replay")
suppress_option(parser,"-S")
suppress_option(parser,"-k")
suppress_option(parser,"--rheader")
suppress_option(parser,"--norefresh")
suppress_option(parser,"--no-pop")