|
5 | 5 | from capstone import *
|
6 | 6 | from qiling.const import QL_VERBOSE
|
7 | 7 | from qiling.os.mapper import QlFsMappedObject
|
| 8 | +from qiling.extensions import trace |
8 | 9 |
|
9 | 10 |
|
10 | 11 | class Fake_Drive(QlFsMappedObject):
|
@@ -38,19 +39,17 @@ def stop(ql):
|
38 | 39 | ql.nprint("[+] Address found")
|
39 | 40 | ql.emu_stop()
|
40 | 41 |
|
41 |
| - def my_sandbox_nodebugger(path, rootfs = "examples/rootfs/x8664_windows"): |
42 |
| - ql = Qiling(path, r"" + rootfs, verbose=QL_VERBOSE.DEBUG) |
| 42 | + def my_sandbox_nodebugger(path, arch, rootfs = "examples/rootfs/x8664_windows"): |
| 43 | + ql = Qiling(path, r"" + rootfs, archtype=arch, ostype=QL_OS.WINDOWS, verbose=QL_VERBOSE.DEBUG) |
43 | 44 | ql.run()
|
44 | 45 |
|
45 |
| - def my_sandbox(path, rootfs = "examples/rootfs/x8664_windows", debugger = "gdb"): |
46 |
| - ql = Qiling(path, r"" + rootfs, verbose=QL_VERBOSE.DEBUG) |
| 46 | + def my_sandbox(path, arch, rootfs = "examples/rootfs/x8664_windows", debugger = "gdb"): |
| 47 | + ql = Qiling(path, r"" + rootfs, archtype=arch, ostype=QL_OS.WINDOWS, verbose=QL_VERBOSE.DEBUG) |
47 | 48 | ql.debugger = str(debugger)
|
48 |
| - ql.run(timeout=5000) |
49 | 49 |
|
50 | 50 | def shellcode_sandbox(path, shellcode, rtfs = "examples/rootfs/x8664_windows", debugger = "gdb"):
|
51 | 51 | ql = Qiling(shellcoder=shellcode, rootfs=r"" + rtfs, verbose=QL_VERBOSE.DEBUG)
|
52 | 52 | ql.debugger = str(debugger)
|
53 |
| - ql.run(timeout=5000) |
54 | 53 |
|
55 | 54 | def stopatkillerswtich(ql: Qiling):
|
56 | 55 | print("WannaCry Detected!")
|
@@ -90,26 +89,26 @@ def sandbox_analyze(exeloc, debugger):
|
90 | 89 | os.mkdir("examples/rootfs/x8664_windows/bin")
|
91 | 90 |
|
92 | 91 | shutil.copyfile("exefiles/" + exeloc, "examples/rootfs/x8664_windows/bin/" + exeloc)
|
93 |
| - QilingSandBox_Windows_x86_64.my_sandbox_nodebugger(["examples/rootfs/x8664_windows/bin/" + exeloc], "examples/rootfs/x8664_windows") |
| 92 | + QilingSandBox_Windows_x86_64.my_sandbox_nodebugger(["examples/rootfs/x8664_windows/bin/" + exeloc], QL_ARCH.X8664, "examples/rootfs/x8664_windows") |
94 | 93 | else:
|
95 | 94 | # Create folder if was not created
|
96 | 95 | if os.path.exists("examples/rootfs/x86_windows/bin") is False:
|
97 | 96 | os.mkdir("examples/rootfs/x86_windows/bin")
|
98 | 97 |
|
99 | 98 | shutil.copyfile("exefiles/" + exeloc, "examples/rootfs/x86_windows/bin/" + exeloc)
|
100 |
| - QilingSandBox_Windows_x86_64.my_sandbox_nodebugger(["examples/rootfs/x86_windows/bin/" + exeloc], "examples/rootfs/x86_windows") |
| 99 | + QilingSandBox_Windows_x86_64.my_sandbox_nodebugger(["examples/rootfs/x86_windows/bin/" + exeloc], QL_ARCH.X86, "examples/rootfs/x86_windows") |
101 | 100 | else:
|
102 | 101 | if(arch == "64"):
|
103 | 102 | # Create folder if was not created
|
104 | 103 | if os.path.exists("examples/rootfs/x8664_windows/bin") is False:
|
105 | 104 | os.mkdir("examples/rootfs/x8664_windows/bin")
|
106 | 105 |
|
107 | 106 | shutil.copyfile("exefiles/" + exeloc, "examples/rootfs/x8664_windows/bin/" + exeloc)
|
108 |
| - QilingSandBox_Windows_x86_64.my_sandbox(["examples/rootfs/x8664_windows/bin/" + exeloc], "examples/rootfs/x8664_windows", debugger) |
| 107 | + QilingSandBox_Windows_x86_64.my_sandbox(["examples/rootfs/x8664_windows/bin/" + exeloc], QL_ARCH.X8664, "examples/rootfs/x8664_windows", debugger) |
109 | 108 | else:
|
110 | 109 | # Create folder if was not created
|
111 | 110 | if os.path.exists("examples/rootfs/x86_windows/bin") is False:
|
112 | 111 | os.mkdir("examples/rootfs/x86_windows/bin")
|
113 | 112 |
|
114 | 113 | shutil.copyfile("exefiles/" + exeloc, "examples/rootfs/x86_windows/bin/" + exeloc)
|
115 |
| - QilingSandBox_Windows_x86_64.my_sandbox(["examples/rootfs/x86_windows/bin/" + exeloc], "examples/rootfs/x86_windows", debugger) |
| 114 | + QilingSandBox_Windows_x86_64.my_sandbox(["examples/rootfs/x86_windows/bin/" + exeloc], QL_ARCH.X86, "examples/rootfs/x86_windows", debugger) |
0 commit comments