-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
44 lines (34 loc) · 1.33 KB
/
example.py
File metadata and controls
44 lines (34 loc) · 1.33 KB
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
"""
Example use to decode a string in this
strcpy(vStackString, "nAA:P<;n@XRFa=cXO;>@sxt?avd\x1DJX");
v28 = (char *)v62;
do
{
vStackString[index] = 0x14 - ((index ^ (vStackString[index] + 0x67)) - 4);
++index;
}
while ( index != 31 );
"""
from byteops import ByteOps
def decode():
vStackString = bytes([
0x6E, 0x41, 0x41, 0x3A, 0x50, 0x3C, 0x3B, 0x6E, 0x40, 0x58, 0x52, 0x46, 0x61, 0x3D, 0x63, 0x58,
0x4F, 0x3B, 0x3E, 0x40, 0x73, 0x78, 0x74, 0x3F, 0x61, 0x76, 0x64, 0x1D, 0x4A, 0x58, 0x00, 0x00
])
result = bytearray(20)
for index in range(31):
temp = bytes([vStackString[index]])
index_bytes = index.to_bytes(1, 'little')
# (vStackString[index] + 0x67)
add_result = ByteOps.add_byte(temp, bytes.fromhex("67"))
# (index ^ (vStackString[index] + 0x67))
xor_result = ByteOps.xor_byte(index_bytes, add_result)
# ((index ^ (vStackString[index] + 0x67)) - 4)
sub_result = ByteOps.sub_byte(xor_result, bytes.fromhex("04"))
# 0x14 - ((index ^ (vStackString[index] + 0x67)) - 4)
final_result = ByteOps.sub_byte(bytes.fromhex("14"), sub_result)
# first and also only byte to the result store
if index < 20:
result[index] = final_result[0]
print("".join(chr(i) for i in result))
decode()