forked from REW-sploit/REW-sploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply_patch.py
executable file
·54 lines (43 loc) · 1.34 KB
/
apply_patch.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
#!/usr/bin/env python
"""
Applies needed patches to the speakeasy-emulator
usage: apply_patch.py [-h] [-f] [-r]
optional arguments:
-h, --help show this help message and exit
-f, --force No prompts before applying
-r, --revert Revert patching
"""
import patch
import speakeasy
import os
import argparse
def apply_all(folder, revert):
#
# Files to patch: objman.py
#
destination = folder + '/windows/objman.py'
patchfile = 'patches/objman.diff'
try:
pset = patch.fromfile(patchfile)
if revert == True:
pset.revert(root=folder)
else:
pset.apply(root=folder)
print('OK: %s patched successfully' % (destination))
except:
print('KO: Error patching %s' % (destination))
if __name__ == '__main__':
ap = argparse.ArgumentParser()
ap.add_argument('-f', '--force', action='store_true', help='No prompts before applying',
default=False)
ap.add_argument('-r', '--revert', action='store_true', help='Revert patching',
default=False)
args = ap.parse_args()
location = speakeasy.__file__
folder = os.path.dirname(location)
print('You are going to apply patch to:')
print(folder)
if args.force == False:
input('Press ENTER to continue')
print()
apply_all(folder,args.revert)