Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
d6de9d6
Use ql_afl_fuzz_ext
wtdcode Mar 6, 2022
3194cd9
Rename to _custom
wtdcode Mar 6, 2022
1499e45
Merge origin/dev
wtdcode Mar 6, 2022
7aef51b
self.ql 不赋值就不存在,如果不去使用qiling插件时self.ql就不会初始化,
BRAlNDead May 31, 2022
bd1b7da
post 1.4.3 to 1.4.4
xwings Jun 1, 2022
c9bd0c1
Merge pull request #1165 from BRAlNDead/fix_ida_plugin
kabeor Jun 1, 2022
06a2a7e
Collect a few additional DLLs for x8664
Jun 2, 2022
76ae39e
fix: ql_syscall_faccessat
cgfandia-tii Jun 3, 2022
211dd07
fix: ql_syscall_writev
cgfandia-tii Jun 3, 2022
4964409
fix: `ql_syscall_connect`, `ql_syscall_bind`
cgfandia-tii Jun 3, 2022
1d271bf
fix: `ql_unix_socket_path`
cgfandia-tii Jun 3, 2022
59ecb1f
fix: `ql_syscall_sendto`
cgfandia-tii Jun 3, 2022
08e2751
Merge pull request #1167 from jasperla/dlls
xwings Jun 4, 2022
0f07bb6
fix: `__getdents_common`
cgfandia-tii Jun 6, 2022
7b50666
fix: `ql_syscall_recvfrom`
cgfandia-tii Jun 6, 2022
7c34381
Use global cwd in thread
bet4it Jun 10, 2022
5456e42
feat: add r2 extension
chinggg Jun 14, 2022
1404840
Introduce a minimal procfs to Linux OS
elicn Jun 14, 2022
9900c10
style: avoid importing namespace pollution
chinggg Jun 14, 2022
ebfa2d5
Add base class R2Data
chinggg Jun 18, 2022
c1dcc23
Support shellcode mode and set r2 asm arch and bits
chinggg Jun 18, 2022
54a5169
Merge pull request #1170 from bet4it/cwd
kabeor Jun 18, 2022
a550019
Clean r2 extension code
chinggg Jun 19, 2022
ca755a2
Replace binascii.unhexlify with bytes.fromhex in r2 example
chinggg Jun 19, 2022
e2cf9e2
style: improve typing
chinggg Jun 21, 2022
1252a38
Add r2libr==5.7.0 to essential dependency
chinggg Jun 21, 2022
b3877c1
Fix `QlLinuxThreadManagement.threads` to update appropriately
vhertz Jun 23, 2022
eefacbe
Add more one log for debugging
vhertz Jun 23, 2022
a911e91
Merge pull request #1 from cgfandia-tii/master
cgfandia-tii Jun 28, 2022
591976b
Merge branch 'qilingframework:dev' into dev
cgfandia-tii Jun 28, 2022
eecf72b
Merge pull request #1180 from vhertz/patch_linux_thread_management
xwings Jun 29, 2022
c83cb19
fix: remove comments
cgfandia-tii Jun 30, 2022
f31b083
Convert rwx perm str to UC_PROT const integer
chinggg Jul 2, 2022
475216b
Enable android 32bit test
bet4it Jul 1, 2022
24ec8fd
Add `read` function to r2
chinggg Jul 3, 2022
1dd96bf
Merge pull request #1184 from bet4it/test
xwings Jul 4, 2022
faf1537
Add functions to get binary info
chinggg Jul 4, 2022
0368def
Update CREDITS.md
xwings Jul 4, 2022
4dae041
Create __init__.py
xwings Jul 4, 2022
cee4265
Add function to get associated flag at an address
chinggg Jul 4, 2022
e4aad7d
style: simplify `read` function
chinggg Jul 5, 2022
bc53bb4
fix: revert to arch-dependent `getdents`
cgfandia-tii Jul 5, 2022
1d062ff
Wrong platform_system for unicornafl
wtdcode Jul 5, 2022
0a9085c
Provide virtual path instead of host path when possible
elicn Jun 14, 2022
0b90a3a
Code quality improvements
elicn Jun 14, 2022
c74cbfa
Use virtual address for KI_USER_SHARED_DATA
elicn Jun 28, 2022
de4b55a
Always init KI_USER_SHARED_DATA
elicn Jun 28, 2022
2f29ac5
Add required mscoree.dll
elicn Jun 28, 2022
4e2f760
Fix missing fcall unwinding during DllMain execution
elicn Jun 28, 2022
bb97fab
Fix WideCharToMultiByte and MultiByteToWideChar
elicn Jun 28, 2022
a3676c8
Fix clipboard data handling
elicn Jun 28, 2022
3f02a82
Extend MessageBox support to more types
elicn Jun 28, 2022
51c1444
Cleanup win threads and fix scheduling bug
elicn Jun 28, 2022
2f574f0
Implement __getmainargs
elicn Jun 28, 2022
03a435a
Fix CreateMutex
elicn Jun 28, 2022
75dde49
Fix GetModuleHandle
elicn Jun 28, 2022
948e6b8
Adjust image name on mem map
elicn Jun 28, 2022
a3a4b38
Support segmented references in trace
elicn Jun 28, 2022
5ae3cc2
Implement missing GetSystemTimeAsFileTime
elicn Jun 28, 2022
abc4d8e
Implement missing __strncnt
elicn Jun 28, 2022
4a98f8e
Resume on non-implemented info class values
elicn Jun 28, 2022
42d885e
Add missing import
elicn Jun 28, 2022
8507eec
Enable reading fcall ellipsis
elicn Jul 1, 2022
946debf
Improve format string handling
elicn Jul 1, 2022
87499f9
Let GetTokenInformation fail gracefully
elicn Jul 3, 2022
2b6e21e
Align _initterm implementation with _initterm_e
elicn Jul 3, 2022
b7f7c56
Have WideCharToMultiByte handle more corner cases
elicn Jul 3, 2022
006e6fd
Improve OpenMutex robustness
elicn Jul 3, 2022
43dc401
Improve CreateEvent robustness
elicn Jul 3, 2022
96ea792
Improve registry keys handling
elicn Jul 3, 2022
92f7bcc
Improve Windows exception handling
elicn Jul 3, 2022
1747248
Overlooked additions
elicn Jul 3, 2022
14e5bde
Improve LoadLibrary
elicn Jul 3, 2022
d816354
Fix GetModuleFileName
elicn Jul 3, 2022
6c56feb
Add missing TimeZoneAPI
elicn Jul 3, 2022
c36fa64
Fix bug in UnicodeString layout
elicn Jul 3, 2022
18a5668
A bit more accurate gdb features advertisement
elicn Jul 5, 2022
f6cf40a
refactor: simplify setup_code and setup_file
chinggg Jul 6, 2022
682ee74
Improve `at` function to get offset to flag
chinggg Jul 6, 2022
027a926
PoC of symbol resolved trace powered by r2
chinggg Jul 6, 2022
a9d7594
feat: PoC of r2 xref
chinggg Jul 6, 2022
5ca4277
refactor: use decorator to analyze before call methods
chinggg Jul 6, 2022
cc1e6f1
Merge pull request #1185 from qilingframework/fix-unicornafl-platform
kabeor Jul 7, 2022
862f0bc
Merge pull request #1186 from qilingframework/master
xwings Jul 7, 2022
057a9fd
Merge pull request #1174 from elicn/procfs-poc
xwings Jul 7, 2022
8dd9fa1
Update setup.py
aquynh Jul 7, 2022
577bd29
fix arm thumb mode emulating
ucgJhe Jul 8, 2022
a492e02
corresponding changes in qltool
ucgJhe Jul 8, 2022
accd101
add arm thumb mode test case
ucgJhe Jul 8, 2022
da814b4
Merge remote-tracking branch 'qiling.io/dev' into fix_thumb_emu
ucgJhe Jul 8, 2022
44f3984
Merge pull request #1189 from qilingframework/update-unicorn2
kabeor Jul 9, 2022
e30cf2d
Merge pull request #1187 from ucgJhe/fix_thumb_emu
xwings Jul 9, 2022
250d5df
Allow a mapper to be deleted
wtdcode Jul 10, 2022
56431fb
Implement /proc/self/maps and eliminate duplicate code with io.BytesIO
wtdcode Jul 10, 2022
b97ed73
Use new API
wtdcode Jul 10, 2022
0be8544
Use io.BytesIO
wtdcode Jul 10, 2022
f236aff
Fix compatibility with pwndbg
wtdcode Jul 10, 2022
5fc43d6
Make the write behavior consistent with previous implementation
wtdcode Jul 10, 2022
3777f9e
Compatible with previous TextIO
wtdcode Jul 10, 2022
0452767
Merge pull request #1107 from wtdcode/fuzz-ext
xwings Jul 11, 2022
d1fdb19
Merge pull request #1190 from wtdcode/proc-improv
kabeor Jul 11, 2022
cf51ee9
style(r2): adjust order of classes and methods
chinggg Jul 14, 2022
bc9680d
fix example script issues
kabeor Jul 14, 2022
ea294a8
Merge pull request #1193 from kabeor/examples_fix
wtdcode Jul 14, 2022
6b1a347
refactor(r2): get xrefs as list
chinggg Jul 15, 2022
86c3c9f
refactor: convert ql arch to r2 without removesuffix()
chinggg Jul 15, 2022
b2a2311
fix(r2): set r2 arch from QlArch properly
chinggg Jul 16, 2022
48c3699
test(r2): Add test for evm shellcode disasm
chinggg Jul 17, 2022
7c0fd6a
style(r2): remove unnecessary import
chinggg Jul 17, 2022
c197553
Fix examples
elicn Jul 17, 2022
7ce8109
chore: update r2libr and move to extra dependency
chinggg Jul 17, 2022
34b4898
Merge pull request #1172 from chinggg/r2
wtdcode Jul 18, 2022
40cdff8
Merge pull request #1194 from elicn/fix-examples
kabeor Jul 19, 2022
18eec6f
Merge pull request #1181 from cgfandia-tii/dev
xwings Jul 19, 2022
1fa094d
feat(r2): disasm N bytes to print resolved disasm
chinggg Jul 20, 2022
bb09b51
feat(r2): selective disasm by regex filtering flag name
chinggg Jul 25, 2022
5b114ca
Increase host security around fileystem access
elicn Jul 5, 2022
ae739a4
Misc. improvements to fileapi
elicn Jul 10, 2022
08f995d
Fix KD ABS symbol relocation
elicn Jul 18, 2022
0ca5fdc
Have tests clean up after themselves
elicn Jul 19, 2022
0cac645
Fix KO loading base address
elicn Jul 19, 2022
adfcef2
Adjusting ELF KO tests
elicn Jul 19, 2022
a57245b
Auto calculate needed vsyscall_size
elicn Jul 19, 2022
887bad6
Minor code tweaks to ELF loader
elicn Jul 19, 2022
3d7164d
Remove obsolete append setting from profiles
elicn Jul 19, 2022
a0c22ce
Remove obsolete LOG section from profiles
elicn Jul 19, 2022
9ad1909
feat(r2): add method where() to get address of name
chinggg Jul 27, 2022
754785b
fix(r2): default argument of filt_str in enable_disasm()
chinggg Jul 28, 2022
23dd437
ci: pip install r2libr when linux run tests
chinggg Jul 28, 2022
1427b32
fix(r2): remove `@staticmethod` decorator of `@aaa` wrapper
chinggg Jul 28, 2022
30282a9
fix(r2): disassembler return progress on invalid inst
chinggg Jul 28, 2022
2733e2b
feat(r2): monkey patch QlArchUtils.disassembler
chinggg Aug 1, 2022
e310c48
Fix gdb step/continue handling
rgrachek Aug 2, 2022
33799ed
Merge pull request #1200 from oscardagrach/gdb-fix
kabeor Aug 4, 2022
177f536
Added tenet tracer
Aug 6, 2022
c049377
fix README.md
hamarituc Aug 8, 2022
6bde122
Merge pull request #1203 from hamarituc/doc
xwings Aug 8, 2022
b4538bc
Fixed bug with negative values
Aug 9, 2022
0a84e9a
Merge pull request #1205 from EtchProject/dev
xwings Aug 10, 2022
2f41e9b
fix(gdb): typo of default ip 127.0.0.1
chinggg Aug 12, 2022
8530924
Merge pull request #1207 from chinggg/typo-gdb-ip
wtdcode Aug 12, 2022
d8c9cb5
feat: QL_VERBOSE.DISASM will try to use r2 disassembler
chinggg Aug 12, 2022
d9c75f8
Temporarily mask Python versions that are not supported by the EVM mo…
Aug 12, 2022
03c3856
Merge pull request #1208 from kabeor/qldev
kabeor Aug 12, 2022
d188f76
refactor(r2): addr <-> flag+delta using internal commands
chinggg Aug 17, 2022
ec86f5d
test(r2): improve test for flag resolving and disasm
chinggg Aug 18, 2022
5442792
Merge pull request #1196 from chinggg/r2-enable-disasm
wtdcode Aug 21, 2022
9498570
Update changelog to version 1.4.4
Aug 22, 2022
9916198
Define Windows console structures
elicn Jul 26, 2022
e1b738a
Implement PROCESS_BASIC_INFORMATION as a ctypes structure
elicn Jul 26, 2022
7150e4a
Improve QueryInformationProcess
elicn Jul 26, 2022
36ae903
Remove an unnecessary try-catch block
elicn Jul 26, 2022
f3c2c9b
Adjust Al-Khaser test
elicn Jul 26, 2022
8afefca
Initialize KUSER_SHARED_DATA key fields
elicn Jul 26, 2022
a3b078d
Use info from KUSER_SHARED_DATA where possible
elicn Jul 26, 2022
5e44873
Code deduplication
elicn Jul 26, 2022
91f3cfd
Use values instead of pointer types
elicn Jul 27, 2022
5704304
Improve VerSetConditionMask and VerifyVersionInfo
elicn Aug 4, 2022
5d15799
Remove syscall_count
elicn Aug 4, 2022
5963d3b
Patch outdated verify_ret
elicn Aug 17, 2022
6e4abd1
Introducing OS struct module
elicn Aug 17, 2022
aedbd56
Adjust Windows structure definitions to the new struct model
elicn Aug 17, 2022
9523978
Adjust structures used by PE loader
elicn Aug 17, 2022
e2844ea
Adjust structures used in Win API
elicn Aug 17, 2022
94c1f19
Adjust tests
elicn Aug 17, 2022
0a4afcf
Bugfixes
elicn Aug 17, 2022
3cc699b
Redefine SID as a BaseStruct
elicn Aug 19, 2022
5000cf6
Redefine SYSTEMTIME as a BaseStruct
elicn Aug 19, 2022
67c61f6
Redefine SYSTEM_INFO as a BaseStruct
elicn Aug 19, 2022
241d881
Redefine OSVERSIONINFOEX as a BaseStruct
elicn Aug 19, 2022
3552ab1
Fix syntax issue
elicn Aug 19, 2022
f22045b
Redefine SHELLEXECUTEINFO as a BaseStruct
elicn Aug 19, 2022
12dbb27
Redefine STARTUPINFO as a BaseStruct
elicn Aug 19, 2022
373e9c4
Redefine SYSTEM_BASIC_INFORMATION as a BaseStruct
elicn Aug 19, 2022
088f5ed
Redefine POINT as a BaseStruct
elicn Aug 19, 2022
0b8c2ef
Redefine HOSTENT as a BaseStruct
elicn Aug 19, 2022
0a3fb1e
Redefine OBJECT_TYPE_INFORMATION as a BaseStruct
elicn Aug 21, 2022
8998f66
Fix types incompatibility
elicn Aug 21, 2022
b811cbf
Fix overlooked fields names
elicn Aug 21, 2022
a3aef2b
Fix Al-Khaser related issues
elicn Aug 21, 2022
37c00ff
Fix API cc
elicn Aug 21, 2022
2045715
Make IsDebuggerPresentconsistent with PEB
elicn Aug 21, 2022
d3c90f5
Fix wrong object reference
elicn Aug 21, 2022
d0f477e
Fix init with incompatible types
elicn Aug 21, 2022
9977863
Redefine WIN32_FIND_DATA as a BaseStruct
elicn Aug 21, 2022
6883aab
Fix syntax isue
elicn Aug 21, 2022
5d7a8f0
Clean up residuals
elicn Aug 21, 2022
fde213b
Merge branch 'dev' of https://github.com/qilingframework/qiling into …
Aug 30, 2022
34d49c5
Add x86_64 debug support
HackingFrogWithSunglasses Aug 31, 2022
934e4e5
Change unix_socket_path to support more meaningful logging
elicn Aug 30, 2022
b296e68
Simplify connect syscall
elicn Aug 30, 2022
65606d2
Modify socket ioctl to log underlying exceptions
elicn Aug 30, 2022
b78611d
Add ifrname_override option to work around some sockets ioctl errors
elicn Aug 30, 2022
edf36be
renew code for picohttpd
xwings Sep 1, 2022
159b035
Merge pull request #1221 from xwings/dev
kabeor Sep 1, 2022
106a9d7
remove unneeded frontend.py in qdb
Sep 7, 2022
b420f1e
fix missing _return_address_on_stack for arm
Sep 7, 2022
6c3e655
retab modified file
Sep 7, 2022
89d95ba
add features: mark and jump in qdb
ucgJhe Sep 10, 2022
eb41e43
Merge remote-tracking branch 'qiling.io/dev' into qdb
ucgJhe Sep 10, 2022
c1068de
move marking-related function into a class Marker
Sep 10, 2022
30046d8
more comment
Sep 10, 2022
de7e510
add feature: setting register value in qdb
Sep 10, 2022
0f22094
handle negtive value in register setting
Sep 10, 2022
d5e6109
allow user to build config from dictionary other than disk file
Sep 10, 2022
f68ea66
proper type hint for profile_setup
Sep 10, 2022
89811a0
fix profile_setup default behavior
Sep 10, 2022
dd1aff9
Merge pull request #1225 from ucgJhe/fix_bug
kabeor Sep 13, 2022
be2eef1
Merge remote-tracking branch 'qiling.io/dev' into dev
Sep 15, 2022
6ac199d
keep same behaviour as previous version of profile_setup
Sep 22, 2022
0a74071
make sure user_config is not None
Sep 22, 2022
5eaea98
Merge pull request #1227 from ucgJhe/dev
xwings Sep 23, 2022
717241a
Merge pull request #1226 from ucgJhe/qdb
xwings Sep 23, 2022
bd2074b
Merge pull request #1218 from coretechsec/debugger
kabeor Sep 23, 2022
926a45f
update changelog
Sep 23, 2022
51396db
fix(ida): replace __getattribute__ with __getattr__
chinggg Sep 23, 2022
d3d239d
update changelog date
Sep 24, 2022
b245269
Merge pull request #1212 from kabeor/changelog_144
xwings Sep 24, 2022
dea4cf6
Update setup.py
xwings Sep 24, 2022
28c06fc
Merge pull request #1231 from chinggg/fix-ida-getattr
xwings Sep 24, 2022
75aaafd
Update ChangeLog
xwings Sep 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
cd ../qiling
cd ../examples/rootfs/x86_linux/kernel && unzip -P infected m0hamed_rootkit.ko.zip
cd ../../../../
pip3 install -e .[evm]
pip3 install -e .[evm,RE]

