Skip to content

Commit 0c2178f

Browse files
authored
Merge pull request #629 from qilingframework/dev
1.2.1 ready
2 parents d59436e + 0eb66a9 commit 0c2178f

File tree

183 files changed

+7567
-6157
lines changed

Some content is hidden

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

183 files changed

+7567
-6157
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
1-
- [ ] Have you checked that there aren't other open [pull requests](https://github.com/qilingframework/qiling/pulls) for the same update/change?
2-
- [ ] Is this pull request for [dev](https://github.com/qilingframework/qiling/tree/dev) branch? (Do not pull request for **master** branch).
1+
<!--
2+
We highly appreciate your interest and contribution to our project.
3+
Before submiting your PR, please finish the checklist below.
4+
-->
5+
6+
## Checklist
7+
8+
### Which kind of PR do you create?
9+
10+
- [ ] This PR only contains minor fixes.
11+
- [ ] This PR contains major feature update.
12+
- [ ] This PR introduces a new function/api for Qiling Framework.
13+
14+
### Coding convention?
15+
16+
- [ ] The new code conforms to Qiling Framework naming convention.
17+
- [ ] The imports are arranged properly.
18+
- [ ] Essential comments are added.
19+
- [ ] The reference of the new code is pointed out.
20+
21+
### Extra tests?
22+
23+
- [ ] No extra tests are needed for this PR.
24+
- [ ] I have added enough tests for this PR.
25+
- [ ] Tests will be added after some discussion and review.
26+
27+
### Changelog?
28+
29+
- [ ] This PR doesn't need to update Changelog.
30+
- [ ] Changelog will be updated after some proper review.
31+
- [ ] Changelog has been updated in my PR.
32+
33+
### Target branch?
34+
35+
- [ ] The target branch is dev branch.
36+
37+
### One last thing
38+
39+
- [ ] I have read the [contribution guide](https://docs.qiling.io/en/latest/contribution/)
340

441
-----

.github/workflows/build-ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Run tests
2+
on: [push, pull_request]
3+
env:
4+
CI: true
5+
jobs:
6+
tests:
7+
runs-on: ${{ matrix.os }}
8+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [windows-2019, macos-10.15, ubuntu-18.04, ubuntu-20.04]
13+
python-version: [3.6.8, 3.7.6]
14+
exclude:
15+
- os: windows-2019
16+
python-version: 3.7.6
17+
- os: macos-10.15
18+
python-version: 3.7.6
19+
- os: ubuntu-20.04
20+
python-version: 3.7.6
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: win setup MSVC
30+
if: contains(matrix.os, 'windows')
31+
uses: microsoft/setup-msbuild@v1
32+
33+
- name: win run tests
34+
if: contains(matrix.os, 'windows')
35+
shell: bash
36+
run: |
37+
powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableArchiveScanning \$true'"
38+
powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableBehaviorMonitoring \$true'"
39+
powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableRealtimeMonitoring \$true'"
40+
powershell Add-MpPreference -ExclusionPath $GITHUB_WORKSPACE
41+
pip3 install setuptools wheel
42+
pip3 install .
43+
cmd.exe //C 'examples\scripts\dllscollector.bat'
44+
cd $GITHUB_WORKSPACE/examples/rootfs/x86_windows/bin
45+
unzip -Pinfected wannacry.bin.zip
46+
unzip -Pinfected UselessDisk.bin.zip
47+
unzip -Pinfected GandCrab502.bin.zip
48+
unzip -Pinfected al-khaser.bin.zip
49+
unzip -Pinfected sality.dll.zip
50+
cd $GITHUB_WORKSPACE/tests
51+
cmd.exe //C '.\test_pe.bat'
52+
- name: mac run tests
53+
if: contains(matrix.os, 'macos')
54+
continue-on-error: true
55+
shell: bash
56+
run: |
57+
pip3 install setuptools wheel
58+
pip3 install .
59+
./examples/scripts/dylibcollector.sh
60+
cd $GITHUB_WORKSPACE/examples/rootfs/x8664_macos/kext
61+
unzip -Pinfected SuperRootkit.kext.zip
62+
cd $GITHUB_WORKSPACE/tests
63+
./test_macho.sh
64+
- name: linux run tests
65+
if: contains(matrix.os, 'ubuntu')
66+
shell: 'script -q -e -c "bash {0}"'
67+
run: |
68+
if [ ${{ matrix.os }} == 'ubuntu-18.04' ] && [ ${{ matrix.python-version }} == '3.7.6' ]; then
69+
pip3 install setuptools wheel flake8
70+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
71+
pip3 install .
72+
cd tests && ./test_elf.sh
73+
elif [ ${{ matrix.os }} == 'ubuntu-20.04' ]; then
74+
docker run -it --rm -v ${GITHUB_WORKSPACE}:/qiling qilingframework/qiling:dev bash -c "pip3 install . && cd tests && ./test_elf.sh"
75+
else
76+
pip3 install setuptools wheel
77+
pip3 install .
78+
cd tests && ./test_elf.sh
79+
fi

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ test.file
3232
*.o
3333
core
3434
*.perf
35+
examples/rootfs/x86_windows/Windows/registry
36+
examples/rootfs/x8664_windows/Windows/registry

.travis.yml

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@ language: shell
22
matrix:
33
fast_finish: true
44
include:
5-
- name: "Python 3.6 on Linux"
6-
os: linux
7-
dist: bionic
8-
language: python
9-
python: "3.6"
10-
cache: pip
11-
install:
12-
- pip3 install .
13-
before_script:
14-
- cd tests
15-
script:
16-
- ./test_elf.sh
17-
18-
- name: "Python 3.7 on Linux"
19-
os: linux
20-
dist: bionic
21-
language: python
22-
python: "3.7"
23-
cache: pip
24-
install:
25-
- pip3 install flake8
26-
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27-
- pip3 install .
28-
before_script:
29-
- cd tests
30-
script:
31-
- ./test_elf.sh
32-
335
- name: "Python 3.7 on OSX"
346
os: osx
357
osx_image: xcode10.1
@@ -61,101 +33,3 @@ matrix:
6133
script:
6234
- ./test_macho.sh
6335

64-
- name: "Python 3.6.8 on Windows"
65-
os: windows
66-
language: shell
67-
env:
68-
- PATH="/c/Python36:/c/Python36/Scripts:$PATH"
69-
cache:
70-
directories:
71-
# - $HOME/AppData/Local/Temp/chocolatey
72-
- $HOME/AppData/Local/pip/Cache
73-
- /c/Python36
74-
# - $HOME/AppData/Local/NuGet/Cache
75-
before_install:
76-
- |
77-
if [[ ! -f /c/Python36/python ]]; then
78-
choco install python --version=3.6.8
79-
fi
80-
# Prevent worker settings failure
81-
- powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableArchiveScanning \$true'"
82-
- powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableBehaviorMonitoring \$true'"
83-
- powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableRealtimeMonitoring \$true'"
84-
#- choco install kb2999226
85-
#- python -m pip install --upgrade pip
86-
install:
87-
# - pip3 install wheel 'capstone>=4.0.1' 'pefile>=2019.4.18' 'python-registry>=1.3.1' 'unicorn>=1.0.2rc3'
88-
# - |
89-
# if [ ! -f $HOME/dist/keystone*.zip ]; then
90-
# git clone https://github.com/keystone-engine/keystone && \
91-
# cd keystone && \
92-
# mkdir build && \
93-
# cd build && \
94-
# cmd.exe //C 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat' amd64 '&' cmd.exe //C '..\nmake-dll.bat' '&&' nmake instalL && \
95-
# cd ../bindings/python && \
96-
# python setup.py install && \
97-
# python setup.py bdist --formats=zip && \
98-
# cp dist/*.zip $HOME/dist/ && \
99-
# cp /c/Program\ Files\ \(x86\)/keystone/lib/keystone.dll /c/Python36/Lib/site-packages/keystone/ && \
100-
# cp /c/Program\ Files\ \(x86\)/keystone/lib/keystone.dll $HOME/dist/;
101-
# else
102-
# unzip $HOME/dist/*.zip -d /c && \
103-
# cp $HOME/dist/keystone.dll /c/Python36/Lib/site-packages/keystone/;
104-
# fi
105-
- cd $TRAVIS_BUILD_DIR
106-
- pip3 install .
107-
# - cp /c/Program\ Files\ \(x86\)/keystone/lib/keystone.dll /c/Python36/Lib/site-packages/keystone/
108-
before_script:
109-
- cmd.exe //C 'examples\scripts\dllscollector.bat'
110-
- cd $TRAVIS_BUILD_DIR/examples/rootfs/x86_windows/bin
111-
- unzip -Pinfected wannacry.bin.zip
112-
- unzip -Pinfected UselessDisk.bin.zip
113-
- unzip -Pinfected GandCrab502.bin.zip
114-
- unzip -Pinfected al-khaser.bin.zip
115-
- unzip -Pinfected sality.dll.zip
116-
- cd $TRAVIS_BUILD_DIR/tests
117-
script:
118-
- cmd.exe //C '.\test_pe.bat'
119-
120-
- name: "Python 3.6 on Docker"
121-
services:
122-
- docker
123-
# cache:
124-
# bundler: true
125-
# directories:
126-
# - $HOME/docker
127-
before_script:
128-
# - docker build -t qiling:1.1 .
129-
# - docker load -i $HOME/docker/images.tar || true
130-
# - |
131-
# if [[ ! $(docker images -q qiling:1.1) ]]; then
132-
# docker build -t qiling:1.1 . && docker save -o $HOME/docker/images.tar qiling:1.1;
133-
# fi
134-
# - docker run -dt --name qiling -v ${TRAVIS_BUILD_DIR}:/qiling qiling:1.1
135-
# - docker exec qiling pip3 install -r requirements.txt
136-
# - docker exec qiling python3 setup.py install
137-
script:
138-
- docker run -it --rm -v ${TRAVIS_BUILD_DIR}:/qiling qilingframework/qiling:dev bash -c "pip3 install . && cd tests && ./test_elf.sh"
139-
# - docker exec qiling bash -c "cd tests && ./test_elf.sh"
140-
141-
# - name: "Python 3.6 on WSL1 Ubuntu"
142-
# os: windows
143-
# language: shell
144-
# before_install:
145-
# - choco install wsl-ubuntu-1804
146-
# - wsl apt update
147-
# - wsl DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y
148-
# - wsl DEBIAN_FRONTEND=noninteractive apt install -y python3-pip cmake
149-
# - wsl pip3 install --upgrade pip
150-
# install:
151-
# - wsl pip3 install -r requirements.txt
152-
# - wsl python3 setup.py install
153-
# before_script:
154-
# - MSYS_NO_PATHCONV=1 wsl cp $(wsl python3 -c "import site; print(site.getsitepackages()[0])")$(wsl python3 -c "import site; print(site.getsitepackages()[1])")/keystone/libkeystone.so $(wsl python3 -c "import site; print(site.getsitepackages()[0])")/keystone/
155-
# - cd tests
156-
# script:
157-
# - wsl python3 test_all.py
158-
159-
# allow_failures:
160-
# - os: osx
161-
# - services: docker

CREDITS.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ iamyeh
4949
alfink
5050
bambu
5151
bkerler (viperbjk)
52+
Mark Jansen (learn-more)
53+
cq674350529
5254

5355
Alpha testers (in no particular order, named by github id)
5456
==========================================================

ChangeLog

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
This file details the changelog of Qiling Framework.
22

3+
------------------------------------
4+
BREAK CHANGE
5+
- ql.multithread can be only set during Qiling.__init__ now.
6+
- ql.nprint and ql.dpring is depreciated. Please use logging directly instead.
7+
- ql.filename is renamed to ql.argv.
8+
- ql.output and ql.verbose now has slightly different meanings and can be adjusted runtime. See their docstring for details.
9+
- ql.filter now accepts a regular expression.
10+
311
------------------------------------
412
[Version 1.2.1]: December [SOMETHING], 2020
5-
-
13+
14+
- Added support for custom envs variables inside IDA plugin
15+
- Demigod: Fixed lkm mapping and added support for MIPS32EL
16+
- Demigod: Added support for Linux x86 32bit
17+
- Added support for binaries that return from their entrypoint (PE / ELF).
18+
- Configure Qiling with 'stop_on_stackpointer' or 'stop_on_exit_trap'.
19+
- Add basic Windows driver tests / example
20+
- UEFI refactor
21+
622

723
------------------------------------
824
[Version 1.2]: November 16th, 2020
@@ -20,7 +36,7 @@ This file details the changelog of Qiling Framework.
2036

2137

2238
------------------------------------
23-
[Version 1.1.3]: September 30, 2020
39+
[Version 1.1.3]: September 30th, 2020
2440

2541
- Added Doogie example and implement more interrupts
2642
- Added ollvm de-flattern support for IDA plugin

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ COPY --from=builder /qiling /qiling
1919
WORKDIR /qiling
2020

2121
RUN apt-get update \
22-
&& apt-get install -y libmagic-dev \
2322
&& rm -rf /var/lib/apt/lists/* \
2423
&& pip3 install wheels/*.whl \
2524
&& rm -rf wheels

examples/doogie_8086_crack.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
# Built on top of Unicorn emulator (www.unicorn-engine.org)
55

6-
import sys, curses, math, struct, string, time
6+
import sys, curses, math, struct, string, time, logging
77
sys.path.append("..")
88
from qiling import *
99
from qiling.const import *
@@ -129,11 +129,11 @@ def show_once(ql: Qiling, key):
129129
# In this stage, we show every key.
130130
def third_stage(keys):
131131
# To setup terminal again, we have to restart the whole program.
132-
ql = Qiling(["rootfs/8086/doogie/doogie.bin"],
132+
ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"],
133133
"rootfs/8086",
134134
console=False,
135135
log_dir=".")
136-
ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.bin", 0x80))
136+
ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.DOS_MBR", 0x80))
137137
ql.set_api((0x1a, 4), set_required_datetime, QL_INTERCEPT.EXIT)
138138
hk = ql.hook_code(stop, begin=0x8018, end=0x8018)
139139
ql.run()
@@ -172,7 +172,7 @@ def read_until_zero(ql: Qiling, addr):
172172
return buf
173173

174174
def set_required_datetime(ql: Qiling):
175-
ql.nprint("Setting Feburary 06, 1990")
175+
logging.info("Setting Feburary 06, 1990")
176176
ql.reg.ch = BIN2BCD(19)
177177
ql.reg.cl = BIN2BCD(1990%100)
178178
ql.reg.dh = BIN2BCD(2)
@@ -183,11 +183,11 @@ def stop(ql, addr, data):
183183

184184
# In this stage, we get the encrypted data which xored with the specific date.
185185
def first_stage():
186-
ql = Qiling(["rootfs/8086/doogie/doogie.bin"],
186+
ql = Qiling(["rootfs/8086/doogie/doogie.DOS_MBR"],
187187
"rootfs/8086",
188188
console=False,
189189
log_dir=".")
190-
ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.bin", 0x80))
190+
ql.add_fs_mapper(0x80, QlDisk("rootfs/8086/doogie/doogie.DOS_MBR", 0x80))
191191
# Doogie suggests that the datetime should be 1990-02-06.
192192
ql.set_api((0x1a, 4), set_required_datetime, QL_INTERCEPT.EXIT)
193193
# A workaround to stop the program.

examples/hello_arm_linux_custom_syscall.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ def my_syscall_write(ql, write_fd, write_buf, write_count, *args, **kw):
1414

1515
try:
1616
buf = ql.mem.read(write_buf, write_count)
17-
ql.nprint("\n+++++++++\nmy write(%d,%x,%i) = %d\n+++++++++" % (write_fd, write_buf, write_count, regreturn))
17+
logging.info("\n+++++++++\nmy write(%d,%x,%i) = %d\n+++++++++" % (write_fd, write_buf, write_count, regreturn))
1818
ql.os.fd[write_fd].write(buf)
1919
regreturn = write_count
2020
except:
2121
regreturn = -1
22-
ql.nprint("\n+++++++++\nmy write(%d,%x,%i) = %d\n+++++++++" % (write_fd, write_buf, write_count, regreturn))
22+
logging.info("\n+++++++++\nmy write(%d,%x,%i) = %d\n+++++++++" % (write_fd, write_buf, write_count, regreturn))
2323
if ql.output in (QL_OUTPUT.DEBUG, QL_OUTPUT.DUMP):
2424
raise
2525

26-
ql.os.definesyscall_return(regreturn)
26+
return regreturn
2727

2828

2929
if __name__ == "__main__":

examples/hello_arm_linux_debug.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def run_sandbox(path, rootfs, output):
1212
ql.multithread = False
1313
ql.debugger = "qdb:rr" # switch on record and replay with rr
1414
# ql.debugger = "qdb:" # enable qdb without options
15+
# ql.debugger = "qdb:0x1030c" # enable qdb and setup breakpoin at 0x1030c
1516
ql.run()
1617

1718

0 commit comments

Comments
 (0)