Skip to content

Commit fc8c22a

Browse files
authored
Merge branch 'dev' into gdb-improv
2 parents 945f32d + 561f3a8 commit fc8c22a

File tree

17 files changed

+152
-56
lines changed

17 files changed

+152
-56
lines changed

.github/workflows/giteesync.yml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- danielmoos
5555
- sigeryang
5656
- bet4it
57+
- nullableVoidPtr
5758

5859

5960
#### Legacy Core Developers

MANIFEST.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

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

15-
- Emulate multi-platforms: Windows, MacOS, Linux, BSD, UEFI, DOS, MBR, Ethereum Virtual Machine
15+
- Emulate multi-platforms: Windows, MacOS, Linux, Android, BSD, UEFI, DOS, MBR, Ethereum Virtual Machine
1616
- Emulate multi-architectures: 8086, X86, X86_64, ARM, ARM64, MIPS, RISCV, PowerPC
1717
- Support multiple file formats: PE, MachO, ELF, COM, MBR
1818
- Support Windows Driver (.sys), Linux Kernel Module (.ko) & MacOS Kernel (.kext) via [Demigod](https://groundx.io/demigod/)

examples/rootfs

Submodule rootfs updated 115 files

qiling/arch/evm/analysis/signatures.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import os
1+
import inspect
2+
from pathlib import Path
23
import re
34
import logging
45
import json
@@ -92,8 +93,8 @@ def analysis_func_sign(insns:list, engine_num=1):
9293
class signatures_engine_1:
9394
@staticmethod
9495
def find_signature(sign):
95-
path = os.path.split(os.path.realpath(__file__))[0] + '/signatures.json'
96-
with open(path) as data_file:
96+
path = Path(inspect.getfile(inspect.getframe())).parent / 'signatures.json'
97+
with path.open('r') as data_file:
9798
data = json.load(data_file)
9899

99100
list_name = [name for name, hexa in data.items() if hexa == sign]

qiling/os/linux/futex.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,33 @@
1010
from queue import Queue
1111

1212
class QlLinuxFutexManagement:
13-
13+
1414
FUTEX_BITSET_MATCH_ANY = 0xffffffff
15-
15+
1616
def __init__(self):
1717
self._wait_list = {}
18-
18+
1919
@property
2020
def wait_list(self):
2121
return self._wait_list
22-
22+
2323
def futex_wait(self, ql, uaddr, t, val, bitset=FUTEX_BITSET_MATCH_ANY):
24+
EAGAIN = 11
2425
def _sched_wait_event(cur_thread):
2526
ql.log.debug(f"Wait for notifications.")
2627
event.wait()
2728
uaddr_value = ql.unpack32(ql.mem.read(uaddr, 4))
2829
if uaddr_value != val:
2930
ql.log.debug(f"uaddr: {hex(uaddr_value)} != {hex(val)}")
30-
return -1
31+
return -EAGAIN
3132
ql.emu_stop()
3233
if uaddr not in self.wait_list.keys():
3334
self.wait_list[uaddr] = Queue()
3435
event = Event()
3536
self.wait_list[uaddr].put((bitset, t, event))
3637
t.sched_cb = _sched_wait_event
3738
return 0
38-
39+
3940
def get_futex_wake_list(self, ql, addr, number, bitset=FUTEX_BITSET_MATCH_ANY):
4041
wakes = []
4142
if addr not in self.wait_list or number == 0:

qiling/os/posix/syscall/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
from .ioctl import *
88
from .mman import *
99
from .net import *
10+
from .personality import *
1011
from .poll import *
1112
from .prctl import *
1213
from .ptrace import *
14+
from .random import *
1315
from .resource import *
1416
from .sched import *
1517
from .select import *
@@ -25,4 +27,3 @@
2527
from .unistd import *
2628
from .utsname import *
2729
from .wait import *
28-
from .random import *
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
import os
7+
8+
9+
from qiling import Qiling
10+
from qiling.const import *
11+
12+
def ql_syscall_personality(ql: Qiling, persona: int):
13+
regreturn = 0
14+
return regreturn

qiling/os/posix/syscall/resource.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ def setrlimit(self, resource, rlim):
1919
from qiling import Qiling
2020

2121
def __getrlimit_common(ql: Qiling, res: int, rlim: int) -> int:
22-
rlimit = resource.getrlimit(res)
23-
ql.mem.write(rlim, ql.pack32s(rlimit[0]) + ql.pack32s(rlimit[1]))
24-
22+
RLIMIT_STACK = 3
23+
if res == RLIMIT_STACK:
24+
if ql.arch.bits == 64:
25+
stack_size = int(ql.os.profile.get("OS64", "stack_size"), 16)
26+
elif ql.arch.bits == 32:
27+
stack_size = int(ql.os.profile.get("OS32", "stack_size"), 16)
28+
rlimit = (stack_size, -1)
29+
else:
30+
rlimit = resource.getrlimit(res)
31+
ql.mem.write(rlim, ql.pack64s(rlimit[0]) + ql.pack64s(rlimit[1]))
2532
return 0
2633

2734
def ql_syscall_ugetrlimit(ql: Qiling, res: int, rlim: int):
@@ -30,23 +37,29 @@ def ql_syscall_ugetrlimit(ql: Qiling, res: int, rlim: int):
3037
def ql_syscall_getrlimit(ql: Qiling, res: int, rlim: int):
3138
return __getrlimit_common(ql, res, rlim)
3239

33-
def ql_syscall_setrlimit(ql: Qiling, setrlimit_resource: int, setrlimit_rlim: int):
40+
def ql_syscall_setrlimit(ql: Qiling, res: int, rlim: int):
3441
# maybe we can nop the setrlimit
35-
tmp_rlim = (ql.unpack32s(ql.mem.read(setrlimit_rlim, 4)), ql.unpack32s(ql.mem.read(setrlimit_rlim + 4, 4)))
36-
resource.setrlimit(setrlimit_resource, tmp_rlim)
42+
tmp_rlim = (ql.unpack32s(ql.mem.read(rlim, 4)), ql.unpack32s(ql.mem.read(rlim + 4, 4)))
43+
resource.setrlimit(res, tmp_rlim)
3744

3845
return 0
3946

4047
def ql_syscall_prlimit64(ql: Qiling, pid: int, res: int, new_limit: int, old_limit: int):
4148
# setrlimit() and getrlimit()
4249
if pid == 0 and new_limit == 0:
43-
rlim = resource.getrlimit(res)
44-
ql.mem.write(old_limit, ql.packs(rlim[0]) + ql.packs(rlim[1]))
45-
46-
return 0
50+
try:
51+
rlim = resource.getrlimit(res)
52+
ql.mem.write(old_limit, ql.packs(rlim[0]) + ql.packs(rlim[1]))
53+
return 0
54+
except:
55+
return -1
4756

4857
# set other process which pid != 0
4958
return -1
5059

51-
def ql_syscall_getpriority(ql: Qiling, getpriority_which: int, getpriority_who: int):
52-
return os.getpriority(getpriority_which, getpriority_who)
60+
def ql_syscall_getpriority(ql: Qiling, which: int, who: int):
61+
try:
62+
regreturn = os.getpriority(which, who)
63+
except:
64+
regreturn = -1
65+
return regreturn

0 commit comments

Comments
 (0)