I'm looking at a game with python-ptrace. I do not want to disconnect from the server so after attaching to the process, I immediately call cont() to allow it to keep running.
In this state I can still read memory, but I can not write to it.
Is there anyway to break back into the process and then be able to read memory? I have tried re-adding the process, calling detach() and then re-adding. The only thing that has worked is completely closing out Python and reopening it and reopening the process.
Example interaction:
>>> from ptrace.debugger import PtraceDebugger
>>> dbg = PtraceDebugger()
>>> proc = dbg.addProcess(35765, False)
>>> proc.writeBytes(0x185e8c08, '\x00\x40\x1c\x46')
>>> proc.cont()
>>> proc.writeBytes(0x185e8c08, '\x00\x40\x1c\x46')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 630, in writeBytes
self.writeWord(address, bytes2word(word))
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 700, in writeWord
ptrace_poketext(self.pid, address, word)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 184, in ptrace_poketext
_poke(PTRACE_POKETEXT, pid, address, word)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 172, in _poke
ptrace(command, pid, address, word)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 148, in ptrace
raise PtraceError(message, errno=errno, pid=pid)
ptrace.error.PtraceError: ptrace(cmd=4, pid=35765, 408849416, 4142814460058025984) error #3: No such process
>>> proc.detach()
>>> proc = dbg.addProcess(35765, False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/debugger.py", line 75, in addProcess
process = PtraceProcess(self, pid, is_attached, parent=parent)
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 167, in __init__
self.attach()
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 184, in attach
ptrace_attach(self.pid)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 155, in ptrace_attach
ptrace(PTRACE_ATTACH, pid)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 148, in ptrace
raise PtraceError(message, errno=errno, pid=pid)
ptrace.error.PtraceError: ptrace(cmd=16, pid=35765, 0, 0) error #1: Operation not permitted
>>> proc = dbg.deleteProcess(proc)
>>> proc = dbg.addProcess(35765, False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/debugger.py", line 75, in addProcess
process = PtraceProcess(self, pid, is_attached, parent=parent)
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 167, in __init__
self.attach()
File "/usr/local/lib/python2.7/dist-packages/ptrace/debugger/process.py", line 184, in attach
ptrace_attach(self.pid)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 155, in ptrace_attach
ptrace(PTRACE_ATTACH, pid)
File "/usr/local/lib/python2.7/dist-packages/ptrace/binding/func.py", line 148, in ptrace
raise PtraceError(message, errno=errno, pid=pid)
ptrace.error.PtraceError: ptrace(cmd=16, pid=35765, 0, 0) error #1: Operation not permitted
Any suggestions how to edit this while it is still running?
I don't see a break() function to break back into the process.
Decent doc strings here:
https://github.com/qikon/python-ptrace/blob/master/ptrace/debugger/debugger.py
https://github.com/qikon/python-ptrace/blob/master/ptrace/debugger/process.py