| 18 | |
| 19 | |
| 20 | def get_count(flag: Sequence[str]): |
| 21 | ql = Qiling(["../examples/rootfs/x86_windows/bin/crackme.exe"], "../examples/rootfs/x86_windows", verbose=QL_VERBOSE.OFF, libcache = True) |
| 22 | ql.os.stdin = pipe.SimpleStringBuffer() |
| 23 | ql.os.stdout = pipe.SimpleStringBuffer() |
| 24 | |
| 25 | count = [0] |
| 26 | ql.hook_code(instruction_count, count) |
| 27 | |
| 28 | ql.os.stdin.write(bytes("".join(flag) + "\n", 'utf-8')) |
| 29 | ql.run() |
| 30 | |
| 31 | print(ql.os.stdout.read().decode('utf-8'), end='') |
| 32 | print(f' ============ count: {count[0]:d} ============ ') |
| 33 | |
| 34 | return count[0] |
| 35 | |
| 36 | |
| 37 | def solve(): |