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
| from qiling import *
from qiling.os.mapper import QlFsMappedObject
from qiling.const import *
from qiling.os.const import STRING
flag = ''
class Fake_urandom(QlFsMappedObject):
def read(self, size):
return 0x48763.to_bytes(4, "little") # fixed value for reading /dev/urandom
def my_sleep(ql):
pass
def my_hook(ql: Qiling):
global flag
flag += chr(ql.reg.edx & 0xff)
if __name__ == "__main__":
ql = Qiling(["./crackme"], "../../rootfs/x8664_linux")
ql.add_fs_mapper("/dev/urandom", Fake_urandom())
ql.os.set_api('sleep', my_sleep, QL_INTERCEPT.CALL)
ql.hook_address(my_hook, 0x004015f4)
ql.run()
print(flag)
|