if [ ${{ matrix.os }} == 'ubuntu-18.04' ] and [ ${{ matrix.python-version }} == '3.9' ]; then
docker run -it --rm -v ${GITHUB_WORKSPACE}:/qiling qilingframework/qiling:dev bash -c "cd tests && ./test_onlinux.sh"
Expand Down
4 changes: 2 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#### CI, Website,Documentations, Logo & Swags

- FOO Kevin (chfl4gs) <chfl4gs_at_qiling_io>
- SU muchen (miraisuu) <suu_at_iling_io>
- SU muchen (miraisuu) <suu_at_qiling_io>


#### Key Contributors (in no particular order)
Expand All @@ -36,6 +36,7 @@
- Mark Jansen (learn-more)
- cq674350529
- bkerler (viperbjk)
- bet4it


#### Contributors (in no particular order)
Expand All @@ -53,7 +54,6 @@
- madprogrammer
- danielmoos
- sigeryang
- bet4it
- nullableVoidPtr


Expand Down
49 changes: 48 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
This file details the changelog of Qiling Framework.

------------------------------------
[Version 1.4.4]: July XX, 2022
[Version 1.4.4]: September 24th, 2022

New features:
- Add r2 extension (#1172)
- Introduce procfs to Linux OS (#1174)
- Add a tracer for IDAPro's Tenet plugin (#1205)

Improvements:
- Collect a few additional DLLs for x8664 (#1167)
- Use global cwd in thread (#1170)
- Fix QlLinuxThreadManagement.threads to be updated appropriately (#1180)
- Fix Unix socket subsystem (#1181)
- Maintenance PR for security and code quality (#1182 #1195)
- Enable android 32bit test (#1184)
- Fix wrong platform_system for unicornafl (#1185)
- Fix arm thumb mode shellcode emulation (#1187)
- Pump unicorn version to 2.0.0 (#1189)
- Procfs improve & pwndbg compatiblity (#1190)
- Fix example script issues (#1193 #1194)
- Introduce a human-friendly disassembler (#1196)
- Fix gdb step/continue handling (#1200)
- Fix README.md (#1203)
- Fix typo of default ip 127.0.0.1 (#1205)
- Temporarily mask Python versions that are not supported by the EVM module (#1208)
- Windows Maintenance PR (#1210)
- Improvements around POSIX sockets (#1216)
- Add x86_64 debug support for Qdb (#1218)
- Renew code for picohttpd (#1221)
- Fix missing retaddr_on_stack in Qdb for arm (#1225)
- Qdb improvments: Mark, Jump and modify register value in qdb (#1226)
- Allow user to build config from dictionary other than disk file (#1227)
- fix(ida): replace __getattribute__ with __getattr__ (#1231)

Contributors:
- jasperla
- bet4it
- chinggg
- elicn
- vhertz
- cgfandia-tii
- wtdcode
- ucgJhe
- aquynh
- kabeor
- oscardagrach
- hamarituc
- EtchProject
- HackingFrogWithSunglasses
- xwings

------------------------------------
[Version 1.4.3]: June 1st, 2022
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ With qltool, easy execution can be performed:
With shellcode:

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

With binary file:
Expand Down
2 changes: 1 addition & 1 deletion examples/crackme_x86_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Solver:
def __init__(self, invalid: bytes):
# create a silent qiling instance
self.ql = Qiling([rf"{ROOTFS}/bin/crackme.exe"], ROOTFS, verbose=QL_VERBOSE.OFF)
self.ql = Qiling([rf"{ROOTFS}/bin/crackme.exe"], ROOTFS, verbose=QL_VERBOSE.DISABLED)

self.ql.os.stdin = pipe.SimpleInStream(sys.stdin.fileno()) # take over the input to the program using a fake stdin
self.ql.os.stdout = pipe.NullOutStream(sys.stdout.fileno()) # disregard program output
Expand Down
12 changes: 11 additions & 1 deletion examples/crackme_x86_windows_setcallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,36 @@
from qiling import Qiling

def force_call_dialog_func(ql: Qiling):
# this hook is invoked after returning from DialogBoxParamA, so its
# stack frame content is still available to us.

# get DialogFunc address
lpDialogFunc = ql.unpack32(ql.mem.read(ql.arch.regs.esp - 0x8, 4))
lpDialogFunc = ql.stack_read(-8)

# setup stack 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.arch.regs.eip = lpDialogFunc

def my_sandbox(path, rootfs):
ql = Qiling(path, rootfs)

# patch the input validation code: overwrite all its breaking points
# denoted with "jne 0x401135", so it would keep going even if there
# is an error
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 the instruction after returning from DialogBoxParamA
ql.hook_address(force_call_dialog_func, 0x00401016)

ql.run()

if __name__ == "__main__":
Expand Down
9 changes: 8 additions & 1 deletion examples/crackme_x86_windows_unpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@
from qiling import Qiling

def force_call_dialog_func(ql: Qiling):
# this hook is invoked after returning from DialogBoxParamA, so its
# stack frame content is still available to us.

# get DialogFunc address
lpDialogFunc = ql.unpack32(ql.mem.read(ql.arch.regs.esp - 0x8, 4))
lpDialogFunc = ql.stack_read(-8)

# setup stack 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.arch.regs.eip = lpDialogFunc

def our_sandbox(path, rootfs):
ql = Qiling(path, rootfs)

# hook the instruction after returning from DialogBoxParamA
ql.hook_address(force_call_dialog_func, 0x00401016)

ql.run()

if __name__ == "__main__":
Expand Down
50 changes: 50 additions & 0 deletions examples/extensions/r2/hello_r2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
#
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
#

import sys
sys.path.append('..')

from qiling import Qiling
from qiling.const import QL_VERBOSE
from qiling.extensions.r2 import R2


def func(ql: Qiling, *args, **kwargs):
ql.os.stdout.write(b"=====hooked main=====!\n")
return

def my_sandbox(path, rootfs):
ql = Qiling(path, rootfs, verbose=QL_VERBOSE.DISASM)
# QL_VERBOSE.DISASM will be monkey-patched when r2 is available
r2 = R2(ql)

# search bytes sequence using ql.mem.search
addrs = ql.mem.search(b'llo worl') # return all matching results
print(r2.at(addrs[0])) # find corresponding flag at the address and the offset to the flag
# search string using r2
addr = r2.strings['Hello world!'].vaddr # key must be exactly same
print(addrs[0], addr)
# print xref to string "Hello world!"
print(r2.refto(addr))
# write to string using ql.mem.write
ql.mem.write(addr, b"No hello, Bye!\x00")

# get function address and hook it
ql.hook_address(func, r2.functions['main'].offset)
# enable trace powered by r2 symsmap
# r2.enable_trace()
ql.run()

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

# test shellcode mode
ARM64_LIN = bytes.fromhex('420002ca210080d2400080d2c81880d2010000d4e60300aa01020010020280d2681980d2010000d4410080d2420002cae00306aa080380d2010000d4210400f165ffff54e0000010420002ca210001caa81b80d2010000d4020004d27f0000012f62696e2f736800')
print("\nLinux ARM 64bit Shellcode")
ql = Qiling(code=ARM64_LIN, archtype="arm64", ostype="linux", verbose=QL_VERBOSE.DEBUG)
r2 = R2(ql)
# disassemble 32 instructions
print(r2._cmd('pd 32'))
ql.run()
5 changes: 4 additions & 1 deletion examples/hello_arm_qnx_customapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@
sys.path.append("..")

from qiling import Qiling
from qiling.const import QL_INTERCEPT, QL_CALL_BLOCK, QL_VERBOSE
from qiling.const import QL_INTERCEPT, QL_CALL_BLOCK
from qiling.os.const import STRING

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

print(f'puts("{params["s"]}")')

return QL_CALL_BLOCK

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

print(f'printf("{params["s"]}")')

return QL_CALL_BLOCK

def my_puts_onexit(ql: Qiling):
print(f'after puts')

return QL_CALL_BLOCK

if __name__ == "__main__":
Expand Down
12 changes: 8 additions & 4 deletions examples/hello_arm_uboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
from qiling.os.const import STRING

def get_kaimendaji_password():
def my_getenv(ql, *args, **kwargs):
env = {"ID": b"000000000000000", "ethaddr": b"11:22:33:44:55:66"}
def my_getenv(ql: Qiling):
env = {
"ID" : b"000000000000000",
"ethaddr" : b"11:22:33:44:55:66"
}

params = ql.os.resolve_fcall_params({'key': STRING})
value = env.get(params["key"], b"")

Expand All @@ -22,7 +26,7 @@ def my_getenv(ql, *args, **kwargs):
ql.arch.regs.r0 = value_addr
ql.arch.regs.arch_pc = ql.arch.regs.lr

def get_password(ql, *args, **kwargs):
def get_password(ql: Qiling):
password_raw = ql.mem.read(ql.arch.regs.r0, ql.arch.regs.r2)

password = ''
Expand All @@ -34,7 +38,7 @@ def get_password(ql, *args, **kwargs):

print("The password is: %s" % password)

def partial_run_init(ql):
def partial_run_init(ql: Qiling):
# argv prepare
ql.arch.regs.arch_sp -= 0x30
arg0_ptr = ql.arch.regs.arch_sp
Expand Down
17 changes: 10 additions & 7 deletions examples/hello_linuxx8664_intercept.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
sys.path.append("..")

from qiling import Qiling
from qiling.const import QL_INTERCEPT, QL_VERBOSE
from qiling.const import QL_INTERCEPT
from qiling.os.linux.syscall_nums import SYSCALL_NR

def write_onenter(ql: Qiling, arg1, arg2, arg3, *args):
def write_onenter(ql: Qiling, fd: int, buf: int, count: int):
print("enter write syscall!")
ql.arch.regs.rsi = arg2 + 1
ql.arch.regs.rdx = arg3 - 1

def write_onexit(ql: Qiling, arg1, arg2, arg3, *args):
ql.arch.regs.rsi = buf + 1
ql.arch.regs.rdx = count - 1

def write_onexit(ql: Qiling, fd: int, buf: int, count: int, retval: int):
print("exit write syscall!")
ql.arch.regs.rax = arg3 + 1

ql.arch.regs.rax = count + 1

if __name__ == "__main__":
ql = Qiling(["rootfs/x8664_linux/bin/x8664_hello"], "rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
ql = Qiling(["rootfs/x8664_linux/bin/x8664_hello"], "rootfs/x8664_linux")

ql.os.set_syscall(SYSCALL_NR.write, write_onenter, QL_INTERCEPT.ENTER)
ql.os.set_syscall(SYSCALL_NR.write, write_onexit, QL_INTERCEPT.EXIT)

ql.run()
15 changes: 11 additions & 4 deletions examples/hello_x8664_linux_part_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
from qiling.const import QL_VERBOSE

if __name__ == "__main__":
ql = Qiling(["rootfs/x8664_linux/bin/sleep_hello"], "rootfs/x8664_linux", verbose=QL_VERBOSE.DEFAULT)
def dump(ql, *args, **kw):
ql.save(reg=False, cpu_context=True, snapshot="/tmp/snapshot.bin")
ql.emu_stop()

# load base address from profile file
ql = Qiling(["rootfs/x8664_linux/bin/sleep_hello"], "rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
X64BASE = int(ql.profile.get("OS64", "load_address"), 16)
ql.hook_address(dump, X64BASE + 0x1094)
ql.run()

ql = Qiling(["rootfs/x8664_linux/bin/sleep_hello"], "rootfs/x8664_linux", verbose=QL_VERBOSE.DISASM)
# load base address from profile file
X64BASE = int(ql.profile.get("OS64", "load_address"), 16)
ql.restore(snapshot="/tmp/snapshot.bin")
# set execution starting and ending points
begin_point = X64BASE + 0x109e
end_point = X64BASE + 0x10bc

ql.run(begin=begin_point, end=end_point)
ql.run(begin = begin_point, end = end_point)
2 changes: 1 addition & 1 deletion examples/rootfs
14 changes: 7 additions & 7 deletions examples/sality.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ def hook_WriteFile(ql: Qiling, address: int, params):
if hFile == 0x13371337:
buffer = ql.mem.read(lpBuffer, nNumberOfBytesToWrite)
try:
r, nNumberOfBytesToWrite = utils.io_Write(ql.amsint32_driver, buffer)
nNumberOfBytesToWrite = utils.io_Write(ql.amsint32_driver, buffer)
ql.mem.write_ptr(lpNumberOfBytesWritten, nNumberOfBytesToWrite, 4)
except Exception as e:
except Exception:
ql.log.exception("")
print("Exception = %s" % str(e))
r = 1
if r:
return 1
r = False
else:
return 0
r = True

return int(r)

else:
return _WriteFile(ql, address, params)

Expand Down
Loading