forked from qilingframework/qiling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dos.py
38 lines (27 loc) · 984 Bytes
/
test_dos.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
#!/usr/bin/env python3
#
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
#
import sys, unittest
sys.path.append('..')
from qiling import Qiling
from qiling.const import QL_INTERCEPT, QL_VERBOSE
class Checklist:
def __init__(self) -> None:
self.visited_onenter = False
self.visited_onexit = False
class DOSTest(unittest.TestCase):
def test_dos_8086_hello(self):
ql = Qiling(["../examples/rootfs/8086/dos/HI.DOS_COM"], "../examples/rootfs/8086/dos", verbose=QL_VERBOSE.DEBUG)
ck = Checklist()
def onenter(ql: Qiling):
ck.visited_onenter = True
def onexit(ql: Qiling):
ck.visited_onexit = True
ql.set_api((0x21, 0x09), onexit, QL_INTERCEPT.EXIT)
ql.set_api((0x21, 0x4c), onenter, QL_INTERCEPT.ENTER)
ql.run()
self.assertTrue(ck.visited_onenter)
self.assertTrue(ck.visited_onexit)
if __name__ == "__main__":
unittest.main()