|
8 | 8 | <img width="150" height="150" src="https://raw.githubusercontent.com/qilingframework/qiling/master/docs/qiling2_logo_small.png"> |
9 | 9 | </p> |
10 | 10 |
|
| 11 | +[Qiling's usecase, blog and related work](https://github.com/qilingframework/qiling/issues/134) |
| 12 | + |
11 | 13 | Qiling is an advanced binary emulation framework, with the following features: |
12 | 14 |
|
13 | | -- Emulate multi-platforms: Windows, MacOS, Linux, BSD, UEFI, DOS, MBR, Ethereum Virtual Machine |
14 | | -- Emulate multi-architectures: X86, X86_64, Arm, Arm64, MIPS, 8086 |
| 15 | +- Emulate multi-platforms: Windows, MacOS, Linux, Android, BSD, UEFI, DOS, MBR, Ethereum Virtual Machine |
| 16 | +- Emulate multi-architectures: 8086, X86, X86_64, ARM, ARM64, MIPS, RISCV, PowerPC |
15 | 17 | - Support multiple file formats: PE, MachO, ELF, COM, MBR |
16 | 18 | - Support Windows Driver (.sys), Linux Kernel Module (.ko) & MacOS Kernel (.kext) via [Demigod](https://groundx.io/demigod/) |
17 | 19 | - Emulates & sandbox code in an isolated environment |
@@ -88,55 +90,55 @@ Please see [setup guide](https://docs.qiling.io/en/latest/install/) file for how |
88 | 90 |
|
89 | 91 | #### Examples |
90 | 92 |
|
91 | | -- Below example shows how to use Qiling framework to emulate a Windows EXE on a Linux machine |
| 93 | +- The example below shows how to use Qiling framework in the most striaghtforward way to emulate a Windows executable. |
92 | 94 |
|
93 | 95 | ```python |
94 | | -from qiling import * |
95 | | - |
96 | | -# sandbox to emulate the EXE |
97 | | -def my_sandbox(path, rootfs): |
98 | | - # setup Qiling engine |
99 | | - ql = Qiling(path, rootfs) |
100 | | - # now emulate the EXE |
101 | | - ql.run() |
| 96 | +from qiling import Qiling |
102 | 97 |
|
103 | 98 | if __name__ == "__main__": |
104 | | - # execute Windows EXE under our rootfs |
105 | | - my_sandbox(["examples/rootfs/x86_windows/bin/x86_hello.exe"], "examples/rootfs/x86_windows") |
| 99 | + # initialize Qiling instance, specifying the executable to emulate and the emulated system root. |
| 100 | + # note that the current working directory is assumed to be Qiling home |
| 101 | + ql = Qiling([r'examples/rootfs/x86_windows/bin/x86_hello.exe'], r'examples/rootfs/x86_windows') |
| 102 | + |
| 103 | + # start emulation |
| 104 | + ql.run() |
106 | 105 | ``` |
107 | 106 |
|
108 | | -- Below example shows how to use Qiling framework to dynamically patch a Windows crackme, make it always display "Congratulation" dialog |
| 107 | +- The following example shows how a Windows crackme may be patched dynamically to make it always display the "Congratulation" dialog. |
109 | 108 |
|
110 | 109 | ```python |
111 | | -from qiling import * |
| 110 | +from qiling import Qiling |
| 111 | + |
| 112 | +def force_call_dialog_func(ql: Qiling): |
| 113 | + # get DialogFunc address from current stack frame |
| 114 | + lpDialogFunc = ql.stack_read(-8) |
112 | 115 |
|
113 | | -def force_call_dialog_func(ql): |
114 | | - # get DialogFunc address |
115 | | - lpDialogFunc = ql.unpack32(ql.mem.read(ql.reg.esp - 0x8, 4)) |
116 | 116 | # setup stack memory for DialogFunc |
117 | 117 | ql.stack_push(0) |
118 | | - ql.stack_push(1001) |
119 | | - ql.stack_push(273) |
| 118 | + ql.stack_push(1001) # IDS_APPNAME |
| 119 | + ql.stack_push(0x111) # WM_COMMAND |
120 | 120 | ql.stack_push(0) |
| 121 | + |
| 122 | + # push return address |
121 | 123 | ql.stack_push(0x0401018) |
122 | | - # force EIP to DialogFunc |
123 | | - ql.reg.eip = lpDialogFunc |
| 124 | + |
| 125 | + # resume emulation from DialogFunc address |
| 126 | + ql.arch.regs.eip = lpDialogFunc |
124 | 127 |
|
125 | 128 |
|
126 | | -def my_sandbox(path, rootfs): |
127 | | - ql = Qiling(path, rootfs) |
| 129 | +if __name__ == "__main__": |
| 130 | + # initialize Qiling instance |
| 131 | + ql = Qiling([r'rootfs/x86_windows/bin/Easy_CrackMe.exe'], r'rootfs/x86_windows') |
| 132 | + |
128 | 133 | # NOP out some code |
129 | 134 | ql.patch(0x004010B5, b'\x90\x90') |
130 | 135 | ql.patch(0x004010CD, b'\x90\x90') |
131 | 136 | ql.patch(0x0040110B, b'\x90\x90') |
132 | 137 | ql.patch(0x00401112, b'\x90\x90') |
| 138 | + |
133 | 139 | # hook at an address with a callback |
134 | 140 | ql.hook_address(force_call_dialog_func, 0x00401016) |
135 | 141 | ql.run() |
136 | | - |
137 | | - |
138 | | -if __name__ == "__main__": |
139 | | - my_sandbox(["rootfs/x86_windows/bin/Easy_CrackMe.exe"], "rootfs/x86_windows") |
140 | 142 | ``` |
141 | 143 |
|
142 | 144 | The below Youtube video shows how the above example works. |
@@ -221,6 +223,7 @@ Contact us at email [email protected], or via Twitter [@qiling_io](https://twitter. |
221 | 223 |
|
222 | 224 | Please refer to [CREDITS.md](https://github.com/qilingframework/qiling/blob/dev/CREDITS.md) |
223 | 225 |
|
| 226 | + |
224 | 227 | --- |
225 | 228 |
|
226 | 229 | #### This is an awesome project! Can I donate? |
|
0 commit comments