Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic maintenance PR #1336

Merged
merged 42 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c006864
Remove unnecessary property elf_emu_start
elicn Mar 10, 2023
28e1f33
Fix unsafe ELF interpreter loading
elicn Mar 10, 2023
f6200ac
Fix wrapper decoration
elicn Mar 10, 2023
4b4ed62
Reduce module dependencies
elicn Mar 10, 2023
b9f61a9
Have gdbserver report back Uc errors
elicn Mar 10, 2023
c89b43a
Opportunistic PEP8 fixes
elicn Mar 10, 2023
c67a64e
Properly load QNS profile values
elicn Mar 10, 2023
5e9738c
Minor code rearrangements in gdb
elicn Mar 10, 2023
f58c494
Revamp FS mapper
elicn Mar 27, 2023
263d523
Revamp POSIX fcntl
elicn Mar 27, 2023
5aedbaf
Fix close_on_exec type
elicn Mar 27, 2023
8261039
Avoid overwriting custom procfs mappings
elicn Mar 30, 2023
b8c78c6
Turned close_on_exec into a simple member
elicn Mar 30, 2023
0fd6209
Added closed property to ql_file
elicn Mar 30, 2023
056969f
Patched unistd functions
elicn Mar 30, 2023
0be4620
Patched fcntl functions
elicn Mar 30, 2023
2430578
Patched some stat functions
elicn Mar 30, 2023
63c92f1
Fix a bug in FindFirstFileA
elicn Mar 30, 2023
629454f
Re-implemented POSIX shm syscalls
elicn Apr 2, 2023
e76b8ab
Partialy implemented POSIX IPC syscall
elicn Apr 2, 2023
2347a9b
Adjust ELF shellcode tests
elicn Apr 3, 2023
3266680
Allow shellcode execve fail gracefully
elicn Apr 3, 2023
d9ff19d
Patch POSIX execve
elicn Apr 3, 2023
b3de208
Prevent emulation from closing host std streams
elicn Apr 3, 2023
32a8588
Insignificant styling and typo fixes
elicn Apr 3, 2023
48cc58d
Properly set emu_state
elicn Apr 4, 2023
c069a10
Collect new vcruntime140 DLLs
elicn Apr 4, 2023
412bcaf
Use yaml safe loader
elicn Apr 4, 2023
85430f0
Use mmap min address for shm allocations
elicn Apr 7, 2023
06cd3f0
Typo bugfix
elicn Apr 7, 2023
0dd8545
Re-implement POSIX shm
elicn Apr 13, 2023
817bdb7
Add POSIX shmdt syscall
elicn Apr 13, 2023
a95b22b
Make argv and code mutually exclusive
elicn Apr 14, 2023
609ea31
Opportunistic PEP8 fixes
elicn Apr 14, 2023
717899b
Decouple runtime dependencies
elicn Apr 14, 2023
ace56d8
Rearrange and fix ELF MT test suite
elicn Apr 16, 2023
073950a
Fix bugs in IPv6 socket impl
elicn Apr 23, 2023
062bb57
Remove unused log colors
elicn Apr 28, 2023
26e4786
Switch back to default color instead reset entirely
elicn Apr 28, 2023
45056c9
Adhere to the NO_COLOR convention
elicn Apr 28, 2023
8a364a5
Slightly optimize logging for speed
elicn Apr 28, 2023
4c53a43
Handle fds that lack the close_on_exec property
elicn Apr 28, 2023
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: 2 additions & 0 deletions examples/scripts/dllscollector.bat
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ CALL :collect_dll64 shlwapi.dll
CALL :collect_dll64 user32.dll
CALL :collect_dll64 vcruntime140.dll
CALL :collect_dll64 vcruntime140d.dll
CALL :collect_dll64 vcruntime140_1.dll
CALL :collect_dll64 vcruntime140_1d.dll
CALL :collect_dll64 win32u.dll
CALL :collect_dll64 winhttp.dll
CALL :collect_dll64 wininet.dll
Expand Down
32 changes: 21 additions & 11 deletions qiling/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
class Qiling(QlCoreHooks, QlCoreStructs):
def __init__(
self,
argv: Sequence[str] = None,
argv: Sequence[str] = [],
rootfs: str = r'.',
env: MutableMapping[AnyStr, AnyStr] = {},
code: bytes = None,
code: Optional[bytes] = None,
ostype: Union[str, QL_OS] = None,
archtype: Union[str, QL_ARCH] = None,
verbose: QL_VERBOSE = QL_VERBOSE.DEFAULT,
Expand Down Expand Up @@ -90,18 +90,26 @@ def __init__(
##############
# argv setup #
##############
if argv is None:
argv = ['qilingcode']
if argv:
if code:
raise AttributeError('argv and code are mutually execlusive')

elif not os.path.exists(argv[0]):
raise QlErrorFileNotFound(f'Target binary not found: "{argv[0]}"')
target = argv[0]

if not os.path.isfile(target):
raise QlErrorFileNotFound(f'Target binary not found: "{target}"')
else:
# an empty argv list means we are going to execute a shellcode. to keep
# the 'path' api compatible, we insert a dummy placeholder

argv = ['']

self._argv = argv

################
# rootfs setup #
################
if not os.path.exists(rootfs):
if not os.path.isdir(rootfs):
raise QlErrorFileNotFound(f'Target rootfs not found: "{rootfs}"')

self._rootfs = rootfs
Expand Down Expand Up @@ -697,11 +705,11 @@ def restore(self, saved_states: Mapping[str, Any] = {}, *, snapshot: Optional[st

# Map "ql_path" to any objects which implements QlFsMappedObject.
def add_fs_mapper(self, ql_path: Union["PathLike", str], real_dest):
self.os.fs_mapper.add_fs_mapping(ql_path, real_dest)
self.os.fs_mapper.add_mapping(ql_path, real_dest)

# Remove "ql_path" mapping.
def remove_fs_mapper(self, ql_path: Union["PathLike", str]):
self.os.fs_mapper.remove_fs_mapping(ql_path)
self.os.fs_mapper.remove_mapping(ql_path)

# push to stack bottom, and update stack register
def stack_push(self, data):
Expand Down Expand Up @@ -757,14 +765,16 @@ def emu_start(self, begin: int, end: int, timeout: int = 0, count: int = 0):
if getattr(self.arch, '_init_thumb', False):
begin |= 0b1

self._state = QL_STATE.STARTED

# reset exception status before emulation starts
self._internal_exception = None

self._state = QL_STATE.STARTED

# effectively start the emulation. this returns only after uc.emu_stop is called
self.uc.emu_start(begin, end, timeout, count)

self._state = QL_STATE.STOPPED

# if an exception was raised during emulation, propagate it up
if self.internal_exception is not None:
raise self.internal_exception
Loading