qilingframework / qiling

A True Instrumentable Binary Emulation Framework
https://qiling.io
GNU General Public License v2.0
5.14k stars 744 forks source link

KeyError: 'x86' when running shellcode #1398

Closed lordtmk closed 1 year ago

lordtmk commented 1 year ago

*Describe the bug KeyError when specifying arch using library or qltool

Sample Code

ql = Qiling(code=data, rootfs=r'/Users/User/qiling/rootfs/x8664_windows', archtype='x86' , ostype='Windows', verbose=QL_VERBOSE.DEBUG)
ql.run()
...
Load BIN from FILE
Traceback (most recent call last):
  File "/home/lordtmk/.local/bin/qltool", line 266, in <module>
    ql = handle_code(options)
  File "/home/lordtmk/.local/bin/qltool", line 105, in handle_code
    ql = Qiling(
  File "/home/lordtmk/.local/lib/python3.10/site-packages/qiling/core.py", line 150, in __init__
    self._arch = select_arch(archtype, endian, thumb)(self)
  File "/home/lordtmk/.local/lib/python3.10/site-packages/qiling/utils.py", line 385, in select_arch
    module = {
KeyError: 'x86'

Expected behavior Correct architecture found and shellcode running

Screenshots If applicable, add screenshots to help explain your problem.

Additional context In utils.py :

module = {
        QL_ARCH.A8086    : r'x86',
        QL_ARCH.X86      : r'x86',
        QL_ARCH.X8664    : r'x86',
        QL_ARCH.ARM      : r'arm',
        QL_ARCH.ARM64    : r'arm64',
        QL_ARCH.MIPS     : r'mips',
        QL_ARCH.EVM      : r'evm.evm',
        QL_ARCH.CORTEX_M : r'cortex_m',
        QL_ARCH.RISCV    : r'riscv',
        QL_ARCH.RISCV64  : r'riscv64',
        QL_ARCH.PPC      : r'ppc'
    }[archtype]
elicn commented 1 year ago

archtype and ostype do not accept strings anymore; use QL_ARCH and QL_OS instead.

saber0x0 commented 3 months ago

ql = Qiling(code=shellcode, rootfs=r'/path/examples/rootfs/x8664_windows', archtype=QL_ARCH.X8664, ostype=QL_OS.WINDOWS, verbose=QL_VERBOSE.DEBUG)