-
Notifications
You must be signed in to change notification settings - Fork 478
Hacking on Manticore
Yan edited this page May 11, 2017
·
21 revisions
as of a0717aa661c0b04d5f73879b265da4da05756630
To implement a Linux syscall:
- Look up the name of your syscall in
manticore/platforms/linux_syscalls.py
to get the correct name of your syscall for the corresponding syscall number. - In
manticore/platforms/linux.py
, add a method to theSLinux
(Symbolic Linux) class for your syscall. Name your method precisely the name above. The arguments to this method should be- 1:
self
(standard Python self variable) - 2:
cpu
(manticore.core.abstractcpu.Cpu
object representing current cpu state) - 3+: arguments to the syscall
- 1:
- Implement the logic of the syscall in this method, using the
Cpu
APIs as needed - The method should return the value returned by the syscall
as of c78ea5c9109191654d26c7bfd2bedd662dafcdc5
To implement a cpu instruction:
- Open the file according to the architecture for this instruction
- x86 is in
manticore/core/cpu/x86.py
- armv7 is in
manticore/core/cpu/arm.py
- x86 is in
- Add a method to the Cpu class in either of those files that subclasses
Cpu
- Decorate it with the
@instruction
decorator - The arguments to the method should be
- 1:
self
- 2+ one argument for every operand in
instruction.operands
as decoded by Capstone. The types of these arguments aremanticore.core.abstractcpu.Operand
which is a light wrapper over a Capstone operand object (e.g. ArmOp)) and notably support convenience.read
and.write
methods.
- 1:
- Decorate it with the
- Implement the instruction's effects
manticore/
├── binary # code related to binary formats. ignore this
│ ├── grr
│ │ ├── __init__.py
│ │ └── snapshot.py
│ ├── __init__.py
│ └── pe
│ ├── __init__.py
│ └── minidump.py
├── core
│ ├── cpu # code implementing symbolic emulators
│ │ ├── abstractcpu.py
│ │ ├── arm.py
│ │ ├── bitwise.py
│ │ ├── cpufactory.py
│ │ ├── __init__.py
│ │ ├── register.py
│ │ └── x86.py
│ ├── executor.py # main symbolic execution file
│ ├── __init__.py
│ ├── mappings.py
│ ├── memory.py
│ ├── parser
│ │ ├── __init__.py
│ │ └── parser.py
│ ├── smtlib # code related to handling symbolic data
│ │ ├── constraints.py #
│ │ ├── expression.py # defines symbolic data types
│ │ ├── __init__.py
│ │ ├── operators.py # library of operators for transparently handling concrete or symbolic data
│ │ ├── solver.py # code for interacting with the SMT solver
│ │ └── visitors.py # code for transforming expression trees, including serializing to SMTLIB
│ └── state.py # defines type for program state
├── __init__.py
├── __main__.py
├── manticore.py # high level API object
├── platforms # operating system models implemented here
│ ├── cgcrandom.py
│ ├── decree.py
│ ├── __init__.py
│ ├── libc.py
│ ├── linux.py
│ ├── windows.py
│ └── windows_syscalls.py
└── utils
├── emulate.py # code integrating unicorn for emulation of unimplemented instructions
├── event.py
├── helpers.py
├── __init__.py
├── iterpickle.py
└── nointerrupt.py