Skip to content

Commit ee0fbed

Browse files
Merge branch 'dev' into pyproject
Update pyproject.toml to update deps and replace MANIFEST.in
2 parents 683bf43 + 22c2ac6 commit ee0fbed

File tree

310 files changed

+13013
-6190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+13013
-6190
lines changed

.github/workflows/build-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
cd ../qiling
8181
cd ../examples/rootfs/x86_linux/kernel && unzip -P infected m0hamed_rootkit.ko.zip
8282
cd ../../../../
83-
pip3 install -e .[evm]
83+
pip3 install -e .[evm,RE]
8484
8585
if [ ${{ matrix.os }} == 'ubuntu-18.04' ] and [ ${{ matrix.python-version }} == '3.9' ]; then
8686
docker run -it --rm -v ${GITHUB_WORKSPACE}:/qiling qilingframework/qiling:dev bash -c "cd tests && ./test_onlinux.sh"

.github/workflows/giteesync.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
jobs:
66
deploy:
77
runs-on: ubuntu-latest
8+
if: github.repository_owner == 'qilingframework'
89
steps:
910
- uses: actions/checkout@v2
1011
with:

CREDITS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#### CI, Website,Documentations, Logo & Swags
2424

2525
- FOO Kevin (chfl4gs) <chfl4gs_at_qiling_io>
26-
- SU muchen (miraisuu) <suu_at_iling_io>
26+
- SU muchen (miraisuu) <suu_at_qiling_io>
2727

2828

2929
#### Key Contributors (in no particular order)
@@ -36,6 +36,7 @@
3636
- Mark Jansen (learn-more)
3737
- cq674350529
3838
- bkerler (viperbjk)
39+
- bet4it
3940

4041

4142
#### Contributors (in no particular order)
@@ -53,7 +54,7 @@
5354
- madprogrammer
5455
- danielmoos
5556
- sigeryang
56-
- bet4it
57+
- nullableVoidPtr
5758

5859

5960
#### Legacy Core Developers

ChangeLog

+75-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
11
This file details the changelog of Qiling Framework.
22

