GithubHelp home page GithubHelp logo

justfoxing / qiling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qilingframework/qiling

1.0 1.0 0.0 48.65 MB

Qiling Advanced Binary Emulation Framework

Home Page: https://qiling.io

License: GNU General Public License v2.0

Python 99.58% Dockerfile 0.03% Shell 0.03% CodeQL 0.34% Batchfile 0.02%

qiling's Introduction

Pypi Gitter Build Status Docker Image CI

Qiling is an advanced binary emulation framework, with the following features:

  • Cross platform: Windows, MacOS, Linux, BSD, UEFI, DOS
  • Cross architecture: X86, X86_64, Arm, Arm64, MIPS, 8086
  • Multiple file formats: PE, MachO, ELF, COM, MBR
  • Emulates & sandbox machine code in an isolated environment
  • Provides a fully configurable sandbox
  • Provides in-dept memory, register, OS level and filesystem level API
  • Fine-grain instrumentation: allows hooks at various levels (instruction/basic-block/memory-access/exception/syscall/IO/etc)
  • Provides virtual machine level API such as save and restore current execution state.
  • Supports cross architecture and platform debugging capabilities
  • Built-in debugger with reverse debugging capability
  • Allows dynamic hotpatch on-the-fly running code, including the loaded library
  • True framework in Python, making it easy to build customized security analysis tools on top

Qiling is backed by Unicorn engine.

Visit our website https://www.qiling.io for more information.


Appearance

  • 2020:

    • Black Hat, USA
    • Black Hat, Asia
    • Hack In The Box, Lockdown 001
    • Hack In The Box, Lockdown 002
    • Nullcon
  • 2019:

    • Defcon, USA
    • Hitcon
    • Zeronights

License

This project is released and distributed under free software license GPLv2.


Qiling vs other Emulators

There are many open source emulators, but two projects closest to Qiling are Unicorn & Qemu usermode. This section explains the main differences of Qiling against them.

Qiling vs Unicorn engine

Built on top of Unicorn, but Qiling & Unicorn are two different animals.

  • Unicorn is just a CPU emulator, so it focuses on emulating CPU instructions, that can understand emulator memory. Beyond that, Unicorn is not aware of higher level concepts, such as dynamic libraries, system calls, I/O handling or executable formats like PE, MachO or ELF. As a result, Unicorn can only emulate raw machine instructions, without Operating System (OS) context.
  • Qiling is designed as a higher level framework, that leverages Unicorn to emulate CPU instructions, but can understand OS: it has executable format loaders (for PE, MachO & ELF at the moment), dynamic linkers (so we can load & relocate shared libraries), syscall & IO handlers. For this reason, Qiling can run executable binary without requiring its native OS.
Qiling vs Qemu usermode

Qemu usermode does similar thing to our emulator, that is to emulate whole executable binaries in cross-architecture way. However, Qiling offers some important differences against Qemu usermode.

  • Qiling is a true analysis framework, that allows you to build your own dynamic analysis tools on top (in friendly Python language). Meanwhile, Qemu is just a tool, not a framework.
  • Qiling can perform dynamic instrumentation, and can even hotpatch code at runtime. Qemu does not do either.
  • Not only working cross-architecture, Qiling is also cross-platform, so for example you can run Linux ELF file on top of Windows. In contrast, Qemu usermode only run binary of the same OS, such as Linux ELF on Linux, due to the way it forwards syscall from emulated code to native OS.
  • Qiling supports more platforms, including Windows, MacOS, Linux & BSD. Qemu usermode can only handle Linux & BSD.

Installation

Please see setup guide file for how to install Qiling Framework.


Examples

  • Below example shows how to use Qiling framework to emulate a Windows EXE on a Linux machine.
from qiling import *

# sandbox to emulate the EXE
def my_sandbox(path, rootfs):
    # setup Qiling engine
    ql = Qiling(path, rootfs)
    # now emulate the EXE
    ql.run()

if __name__ == "__main__":
    # execute Windows EXE under our rootfs
    my_sandbox(["examples/rootfs/x86_windows/bin/x86_hello.exe"], "examples/rootfs/x86_windows")
  • Below example shows how to use Qiling framework to dynamically patch a Windows crackme, make it always display "Congratulation" dialog.
