-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathSwizzler2.py
131 lines (91 loc) · 2.74 KB
/
Swizzler2.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
#!/usr/bin/python
import imp
modules = ['os', 'readline', 'cmd']
for module in modules:
try:
imp.find_module(module)
except ImportError:
do_something()
from cmd import Cmd
import os
def read_entirely(file):
with open(file, 'r') as handle:
return handle.read()
class MyPrompt(Cmd, object):
def preloop(self):
print ' _____ _ __ ___ '
print ' / ___/ __(_)_______ / /__ ____|__ \\'
print ' \__ \ | /| / / /_ /_ / / / _ \/ ___/_/ /'
print ' ___/ / |/ |/ / / / /_/ /_/ / __/ / / __/ '
print '/____/|__/|__/_/ /___/___/_/\___/_/ /____/ '
print '\n'
print 'List of Available Hooks'
print '\n'.join(self.AVAILABLE_HOOKS)
super(MyPrompt, self).preloop()
def do_q(self, args):
"""Quits the program."""
print "Quitting."
os.remove('Swizzler2.js')
raise SystemExit
def do_quit(self, args):
"""Quits the program."""
print "Quitting."
os.remove('Swizzler2.js')
raise SystemExit
HOOKS = []
AVAILABLE_HOOKS = ['CommonCrypto', 'NSURL', 'SSLKillSwitch','LocalAuthenticator']
HOOK_DICT = {
'CommonCrypto': 'C.CommonCrypto.js',
'NSURL': 'Foundation.NSURL.js',
'SSLKillSwitch': 'SSLKillSwitch.js',
'LocalAuthenticator': 'LocalAuthentication.LAContext.js'
}
def do_hook(self, args):
"""Enables a hook. hook [function]"""
print "Hooking " + args + " ..."
self.HOOKS.append(args)
result = '\n'.join(read_entirely(self.HOOK_DICT[file]) for file in self.HOOKS)
with open('Swizzler2.js', 'w') as handle:
handle.write(result)
print "\nHooks Active: " + ', '.join(self.HOOKS)
def do_unhook(self, args):
"""Disables a hook. unhook [function]"""
print "Unhooking " + args + " ..."
self.HOOKS.remove(args)
result = '\n'.join(read_entirely(self.HOOK_DICT[file]) for file in self.HOOKS)
with open('Swizzler2.js', 'w') as handle:
handle.write(result)
print "\nHooks Active: " + ', '.join(self.HOOKS)
def complete_hook(self, text, line, begidx, endidx):
if not text:
completions = self.AVAILABLE_HOOKS[:]
else:
completions = [ f
for f in self.AVAILABLE_HOOKS
if f.startswith(text)
]
return completions
def complete_unhook(self, text, line, begidx, endidx):
if not text:
completions = self.AVAILABLE_HOOKS[:]
else:
completions = [ f
for f in self.AVAILABLE_HOOKS
if f.startswith(text)
]
return completions
def do_list(self, args):
"""List available or active hooks."""
args = args.split()
if len(args) != 2:
print "list hooks available"
print "list hooks active"
return
if args[1] == 'available':
print '\n'.join(self.AVAILABLE_HOOKS)
if args[1] == 'active':
print '\n'.join(self.HOOKS)
if __name__ == '__main__':
prompt = MyPrompt()
prompt.prompt = '# '
prompt.cmdloop()