forked from F8LEFT/DecLLVM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
360Shell.py
70 lines (57 loc) · 1.68 KB
/
360Shell.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
__author__ = 'F8LEFT'
from dbgEngine import *
from regHelper import ArmReg
# '''
from idaapi import *
from idautils import *
from idc import *
# '''
# from python import *
# for 360 encrypt
# for arm
# shell
# STMFD SP!, {R0}
# ADRL R0, sub_7551FA34 ; next address
# SUB R0, R0, #4
# BX R0 ; loc_7551FA3
# LDMFD SP!, {R0}
class S360Shell(InstructionHelp):
def __init__(self):
InstructionHelp.__init__(self)
def __del__(self):
InstructionHelp.__del__(self)
def get_next_instruction(self, regObj):
StepOver()
GetDebuggerEvent(WFNE_SUSP, -1)
regObj.dumpReg()
isVm, addr = self.isVMStart(regObj)
if isVm:
return addr
else:
return 0
# STMFD SP!, {R0}
# ADRL R0, sub_7551FA34 ; next address
# SUB R0, R0, #4
# BX R0 ; loc_7551FA3#
def isVMStart(self, regObj):
insAddr1 = regObj.insAddr
disAsm1 = GetDisasmEx(insAddr1, GENDSM_FORCE_CODE)
if disAsm1 == "STMFD SP!, {R0}":
insAddr2 = insAddr1 + ItemSize(insAddr1)
disAsm2 = GetDisasmEx(insAddr2, GENDSM_FORCE_CODE)
if disAsm2.find("ADRL R0") > -1:
nextAddr = LocByName(GetOpnd(insAddr2, 1))
return True, nextAddr
return False, 0
if __name__ == "__main__":
print("============360LLVMStart=================")
ins = S360Shell()
reg = ArmReg()
dbgEng = DbgEngine(reg, ins)
fd = open("F:/trace.log", "w+")
dbgEng.start_run(GetRegValue("PC"), 50, fd)
fd.close()
del dbgEng
del reg
del ins
print("============360LLVMEnd=================")