from qiling import *

def force_call_dialog_func(ql):
    # get DialogFunc address
    lpDialogFunc = ql.unpack32(ql.mem.read(ql.reg.esp - 0x8, 4))
    # setup stack memory for DialogFunc
    ql.stack_push(0)
    ql.stack_push(1001)
    ql.stack_push(273)
    ql.stack_push(0)
    ql.stack_push(0x0401018)
    # force EIP to DialogFunc
    ql.reg.eip = lpDialogFunc


def my_sandbox(path, rootfs):
    ql = Qiling(path, rootfs)
    # NOP out some code
    ql.patch(0x004010B5, b'\x90\x90')
    ql.patch(0x004010CD, b'\x90\x90')
    ql.patch(0x0040110B, b'\x90\x90')
    ql.patch(0x00401112, b'\x90\x90')
    # hook at an address with a callback
    ql.hook_address(force_call_dialog_func, 0x00401016)
    ql.run()


if __name__ == "__main__":
    my_sandbox(["rootfs/x86_windows/bin/Easy_CrackMe.exe"], "rootfs/x86_windows")

The below Youtube video shows how the above example works.

GDBserver with IDAPro demo

  • Solving a simple CTF challenge with Qiling Framework and IDAPro

Solving a simple CTF challenge with Qiling Framework and IDAPro

Fuzzing with Qiling Unicornalf

  • More information on fuzzing with Qiling Unicornalf can be found here.

qiling DEMO 2: Fuzzing with Qiling Unicornalf

Emulating ARM router firmware on Ubuntu X64 machine

  • Qiling Framework hot-patch and emulates ARM router's /usr/bin/httpd on a X86_64Bit Ubuntu

qiling DEMO 3: Fully emulating httpd from ARM router firmware with Qiling on Ubuntu X64 machine

Emulating UEFI

  • Qiling Framework emulates UEFI

qiling DEMO 4: Emulating UEFI


Qltool

Qiling also provides a friendly tool named qltool to quickly emulate shellcode & executable binaries.

With qltool, easy execution can be performed:

With shellcode:

$ ./qltool shellcode --os linux --arch arm --hex -f examples/shellcodes/linarm32_tcp_reverse_shell.hex

With binary file:

$ ./qltool run -f examples/rootfs/x8664_linux/bin/x8664_hello --rootfs  examples/rootfs/x8664_linux/

With binary and GDB debugger enable:

$ ./qltool run -f examples/rootfs/x8664_linux/bin/x8664_hello --gdb 127.0.0.1:9999 --rootfs examples/rootfs/x8664_linux

See https://docs.qiling.io/ for more details

With code coverage collection (UEFI only for now):

$ ./qltool run -f examples/rootfs/x8664_efi/bin/TcgPlatformSetupPolicy --rootfs examples/rootfs/x8664_efi --coverage-format drcov --coverage-file TcgPlatformSetupPolicy.cov

Remote Debugger

Qiling supports remote debugging now.

See https://docs.qiling.io/ for more details


Contact

Get the latest info from our website https://www.qiling.io

Contact us at email [email protected], or via Twitter @qiling_io or Weibo


Core developers

Travis-CI, Docker, Website and Documentation

Key Contributors (in no particular order)

  • lazymio
  • kabeor
  • 0ssigeno
  • liba2k
  • assafcarlsbad
  • ucgJhe
  • jhumble

This is an awesome project! Can I donate?

Yes, details please refer to https://www.qiling.io/donation/

qiling's People

Contributors

xwings avatar chfl4gs avatar ucgjhe avatar 0ssigeno avatar kabeor avatar aquynh avatar klks avatar wtdcode avatar dliv3 avatar liba2k avatar chenhuitao avatar w1tcher avatar assafcarlsbad avatar domenukk avatar spikei avatar jhumble avatar nghiadt1098 avatar l1nkz avatar kxynos avatar quangnh89 avatar alfink avatar learn-more avatar bambu avatar cclauss avatar cq674350529 avatar kqyang avatar justfoxing avatar d3smind avatar jimartin361 avatar abcsup avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.