-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmitmoxy.py
executable file
·74 lines (52 loc) · 1.44 KB
/
mitmoxy.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
#!/bin/env python3
import sys
import json
import mitmoxy
from mitmoxy.controllers.controller import Controller
from mitmoxy.utils.functions import get_conf
helpers = """
Bitoxy {version} -- Proxy Server
Developed by {author}
Usage: {name} start|version|help [option]
Arguments:
start
starting a proxy server.
version
get the version of Bitoxy.
help
show this helps.
Examples:
{name} start
"""
helpers = helpers.format(name=sys.argv[0], version=mitmoxy.__version__, author=mitmoxy.__author__)
# function to show help
def show_help():
print(helpers)
sys.exit(0)
# function to show Bitoxy version
def show_version():
print('Bitoxy {version} - Proxy server - Developed by {author}'.
format(version=mitmoxy.__version__, author=mitmoxy.__author__))
sys.exit(0)
# function to execute controller
def exec_controller():
# get server configurations
conf_server = get_conf('conf/server.json')
# init controller and execute it
ctrl = Controller(command, conf_server)
ctrl.execute()
# main function
if __name__ == '__main__':
if len(sys.argv) < 2:
print('[!!] Bitoxy need a argument')
print(helpers)
sys.exit(-1)
command = sys.argv[1]
# switcher to show help or version
# to default execute controller
switcher = {
'help': show_help,
'version': show_version
}
exc = switcher.get(command, exec_controller)
exc()