-
Notifications
You must be signed in to change notification settings - Fork 0
/
Injector.py
53 lines (42 loc) · 1.53 KB
/
Injector.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
import PIL.Image
import io
class Injector:
@staticmethod
def HideString(injectionPath, text):
with open(path, "ab") as f:
f.write(str.encode(text))
@staticmethod
def GetString(injectionPath):
with open(path, "rb") as f:
content = f.read()
offset = content.index(bytes.fromhex('FFD9'))
f.seek(offset + 2)
text = f.read().decode('utf-8')
return text
@staticmethod
def HidePhoto(pngPath, injectionPath):
img = PIL.Image.open(targetPath)
byte_arr = io.BytesIO()
img.save(byte_arr, format='PNG')
with open(injectionPath, 'ab') as f:
f.write(byte_arr.getvalue())
@staticmethod
def GetPhoto(injectionPath, savePath):
with open(injectionPath, "rb") as f:
content = f.read()
offset = content.index(bytes.fromhex('FFD9'))
f.seek(offset + 2)
new_img = PIL.Image.open(io.BytesIO(f.read()))
new_img.save(savePath)
@staticmethod
def HideExe(targetExePath, injectionPath):
with open(injectionPath, 'ab') as f, open(targetExePath, 'rb') as e:
f.write(e.read())
@staticmethod
def GetExe(injectionPath, savePath):
with open(injectionPath, 'rb') as f:
content = f.read()
offset = content.index(bytes.fromhex('FFD9'))
f.seek(offset + 2)
with open(savePath, 'wb') as e:
e.write(f.read())