Skip to content

Commit d55f91c

Browse files
retrocpugeekclaude
andcommitted
Skip shellcode_run.py Windows stages when system DLLs are absent
The Windows shellcode stages need genuine Windows system DLLs, which are not redistributable and so are not shipped with Qiling; they must be collected from a licensed Windows host via examples/scripts/dllscollector.bat. Without them the loader failed to map ntdll.dll and the example crashed with an unhandled UC_ERR_READ_UNMAPPED traceback. Probe for ntdll.dll under each Windows rootfs and skip those stages with a message pointing at the collector script, so the example runs to completion on a stock checkout. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d206aed commit d55f91c

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

‎examples/shellcode_run.py‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
#
55

6+
import os
67
import sys
78

89
sys.path.append("..")
910
from qiling import Qiling
1011
from qiling.const import QL_ARCH, QL_OS, QL_VERBOSE
1112

13+
14+
def windows_rootfs_ready(rootfs: str) -> bool:
15+
# The Windows examples need genuine Windows system DLLs, which cannot be
16+
# redistributed and are therefore not shipped with Qiling. They must be
17+
# collected from a licensed Windows host using the helper script at
18+
# examples/scripts/dllscollector.bat. Probe for ntdll.dll so we can skip
19+
# these stages with a helpful message instead of crashing on an unmapped
20+
# read when the DLLs are absent.
21+
return os.path.isfile(os.path.join(rootfs, 'Windows', 'System32', 'ntdll.dll'))
22+
1223
X86_LIN = bytes.fromhex('31c050682f2f7368682f62696e89e3505389e1b00bcd80')
1324
X8664_LIN = bytes.fromhex('31c048bbd19d9691d08c97ff48f7db53545f995257545eb03b0f05')
1425

@@ -87,12 +98,20 @@
8798
ql.run()
8899

89100
print("\nWindows x86 Shellcode")
90-
ql = Qiling(code=X86_WIN, archtype=QL_ARCH.X86, ostype=QL_OS.WINDOWS, rootfs=r'rootfs/x86_windows')
91-
ql.run()
101+
if windows_rootfs_ready(r'rootfs/x86_windows'):
102+
ql = Qiling(code=X86_WIN, archtype=QL_ARCH.X86, ostype=QL_OS.WINDOWS, rootfs=r'rootfs/x86_windows')
103+
ql.run()
104+
else:
105+
print(" [skipped] Windows system DLLs not found under rootfs/x86_windows/Windows/System32.")
106+
print(" Collect them from a licensed Windows host with examples/scripts/dllscollector.bat.")
92107

93108
print("\nWindows x86-64 Shellcode")
94-
ql = Qiling(code=X8664_WIN, archtype=QL_ARCH.X8664, ostype=QL_OS.WINDOWS, rootfs=r'rootfs/x8664_windows')
95-
ql.run()
109+
if windows_rootfs_ready(r'rootfs/x8664_windows'):
110+
ql = Qiling(code=X8664_WIN, archtype=QL_ARCH.X8664, ostype=QL_OS.WINDOWS, rootfs=r'rootfs/x8664_windows')
111+
ql.run()
112+
else:
113+
print(" [skipped] Windows system DLLs not found under rootfs/x8664_windows/Windows/System32.")
114+
print(" Collect them from a licensed Windows host with examples/scripts/dllscollector.bat.")
96115

97116
# FIXME: freebsd sockets are currently broken.
98117
#

0 commit comments

Comments
 (0)