Skip to content

Commit

Permalink
Epoll Implementation (#2529)
Browse files Browse the repository at this point in the history
* Use my capstone dev branch until fixes are merged into next

* Fix aarch64

* Fix ARM

* Update Capstone commit to fix arm64 LD1 instruction immediates

* Ignore coverage tracking for defensive assertions and exceptions

* ENDBR64 as nop

* Add lacking x86 tests

* New x86 instrution test

* Disable write back once we hit our stop in Unicorn emulation

* Make emulator reinitialize after write backs are disabled

* Fix linting on test_general

Extremely strange that my local black==19.10b0 doesn't catch this, but the one on GH actions does

* Add a Rust/Unicorn resumption test

* Make rusticorn binary actually check behavior

* Run CI on chess branch

* Support for pread64 syscall

* Delete duplicated test method

* Fix addresses and improve error handling

* Fix issue with sphinx autodoc

Sphinx doesn't handle side-effects of importing

* Add last_executed_pc property to abstract CPU

Helpful for knowing the exact last executed instruction address.

* Optionally skip publishing mem read/writes in CPU

* Shallow copy AMD64RegFile but keep concrete register values

The copied RegisterFile should be read-only and used to keep track of
concrete register values at a certain instant

* Remove call to pkg_resources that breaks custom installation

* Fix mypy

* Fix Unicorn resume

* Update unicorn to latest 1.0.2

* Update capstone to latest 4.0.2

* Correctly process memory maps

* Synchronize data from manticore to unicorn upon resume

* Fix some issues with FS register and segments

* Fix some synchronization with CPUID instruction as compared to Unicorn

* X86 syscall instruction breakout for semantics

* Implementation of epoll

* Fix test missed during merge

* Fix more tests missed during merge

* staticmethods to get syscall info

* Revert some unrelated changes

* Revert more unrelated changes

* Revert MORE unrelated changes

* Unstage changes to ARM/x86 CPUs

* Remove fast_crash parameter (unrelated to this PR)

* Add tests

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
Co-authored-by: feliam <felipe.andres.manzano@gmail.com>
  • Loading branch information
3 people committed Feb 17, 2022
1 parent a50b856 commit 49f7ebc
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 26 deletions.
16 changes: 16 additions & 0 deletions manticore/native/plugins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import types

from ..core.plugin import Plugin
from .state_merging import merge_constraints, is_merge_possible, merge
import logging
Expand Down Expand Up @@ -125,3 +127,17 @@ def will_load_state_callback(self, current_state_id):
# UGLY we are replacing a state_id. This may be breaking caches in
# the future
self.replace_state(current_state_id, merged_state)


class SyscallCounter(Plugin):
def will_execute_syscall_callback(self, state, model):
name = model.__func__.__name__ if isinstance(model, types.MethodType) else model.__name__
with self.locked_context("syscall_counts", dict) as counts:
counts[name] = counts.get(name, 0) + 1

def get_counts(self):
with self.locked_context("syscall_counts", dict) as ctx:
return ctx

def did_run_callback(self):
logger.info("Syscalls executed: %s", self.get_counts())

0 comments on commit 49f7ebc

Please sign in to comment.