Fix Python2 issues

pull/11/head
Zach Riggle 11 years ago
parent 994afa9aef
commit b15de2359a

@ -11,11 +11,18 @@ Best supported on Ubuntu 14.04 with default `gdb` or `gdb-multiarch` (e.g. with
## Installation
Pretty easy.
1. Clone the repo: `git clone https://github.com/zachriggle/pwndbg`
2. Add to `~/.gdbinit`: `source ~/pwndbg/gdbinit.py`
### Prerequisites
As of recent versions, you need Capstone 4.0.
1. Clone the repo: `git clone https://github.com/aquynh/capstone`
2. Select the `next` branch: `git checkout -t origin/next`
3. Build and install libcapstone: `sudo make.sh install`
4. Build and install Python bindings: `cd bindings/python && python setup.py install`
## Features
Does most things that PEDA does. Doesn't do things that PEDA does that [pwntools](https://github.com/Gallopsled/pwntools) or [binjitsu](https://binjit.su) (my fork of pwntools) do better.

@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gdb
import pwndbg.arch
import pwndbg.arguments
@ -97,3 +99,9 @@ for line in pre_commands.splitlines():
msg = "Loaded %i commands. Type pwndbg for a list." % len(pwndbg.commands._Command.commands)
print(pwndbg.color.red(msg))
@pwndbg.memoize.reset_on_stop
def prompt_hook(*a):
pwndbg.commands.context.context()
gdb.prompt_hook = prompt_hook

@ -11,24 +11,7 @@ import pwndbg.enhance
import pwndbg.symbol
import pwndbg.ui
__all__ = [
'asm',
'auxv',
'context',
'dt',
'hexdump',
'ida',
'nearpc',
'packing',
'reload',
'rop',
'search',
'shell',
'start',
'telescope',
'vmmap',
'windbg',
]
debug = True

@ -2,7 +2,7 @@ import os
import gdb
import pwndbg.commands
import pwndbg.vmmap
@pwndbg.commands.Command
def rop(start=None, stop=None):
@ -14,6 +14,7 @@ def rop(start=None, stop=None):
Searches executable mapped pages only.
"""
# for page in pwndbg.vmmap.get()
cmd = ['ROPgadget',
'--rawArch=x86',
'--rawMode=32',

@ -58,4 +58,4 @@ def entry(*a):
global break_on_first_instruction
break_on_first_instruction = True
run = 'run ' + ' '.join(a)
gdb.execute(run, from_tty=False, to_string=True)
gdb.execute(run, from_tty=False)

@ -72,12 +72,12 @@ def connect(func, event_handler, name=''):
def caller(*a):
if debug: sys.stdout.write('%r %s.%s %r\n' % (name, func.__module__, func.__name__, a))
if pause: return
with pwndbg.stdio.stdio:
try:
func()
except Exception as e:
print(traceback.format_exc())
raise e
# with pwndbg.stdio.stdio:
try:
func()
except Exception as e:
traceback.print_exc()
raise e
registered[event_handler].append(caller)
event_handler.connect(caller)

@ -155,6 +155,7 @@ _breakpoints=[]
@pwndbg.events.stop
@withIDA
def UpdateBreakpoints():
# XXX: Remove breakpoints from IDA when the user removes them.
current = set(eval(b.location.lstrip('*')) for b in _breakpoints)
want = set(GetBreakpoints())

@ -3,19 +3,18 @@ Provides functionality to circumvent GDB's hooks on sys.stdin and sys.stdout
which prevent output from appearing on-screen inside of certain event handlers.
"""
import io
import os
import sys
import gdb
import pwndbg.compat
def get(fd, mode):
file = io.open(1, mode=mode, buffering=0, closefd=False)
kw = {}
if pwndbg.compat.python3:
kw['write_through']=True
return io.TextIOWrapper(file, **kw)
file = io.open(fd, mode=mode, buffering=0, closefd=False)
return io.TextIOWrapper(file, write_through=True, **kw)
else:
return os.fdopen(fd, mode, 0)
stdin = get(0, 'rb')
stdout = get(1, 'wb')

@ -62,6 +62,11 @@ def address(symbol):
if isinstance(symbol, (int,long)):
return symbol
try:
return int(symbol, 0)
except:
pass
try:
result = gdb.execute('info address %s' % symbol, to_string=True, from_tty=False)
result = result.split()

Loading…
Cancel
Save