_hijack¶
the _hijack module extends some common pwntools features (like tube or ELF) through monkey-patching.
ELF patches¶
ELF.onegadgets(self, level: int = 100) -> list[int]¶
calls the one_gadget tool on the ELF, returns every onegadget at level level, taking into account ELF.address if set.
>>> from dog import *
>>> libc = ELF("./libc.so.6")
>>> libc.onegadgets()
[283167, 283174, 283258, 840051, 840264, 983972, 983984, 987719, 1009648]
>>> libc.onegadgets(0) # default onegadget output
[283258, 983972, 987719]
>>>
>>> libc.address = 0x1234000
>>> libc.onegadgets(0)
[19370618, 20071332, 20075079]
>>>
ELF.gadget(self, asm: str) -> int¶
scans all executable sections for the assembly snippet asm, returns offset if found
@property ELF.binsh(self) -> int¶
shorthand for next(self.search(b"/bin/sh\0")), just find the binsh string and return its address.
@property ELF.orc(self) -> ORC¶
return the ELF as an instance of ORC
@property ELF.sym_obj(self) -> _CVarAccessor¶
like ELF.sym, but return the symbol as a DWARFAddress so you can get the address of values within the struct:
>>> from dog import *
>>> libc = ELF("./libc.so.6")
>>> libc.sym['main_arena']
2112192
>>> int(libc.sym_obj['main_arena'].bins[41])
2112632
>>> int(libc.sym_obj['main_arena'].mutex)
2112192
>>> int(libc.sym_obj['main_arena'].next)
2114352
ELF.resolve_field(self, symbol_name: str, field_path: str | None = None, struct_name: str | None = None) -> int | None¶
same as sym_obj, but you write the field access syntax as a string
>>> from dog import *
>>> libc = ELF("./libc.so.6")
>>> int(libc.resolve_field('main_arena','bins[41]'))
2112632
shorthands¶
ELF.o->ELF.orcELF.symo->ELF.sym_obj
tube patches¶
tube.recvpointer(self) -> int¶
find and return the value of the first %p-style integer printed
>>> from dog import *
>>> p = process("./try")
>>> p.recv()
b'blahblahblahfoo\nhello this is more junk\neven more\n new pointer: 0x7a37e70045c0'
>>> p.unrecv(_)
>>> hex(p.recvpointer())
'0x7a37e70045c0'
todo¶
todo more
shorthands¶
tube.sla->tube.sendlineaftertube.sl->tube.sendlinetube.sa->tube.sendaftertube.s->tube.sendtube.ru->tube.readuntiltube.rl->tube.readlinetube.slc->tube.sendlinecolontube.sc->tube.sendaftercolontube.sic->tube.sendintcolontube.rla->tube.readlineaftertube.rld->tube.readlinecolontube.rud->tube.readuntildroptube.ri->tube.readinttube.rli->tube.readlineinttube.rp->tube.recvpointer