PytStop debugging engine

What is PytStop

PytStop is a debugging engine written in Python. It tries to map operations you do on the object to debugging operation on the process.

For the moment, only a ptrace back-end is implemented, but I've begun to work on a gdbserver backend.

PytStop project

Download PytStop 0.0.1alpha

Example

Note that the mnemonic() and opcode() stuff are not present in 0.0.1alpha yet. Please be patient ! :)
>>> from pytstop import *
>>> p=Ptrace("/bin/ls")
INFO: process 14006 attached
>>> p 
<VBox ptrace [/bin/ls] PC=b7feb7c0 sig=0>
>>> p.singlestep()
INFO: Received stop signal 5
DEBUG: TRAP: singlestep
>>> p
<VBox ptrace [/bin/ls] PC=b7feb7c2 sig=0>
>>> p.ebx
0L
>>> p.ebx=4
>>> p.ebx
4L
>>> p.ebx=0
>>> p[p.eip::20]
'\xe8\xb9,\x00\x00\x89\xc7\xe8\xe2\xff\xff\xff\x81\xc3&X\x01\x00\x8b\x83'
>>> p.mnemonic()
'call    0x2cb9'
>>> p.singlestep()
>>> p.singlestep()
INFO: Received stop signal 5
DEBUG: TRAP: singlestep
>>> p.mnemonic()
'mov     DWORD PTR [ebp-0x30],eax'
>>> o=p.opcode()
>>> o
<Opcode: mov     DWORD PTR [ebp-0x30],eax>
>>> o.source
<Expression: DWORD PTR [ebp-0x30]>
>>> o.source.eval(p.get_all_regs())
3221219496L
>>> p.ebp-0x30
3221219496L
>>> p.set_bp(0x8049a50)
0
>>> p.set_hbp(0x8049a52)
0
>>> p.set_bp(0x8049a53)
1
>>> p.cont()
INFO: Received stop signal 5
INFO: TRAP: software breakpoint #0 at 0x08049a50
>>> p.cont()
DEBUG: pass bp at 08049a50
INFO: Received stop signal 5
DEBUG: TRAP: singlestep
DEBUG: passed pb. Now at 08049a52
INFO: Received stop signal 5
INFO: TRAP: hardware breakpoint #0 at 0x08049a52
>>> p.cont()
DEBUG: pass bp at 08049a52
INFO: Received stop signal 5
DEBUG: TRAP: singlestep
DEBUG: passed pb. Now at 08049a53
INFO: Received stop signal 5
INFO: TRAP: software breakpoint #1 at 0x08049a53
>>> mainlog.setLevel(50) # stop log messages
>>> p.cont()
pytstop.py   pytstop.pyc
Traceback (most recent call last):
  File "", line 1, in ?
  File "pytstop.py", line 542, in cont
    return self.wait()
  File "pytstop.py", line 592, in wait
    raise ProcessExited(os.WEXITSTATUS(s))
pytstop.ProcessExited: 0