|
1 | 1 | #!/usr/bin/env python3 |
2 | | -# |
| 2 | +# |
3 | 3 | # Cross Platform and Multi Architecture Advanced Binary Emulation Framework |
4 | 4 | # |
5 | 5 |
|
6 | | -import sys, curses, math, struct, string, time |
| 6 | +import curses |
| 7 | +import math |
| 8 | +import string |
| 9 | +import time |
| 10 | + |
| 11 | +from struct import pack |
| 12 | + |
| 13 | +import sys |
7 | 14 | sys.path.append("..") |
8 | | -from qiling import * |
| 15 | + |
| 16 | +from qiling import Qiling |
9 | 17 | from qiling.const import * |
10 | 18 | from qiling.os.disk import QlDisk |
11 | 19 | from qiling.os.dos.utils import BIN2BCD |
12 | | -from struct import pack |
13 | 20 |
|
14 | 21 |
|
15 | 22 | # https://stackoverflow.com/questions/9829578/fast-way-of-counting-non-zero-bits-in-positive-integer |
@@ -129,9 +136,7 @@ def show_once(ql: Qiling, key): |
129 | 136 | # In this stage, we show every key. |
130 | 137 | def third_stage(keys): |
131 | 138 | # To setup terminal again, we have to restart the whole program. |
132 | | - ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"], |
133 | | - "rootfs/8086", |
134 | | - console=False) |
| 139 | + ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"], "rootfs/8086", console=False) |
135 | 140 | ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.DOS_MBR", 0x80)) |
136 | 141 | ql.os.set_api((0x1a, 4), set_required_datetime, QL_INTERCEPT.EXIT) |
137 | 142 | hk = ql.hook_code(stop, begin=0x8018, end=0x8018) |
@@ -170,21 +175,22 @@ def read_until_zero(ql: Qiling, addr): |
170 | 175 | addr += 1 |
171 | 176 | return buf |
172 | 177 |
|
| 178 | + |
173 | 179 | def set_required_datetime(ql: Qiling): |
174 | 180 | ql.log.info("Setting Feburary 06, 1990") |
175 | 181 | ql.arch.regs.ch = BIN2BCD(19) |
176 | | - ql.arch.regs.cl = BIN2BCD(1990%100) |
| 182 | + ql.arch.regs.cl = BIN2BCD(1990 % 100) |
177 | 183 | ql.arch.regs.dh = BIN2BCD(2) |
178 | 184 | ql.arch.regs.dl = BIN2BCD(6) |
179 | 185 |
|
| 186 | + |
180 | 187 | def stop(ql, addr, data): |
181 | 188 | ql.emu_stop() |
182 | 189 |
|
| 190 | + |
183 | 191 | # In this stage, we get the encrypted data which xored with the specific date. |
184 | 192 | def first_stage(): |
185 | | - ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"], |
186 | | - "rootfs/8086", |
187 | | - console=False) |
| 193 | + ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"], "rootfs/8086", console=False) |
188 | 194 | ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.DOS_MBR", 0x80)) |
189 | 195 | # Doogie suggests that the datetime should be 1990-02-06. |
190 | 196 | ql.os.set_api((0x1a, 4), set_required_datetime, QL_INTERCEPT.EXIT) |
|
0 commit comments