Angr
Learn & practice AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Part of this cheatsheet is based on the angr documentation.
Installation
sudo apt-get install python3-dev libffi-dev build-essential
python3 -m pip install --user virtualenv
python3 -m venv ang
source ang/bin/activate
pip install angrBasic Actions
import angr
import monkeyhex # this will format numerical results in hexadecimal
#Load binary
proj = angr.Project('/bin/true')
#BASIC BINARY DATA
proj.arch #Get arch "<Arch AMD64 (LE)>"
proj.arch.name #'AMD64'
proj.arch.memory_endness #'Iend_LE'
proj.entry #Get entrypoint "0x4023c0"
proj.filename #Get filename "/bin/true"
#There are specific options to load binaries
#Usually you won't need to use them but you could
angr.Project('examples/fauxware/fauxware', main_opts={'backend': 'blob', 'arch': 'i386'}, lib_opts={'libc.so.6': {'backend': 'elf'}})Loaded and Main object information
Loaded Data
Main Object
Symbols and Relocations
Blocks
Dynamic Analysis
Simulation Manager, States
Calling functions
You can pass a list of arguments through
argsand a dictionary of environment variables throughenvintoentry_stateandfull_init_state. The values in these structures can be strings or bitvectors, and will be serialized into the state as the arguments and environment to the simulated execution. The defaultargsis an empty list, so if the program you're analyzing expects to find at least anargv[0], you should always provide that!If you'd like to have
argcbe symbolic, you can pass a symbolic bitvector asargcto theentry_stateandfull_init_stateconstructors. Be careful, though: if you do this, you should also add a constraint to the resulting state that your value for argc cannot be larger than the number of args you passed intoargs.To use the call state, you should call it with
.call_state(addr, arg1, arg2, ...), whereaddris the address of the function you want to call andargNis the Nth argument to that function, either as a python integer, string, or array, or a bitvector. If you want to have memory allocated and actually pass in a pointer to an object, you should wrap it in an PointerWrapper, i.e.angr.PointerWrapper("point to me!"). The results of this API can be a little unpredictable, but we're working on it.
BitVectors
Symbolic BitVectors & Constraints
Hooking
Furthermore, you can use proj.hook_symbol(name, hook), providing the name of a symbol as the first argument, to hook the address where the symbol lives
Examples
Learn & practice AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Last updated