Skip to content

Commit add8e5c

Browse files
committed
keep update with dev
2 parents 98fab15 + 33a2b6d commit add8e5c

File tree

117 files changed

+2943
-2378
lines changed

Some content is hidden

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

117 files changed

+2943
-2378
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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/)
40+
41+
-----

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
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
513

TODO

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,4 @@
1-
*nix
2-
=====
3-
- More *nix based syscall
4-
5-
iOS
6-
===
7-
- Partially completed. Did not test against any actual iOS binary yet
8-
9-
FreeBSD
10-
=======
11-
Current Status: only work with assembler compiled binary
12-
- gcc compiled static binary
13-
- Dynamically compiled binary
14-
15-
Windows
16-
=======
17-
- ARM64 Windows
18-
- More Windows API
19-
- API for PC name, WINS, WORKGOUP and Domains
20-
- API for fake installed application
21-
- API for process listing
22-
23-
Debugging Server
24-
================
25-
- Add GDB stub commands
26-
27-
USB
28-
===
29-
- Emulate USB
30-
31-
-------------------- FUTURE --------------------
32-
33-
MCU
34-
===
35-
- STM32 Series?
36-
37-
Blockchain
38-
==========
39-
- Smart contract emulator?
40-
41-
Android
42-
======
43-
- It's Linux, but a bit more specific support ?
44-
- maybe an OS by itself
45-
1+
Features request and TODO please refer to issue 333 https://github.com/qilingframework/qiling/issues/333
462

473
-------------------- CHECKLIST before TAG --------------------
484
Release

examples/doogie_8086_crack.py

Lines changed: 2 additions & 2 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 *
@@ -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)

examples/hello_arm_linux_custom_syscall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ 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

examples/hello_x8664_windows_customapi.py

Lines changed: 2 additions & 2 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
6+
import sys, logging
77
sys.path.append("..")
88

99
from qiling import *
@@ -16,7 +16,7 @@
1616
@winsdkapi(cc=CDECL, replace_params={"str": STRING})
1717
def my_puts(ql, address, params):
1818
ret = 0
19-
ql.nprint("\n+++++++++\nmy random Windows API\n+++++++++\n")
19+
logging.info("\n+++++++++\nmy random Windows API\n+++++++++\n")
2020
string = params["str"]
2121
ret = len(string)
2222
return ret

examples/hfs_mbr_crack.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from qiling.const import QL_INTERCEPT
2+
from qiling import Qiling
3+
import curses, logging
4+
5+
def input_index(ql: Qiling):
6+
return ql.unpack16(ql.mem.read(0x81ba, 2))
7+
8+
def target(ql: Qiling):
9+
return ql.unpack16(ql.mem.read(0x81bb, 2))
10+
11+
def stop(ql, b, c):
12+
ql.emu_stop()
13+
14+
def find_once(ql: Qiling, ch):
15+
old = target(ql)
16+
ql.reg.al = ch
17+
h1 = ql.hook_code(stop, begin=0x8004, end=0x8004) # Fail
18+
h2 = ql.hook_code(stop, begin=0x7fea, end=0x7fea) # Success
19+
h3 = ql.hook_code(stop, begin=0x7e37, end=0x7e37)
20+
ql.run(begin=0x7e3d)
21+
ql.hook_del(h1)
22+
ql.hook_del(h2)
23+
ql.hook_del(h3)
24+
new = target(ql)
25+
if new > old:
26+
return True
27+
else:
28+
return False
29+
30+
def find_next(ql: Qiling):
31+
ctx = ql.save()
32+
ctx_succ = None
33+
results = []
34+
for i in range(0x61, 0x7a + 1):
35+
if find_once(ql, i):
36+
results.append(i)
37+
ctx_succ = ql.save()
38+
ql.restore(ctx)
39+
if ctx_succ is None:
40+
logging.info("Can't find any suitbale result.")
41+
return None
42+
ql.restore(ctx_succ)
43+
return results
44+
45+
def print_flags(results):
46+
def _impl(fl, idx, results):
47+
if idx == len(results):
48+
print(f"flag: {fl}")
49+
else:
50+
for ch in results[idx]:
51+
_impl(fl + ch, idx + 1, results)
52+
curses.echo()
53+
curses.nocbreak()
54+
curses.endwin()
55+
return _impl("", 0, results)
56+
57+
def main():
58+
flag = ""
59+
results = []
60+
ql = Qiling(["rootfs/8086/dos/hfs.img"], rootfs="rootfs/8086", console=False, log_dir=".", output="off")
61+
h = ql.hook_code(stop, begin=0x7e3b, end=0x7e3b)
62+
ql.run()
63+
ql.hook_del(h)
64+
ql.reg.ip = 0x7e3d
65+
for i in range(9):
66+
r = find_next(ql)
67+
if r is None:
68+
logging.info("Fail to crack.")
69+
return
70+
else:
71+
r = list(map(lambda x: chr(x), r))
72+
logging.info(f"Get {r}")
73+
results.append(r)
74+
print_flags(results)
75+
76+
if __name__ == "__main__":
77+
main()

examples/multithreading_arm64_linux.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from qiling import *
99

1010
def my_sandbox(path, rootfs):
11-
ql = Qiling(path, rootfs, output = "debug")
12-
ql.multithread = True
11+
ql = Qiling(path, rootfs, output = "debug", multithread=True)
1312
ql.run()
1413

1514

examples/rootfs/8086/dos/hfs.img

10 MB
Binary file not shown.

examples/sality.py

Lines changed: 4 additions & 2 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 struct, sys
6+
import struct, sys, logging
77

88
sys.path.append("..")
99
from qiling import *
@@ -105,6 +105,7 @@ def sality_WriteFile(ql, address, params):
105105
r, nNumberOfBytesToWrite = ql.amsint32_driver.os.io_Write(buffer)
106106
ql.mem.write(lpNumberOfBytesWritten, ql.pack32(nNumberOfBytesToWrite))
107107
except Exception as e:
108+
logging.exception("")
108109
print("Exception = %s" % str(e))
109110
r = 1
110111
if r:
@@ -143,6 +144,7 @@ def sality_StartServiceA(ql, address, params):
143144
else:
144145
return 1
145146
except Exception as e:
147+
logging.exception("")
146148
print (e)
147149

148150

@@ -169,7 +171,7 @@ def hook_stop_address(ql):
169171
ql.os.set_function_args([0])
170172
ql.hook_address(hook_stop_address, 0x4055FA)
171173
ql.run(0x4053B2)
172-
ql.nprint("[+] test kill thread")
174+
logging.info("[+] test kill thread")
173175
if ql.amsint32_driver:
174176
ql.amsint32_driver.os.io_Write(struct.pack("<I", 0xdeadbeef))
175177
ql.amsint32_driver.hook_address(hook_stop_address, 0x10423)

0 commit comments

Comments
 (0)