# sandbox to emulate the EXE defmy_sandbox(path, rootfs): # setup Qiling engine ql = Qiling(path, rootfs) # now emulate the EXE ql.run()
if __name__ == "__main__": # execute Windows EXE under our rootfs my_sandbox(["examples\\rootfs\\x86_windows\\bin\\x86_hello.exe"], "examples/rootfs/x86_windows")
defforce_call_dialog_func(ql): # get DialogFunc address lpDialogFunc = ql.unpack32(ql.mem.read(ql.reg.esp - 0x8, 4)) # setup stack memory for DialogFunc ql.stack_push(0) ql.stack_push(1001) ql.stack_push(273) ql.stack_push(0) ql.stack_push(0x0401018) # force EIP to DialogFunc ql.reg.eip = lpDialogFunc
defmy_sandbox(path, rootfs): ql = Qiling(path, rootfs) # NOP out some code ql.patch(0x004010B5, b'\x90\x90') ql.patch(0x004010CD, b'\x90\x90') ql.patch(0x0040110B, b'\x90\x90') ql.patch(0x00401112, b'\x90\x90') # hook at an address with a callback ql.hook_address(force_call_dialog_func, 0x00401016) ql.run()
if __name__ == "__main__": my_sandbox(["rootfs/x86_windows/bin/Easy_CrackMe.exe"], "rootfs/x86_windows")