1. Check arch: proj.arch #查看架构 2. Check entry: proj.entry #查看程序入口 3. See Name : proj.filename #查看文件名字
To Load: proj.loader
We can do these things with proj.loader
1 2 3 4 5 6
1. See Shared_objects: proj.loader.shared_objects 2. See min_addr: proj.loader.min_addr 3. see max_addr: proj.loader.max_addr 4. See main_object: proj.loader.main_object # 主要对象 5. Check the binary have an executable stack: proj.loader.main_object.execstack 6. Check this binary position-independent : proj.loader.main_object.pic
The Factory
There are a lot of classes in angr, and most of them require a project to be instantiated. Instead of making you pass around the project everywhere, we provide project.factory, which has several convenient constructors for common objects you’ll want to use frequently.
1. To see all the instructions: block.pp() out: 0x401670: xor ebp, ebp 0x401672: mov r9, rdx 0x401675: pop rsi 0x401676: mov rdx, rsp 0x401679: and rsp, 0xfffffffffffffff0 0x40167d: push rax 0x40167e: push rsp 0x40167f: lea r8, [rip + 0x2e2a] 0x401686: lea rcx, [rip + 0x2db3] 0x40168d: lea rdi, [rip - 0xd4] 0x401694: call qword ptr [rip + 0x205866] 2.The number of the instructions:block.instructions 3.The address of the instructions: block.instrutions_addr out:[0x401670, 0x401672, 0x401675, 0x401676, 0x401679, 0x40167d, 0x40167e, 0x40167f, 0x401686, 0x40168d, 0x401694]
State: state = proj.factory.entry_state()
Some Examples:
Here’s another fact about angr - the Project object only represents an “initialization image” for the program. When you’re performing execution with angr, you are working with a specific object representing a simulated program state - a SimState. Let’s grab one right now!
state = proj.factory.entry_state() <SimState @ 0x401670>
A SimState contains a program’s memory, registers, filesystem data… any “live data” that can be changed by execution has a home in the state.
一个state包含了很多状态,比如内存、寄存器、各种可能改变的值都会存储在state里面
1 2 3 4 5 6 7 8
1. state.regs.rip # get the current instrucion pointer out: <BV64 0x401670> 2. state.regs.rax out: <BV64 0x1c> 3. state.mem[proj.entry].int.resolved # interpret the memory at the entry point as a C int out: <BV32 0x8949ed31>
# bv -> bitvectors to represent CPU data in angr # Note that each bitvector has a .length property describing how wide it is in bits.
1. bv = state.solver.BVV(0x1234, 32) # create a 32-bit-wide bitvector with value 0x1234 out: <BV32 0x1234> 2. state.solver.eval(bv) # convert to Python int out: 0x1234