33
------------------------------------
4-
[Version 1.4.3]: April 7th, 2022
4+
[Version 1.4.4]: September 24th, 2022
5+
6+
New features:
7+
- Add r2 extension (#1172)
8+
- Introduce procfs to Linux OS (#1174)
9+
- Add a tracer for IDAPro's Tenet plugin (#1205)
10+
11+
Improvements:
12+
- Collect a few additional DLLs for x8664 (#1167)
13+
- Use global cwd in thread (#1170)
14+
- Fix QlLinuxThreadManagement.threads to be updated appropriately (#1180)
15+
- Fix Unix socket subsystem (#1181)
16+
- Maintenance PR for security and code quality (#1182 #1195)
17+
- Enable android 32bit test (#1184)
18+
- Fix wrong platform_system for unicornafl (#1185)
19+
- Fix arm thumb mode shellcode emulation (#1187)
20+
- Pump unicorn version to 2.0.0 (#1189)
21+
- Procfs improve & pwndbg compatiblity (#1190)
22+
- Fix example script issues (#1193 #1194)
23+
- Introduce a human-friendly disassembler (#1196)
24+
- Fix gdb step/continue handling (#1200)
25+
- Fix README.md (#1203)
26+
- Fix typo of default ip 127.0.0.1 (#1205)
27+
- Temporarily mask Python versions that are not supported by the EVM module (#1208)
28+
- Windows Maintenance PR (#1210)
29+
- Improvements around POSIX sockets (#1216)
30+
- Add x86_64 debug support for Qdb (#1218)
31+
- Renew code for picohttpd (#1221)
32+
- Fix missing retaddr_on_stack in Qdb for arm (#1225)
33+
- Qdb improvments: Mark, Jump and modify register value in qdb (#1226)
34+
- Allow user to build config from dictionary other than disk file (#1227)
35+
- fix(ida): replace __getattribute__ with __getattr__ (#1231)
36+
37+
Contributors:
38+
- jasperla
39+
- bet4it
40+
- chinggg
41+
- elicn
42+
- vhertz
43+
- cgfandia-tii
44+
- wtdcode
45+
- ucgJhe
46+
- aquynh
47+
- kabeor
48+
- oscardagrach
49+
- hamarituc
50+
- EtchProject
51+
- HackingFrogWithSunglasses
52+
- xwings
53+
54+
------------------------------------
55+
[Version 1.4.3]: June 1st, 2022
56+
57+
New features:
58+
- Introduce PowerPC architecture support (#1140)
559

660
Improvements:
761
- Fix fuzzing for tendaac15 (#1096)
@@ -10,21 +64,41 @@ Improvements:
1064
- Minor PE Loader fix (#1104)
1165
- Minor quality changes (#1106)
1266
- Fix cacheflush syscall typo (#1115)
67+
- Improvements and fixes for Windows and PE (#1118)
1368
- Add vm_context to EVM hooks (#1119)
1469
- Load interpreter segments with correct perms and vaddr (#1120)
1570
- Fix mistakes in fuzz_x8664_linux binary (#1121)
1671
- Add EVM ABI helpers, fix EVM DBG stack view (#1123)
1772
- Fix regression caused by missing exception handling when opening socket (#1124)
73+
- CI improvement (#1128 #1134)
74+
- Add macho load command 'LC_LOAD_WEAK_DYLIB' support (#1133)
75+
- Fix breakage of non-Windows binary emulation on Windows host (#1143)
76+
- Remove misused region bound check of unmap_all (#1144)
77+
- Change deprecated interfaces of IDA (#1145)
78+
- Use importlib to retrieve package version (#1146)
79+
- New and improved gdbserver (#1148)
80+
- Rewrite package data reading (#1150)
81+
- Misc improvements (#1154)
82+
- Fix memory exhaustion problem caused by the logger (#1161)
1883

1984
Contributors:
2085
- wtdcode
2186
- aquynh
2287
- elicn
2388
- xwings
2489
- cq674350529
90+
- elicn
2591
- TheZ3ro
2692
- bet4it
2793
- chinggg
94+
- kabeor
95+
- chfl4gs
96+
- profiles
97+
- OlfillasOdikno
98+
- nmantan
99+
- machinewu
100+
- nullableVoidPtr
101+
- Phat3
28102

29103

30104
------------------------------------

MANIFEST.in

-4
This file was deleted.

README.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ With qltool, easy execution can be performed:
182182
With shellcode:
183183

184184
```
185-
$ ./qltool shellcode --os linux --arch arm --hex -f examples/shellcodes/linarm32_tcp_reverse_shell.hex
185+
$ ./qltool code --os linux --arch arm --format hex -f examples/shellcodes/linarm32_tcp_reverse_shell.hex
186186
```
187187

188188
With binary file:
@@ -222,9 +222,3 @@ Contact us at email [email protected], or via Twitter [@qiling_io](https://twitter.
222222
#### Core developers, Key Contributors and etc
223223

224224
Please refer to [CREDITS.md](https://github.com/qilingframework/qiling/blob/dev/CREDITS.md)
225-
226-
227-
---
228-
229-
#### This is an awesome project! Can I donate?
230-
Yes, checkout [SWAG](https://www.qiling.io/swag/)

examples/crackme_x86_windows.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class Solver:
1616
def __init__(self, invalid: bytes):
1717
# create a silent qiling instance
18-
self.ql = Qiling([rf"{ROOTFS}/bin/crackme.exe"], ROOTFS, verbose=QL_VERBOSE.OFF)
18+
self.ql = Qiling([rf"{ROOTFS}/bin/crackme.exe"], ROOTFS, verbose=QL_VERBOSE.DISABLED)
1919

2020
self.ql.os.stdin = pipe.SimpleInStream(sys.stdin.fileno()) # take over the input to the program using a fake stdin
2121
self.ql.os.stdout = pipe.NullOutStream(sys.stdout.fileno()) # disregard program output

examples/crackme_x86_windows_setcallback.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,36 @@
99
from qiling import Qiling
1010

1111
def force_call_dialog_func(ql: Qiling):
12+
# this hook is invoked after returning from DialogBoxParamA, so its
13+
# stack frame content is still available to us.
14+
1215
# get DialogFunc address
13-
lpDialogFunc = ql.unpack32(ql.mem.read(ql.arch.regs.esp - 0x8, 4))
16+
lpDialogFunc = ql.stack_read(-8)
17+
1418
# setup stack for DialogFunc
1519
ql.stack_push(0)
1620
ql.stack_push(1001)
1721
ql.stack_push(273)
1822
ql.stack_push(0)
1923
ql.stack_push(0x0401018)
24+
2025
# force EIP to DialogFunc
2126
ql.arch.regs.eip = lpDialogFunc
2227

2328
def my_sandbox(path, rootfs):
2429
ql = Qiling(path, rootfs)
2530

31+
# patch the input validation code: overwrite all its breaking points
32+
# denoted with "jne 0x401135", so it would keep going even if there
33+
# is an error
2634
ql.patch(0x004010B5, b'\x90\x90')
2735
ql.patch(0x004010CD, b'\x90\x90')
2836
ql.patch(0x0040110B, b'\x90\x90')
2937
ql.patch(0x00401112, b'\x90\x90')
3038

39+
# hook the instruction after returning from DialogBoxParamA
3140
ql.hook_address(force_call_dialog_func, 0x00401016)
41+
3242
ql.run()
3343

3444
if __name__ == "__main__":

examples/crackme_x86_windows_unpatch.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,28 @@
99
from qiling import Qiling
1010

1111
def force_call_dialog_func(ql: Qiling):
12+
# this hook is invoked after returning from DialogBoxParamA, so its
13+
# stack frame content is still available to us.
14+
1215
# get DialogFunc address
13-
lpDialogFunc = ql.unpack32(ql.mem.read(ql.arch.regs.esp - 0x8, 4))
16+
lpDialogFunc = ql.stack_read(-8)
17+
1418
# setup stack for DialogFunc
1519
ql.stack_push(0)
1620
ql.stack_push(1001)
1721
ql.stack_push(273)
1822
ql.stack_push(0)
1923
ql.stack_push(0x0401018)
24+
2025
# force EIP to DialogFunc
2126
ql.arch.regs.eip = lpDialogFunc
2227

2328
def our_sandbox(path, rootfs):
2429
ql = Qiling(path, rootfs)
2530

31+
# hook the instruction after returning from DialogBoxParamA
2632
ql.hook_address(force_call_dialog_func, 0x00401016)
33+
2734
ql.run()
2835

2936
if __name__ == "__main__":

examples/extensions/r2/hello_r2.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
import sys
7+
sys.path.append('..')
8+
9+
from qiling import Qiling
10+
from qiling.const import QL_VERBOSE
11+
from qiling.extensions.r2 import R2
12+
13+
14+
def func(ql: Qiling, *args, **kwargs):
15+
ql.os.stdout.write(b"=====hooked main=====!\n")
16+
return
17+
18+
def my_sandbox(path, rootfs):
19+
ql = Qiling(path, rootfs, verbose=QL_VERBOSE.DISASM)
20+
# QL_VERBOSE.DISASM will be monkey-patched when r2 is available
21+
r2 = R2(ql)
22+
23+
# search bytes sequence using ql.mem.search
24+
addrs = ql.mem.search(b'llo worl') # return all matching results
25+
print(r2.at(addrs[0])) # find corresponding flag at the address and the offset to the flag
26+
# search string using r2
27+
addr = r2.strings['Hello world!'].vaddr # key must be exactly same
28+
print(addrs[0], addr)
29+
# print xref to string "Hello world!"
30+
print(r2.refto(addr))
31+
# write to string using ql.mem.write
32+
ql.mem.write(addr, b"No hello, Bye!\x00")
33+
34+
# get function address and hook it
35+
ql.hook_address(func, r2.functions['main'].offset)
36+
# enable trace powered by r2 symsmap
37+
# r2.enable_trace()
38+
ql.run()
39+
40+
if __name__ == "__main__":
41+
my_sandbox(["rootfs/x86_windows/bin/x86_hello.exe"], "rootfs/x86_windows")
42+
43+
# test shellcode mode
44+
ARM64_LIN = bytes.fromhex('420002ca210080d2400080d2c81880d2010000d4e60300aa01020010020280d2681980d2010000d4410080d2420002cae00306aa080380d2010000d4210400f165ffff54e0000010420002ca210001caa81b80d2010000d4020004d27f0000012f62696e2f736800')
45+
print("\nLinux ARM 64bit Shellcode")
46+
ql = Qiling(code=ARM64_LIN, archtype="arm64", ostype="linux", verbose=QL_VERBOSE.DEBUG)
47+
r2 = R2(ql)
48+
# disassemble 32 instructions
49+
print(r2._cmd('pd 32'))
50+
ql.run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hackme
2+
aaaaaaaaaaaa

examples/fuzzing/stm32f429/fuzz.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
import os
7+
import sys
8+
9+
from typing import Any, Optional
10+
11+
sys.path.append("../../..")
12+
from qiling.core import Qiling
13+
from qiling.const import QL_VERBOSE
14+
15+
from qiling.extensions.afl import ql_afl_fuzz_custom
16+
from qiling.extensions.mcu.stm32f4 import stm32f429
17+
18+
from unicorn import UC_ERR_OK, UcError
19+
20+
def main(input_file: str):
21+
ql = Qiling(["../../rootfs/mcu/stm32f429/bof.elf"],
22+
archtype="cortex_m",
23+
env=stm32f429,
24+
ostype='mcu',
25+
verbose=QL_VERBOSE.DISABLED)
26+
27+
ql.hw.create('rcc')
28+
ql.hw.create('usart2')
29+
ql.hw.create('usart3')
30+
31+
ql.fast_mode = True
32+
33+
def place_input_callback(ql: Qiling, input_bytes: bytes, persistent_round: int) -> Optional[bool]:
34+
"""Called with every newly generated input."""
35+
36+
ql.hw.usart3.send(input_bytes)
37+
38+
return True
39+
40+
def fuzzing_callback(ql: Qiling):
41+
ql.run(end=0x80006d9)
42+
43+
return UC_ERR_OK
44+
45+
ql.uc.ctl_exits_enabled(True)
46+
ql.uc.ctl_set_exits([0x80006d9])
47+
48+
ql_afl_fuzz_custom(ql, input_file, place_input_callback, fuzzing_callback=fuzzing_callback)
49+
50+
os.exit(0)
51+
52+
if __name__ == "__main__":
53+
if len(sys.argv) == 1:
54+
raise ValueError("No input file provided.")
55+
56+
main(sys.argv[1])

examples/fuzzing/stm32f429/fuzz.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
AFL_AUTORESUME=1 afl-fuzz -i afl_inputs -o afl_outputs -U -- python3 ./fuzz.py @@

examples/hello_arm_qnx_customapi.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@
77
sys.path.append("..")
88

99
from qiling import Qiling
10-
from qiling.const import QL_INTERCEPT, QL_CALL_BLOCK, QL_VERBOSE
10+
from qiling.const import QL_INTERCEPT, QL_CALL_BLOCK
1111
from qiling.os.const import STRING
1212

1313
def my_puts_onenter(ql: Qiling):
1414
params = ql.os.resolve_fcall_params({'s': STRING})
1515

1616
print(f'puts("{params["s"]}")')
17+
1718
return QL_CALL_BLOCK
1819

1920
def my_printf_onenter(ql: Qiling):
2021
params = ql.os.resolve_fcall_params({'s': STRING})
2122

2223
print(f'printf("{params["s"]}")')
24+
2325
return QL_CALL_BLOCK
2426

2527
def my_puts_onexit(ql: Qiling):
2628
print(f'after puts')
29+
2730
return QL_CALL_BLOCK
2831

2932
if __name__ == "__main__":

0 commit comments

Comments
 (0)