本文整理汇总了Python中vtrace.platforms.posix.ptrace函数的典型用法代码示例。如果您正苦于以下问题:Python ptrace函数的具体用法?Python ptrace怎么用?Python ptrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ptrace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: platformContinue
def platformContinue(self):
sig = self.getCurrentSignal()
if sig == None:
sig = 0
print 'PT_THUPDATE',v_posix.ptrace(PT_THUPDATE, self.pid, self.getMeta('StoppedThreadId'), sig)
v_posix.ptrace(PT_CONTINUE, self.pid, 1, sig)
self.libc.task_resume(self.task)
开发者ID:Fitblip,项目名称:vdb-fork,代码行数:7,代码来源:__init__.py
示例2: platformSetRegCtx
def platformSetRegCtx(self, tid, ctx):
u = self._getAmdRegsStruct(tid)
ctx._rctx_Export(u)
addr = ctypes.addressof(u)
if v_posix.ptrace(PT_SETREGS, tid, addr, 0) != 0:
raise Exception("ptrace PT_SETREGS failed!")
if v_posix.ptrace(PT_SETDBREGS, tid, addr+amd64_DBG_OFF, 0) != 0:
raise Exception("ptrace PT_SETDBREGS failed!")
开发者ID:Fitblip,项目名称:SocketSniff,代码行数:8,代码来源:freebsd.py
示例3: platformGetRegs
def platformGetRegs(self):
buf = ctypes.create_string_buffer(TOT_REG_CNT*4)
#FIXME thread specific
if v_posix.ptrace(PT_GETREGS, self.pid, buf, 0) != 0:
raise Exception("ptrace PT_GETREGS failed!")
if v_posix.ptrace(PT_GETDBREGS, self.pid, ctypes.addressof(buf)+(GEN_REG_CNT*4), 0) != 0:
raise Exception("ptrace PT_GETDBREGS failed!")
return buf.raw
开发者ID:albertz,项目名称:pydbattach,代码行数:8,代码来源:freebsd.py
示例4: platformSetRegCtx
def platformSetRegCtx(self, tid, ctx):
u = user_regs_i386()
ctx._rctx_Export(u)
if v_posix.ptrace(PT_SETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_SETREGS...) failed!")
for i in range(8):
val = ctx.getRegister(self.dbgidx + i)
if v_posix.ptrace(v_posix.PT_WRITE_U, tid, self.dbgoff+(4*i), val) != 0:
raise Exception("PT_WRITE_U for debug%d failed!" % i)
开发者ID:gdisneyleugers,项目名称:vdebug,代码行数:10,代码来源:linux.py
示例5: platformExec
def platformExec(self, cmdline):
# Basically just like the one in the Ptrace mixin...
self.execing = True
cmdlist = e_cli.splitargs(cmdline)
os.stat(cmdlist[0])
pid = os.fork()
if pid == 0:
v_posix.ptrace(PT_TRACE_ME, 0, 0, 0)
os.execv(cmdlist[0], cmdlist)
sys.exit(-1)
return pid
开发者ID:Fitblip,项目名称:SocketSniff,代码行数:11,代码来源:freebsd.py
示例6: platformSetRegCtx
def platformSetRegCtx(self, tid, ctx):
u = self.user_reg_struct()
# Populate the reg struct with the current values (to allow for
# any regs in that struct that we don't track... *fs_base*ahem*
if v_posix.ptrace(PT_GETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_GETREGS...) failed!")
ctx._rctx_Export(u)
if v_posix.ptrace(PT_SETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_SETREGS...) failed!")
"""
开发者ID:d4nnyk,项目名称:vivisect,代码行数:12,代码来源:linux.py
示例7: _getAmdRegsStruct
def _getAmdRegsStruct(self, tid):
'''
Get (and populate) a register structure
(even set regs needs to get it first...)
'''
u = bsd_regs_amd64()
addr = ctypes.addressof(u)
if v_posix.ptrace(PT_GETREGS, tid, addr, 0) != 0:
raise Exception("ptrace PT_GETREGS failed!")
if v_posix.ptrace(PT_GETDBREGS, tid, addr+amd64_DBG_OFF, 0) != 0:
raise Exception("ptrace PT_GETDBREGS failed!")
return u
开发者ID:Fitblip,项目名称:SocketSniff,代码行数:12,代码来源:freebsd.py
示例8: platformSetRegs
def platformSetRegs(self, buf, tid):
"""
Reverse of above...
"""
x = create_string_buffer(buf[32:])
if v_posix.ptrace(PT_SETREGS, tid, 0, addressof(x)) != 0:
raise Exception("ERROR ptrace PT_SETREGS failed!")
dbgs = struct.unpack("8L", buf[:32])
off = self.usize - 32
for i in range(8):
v_posix.ptrace(v_posix.PT_WRITE_U, tid, off+(4*i), dbgs[i])
开发者ID:gdisneyleugers,项目名称:vdebug,代码行数:12,代码来源:linux.py
示例9: platformGetRegCtx
def platformGetRegCtx(self, tid):
ctx = self.archGetRegCtx()
u = bsd_regs_amd64()
addr = ctypes.addressof(u)
if v_posix.ptrace(PT_GETREGS, tid, addr, 0) != 0:
raise Exception("ptrace PT_GETREGS failed!")
if v_posix.ptrace(PT_GETDBREGS, tid, addr+amd64_DBG_OFF, 0) != 0:
raise Exception("ptrace PT_GETDBREGS failed!")
ctx._rctx_Import(u)
return ctx
开发者ID:gdisneyleugers,项目名称:vdebug,代码行数:13,代码来源:freebsd.py
示例10: platformGetRegCtx
def platformGetRegCtx(self, tid):
ctx = self.archGetRegCtx()
u = self.user_reg_struct()
if v_posix.ptrace(PT_GETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_GETREGS...) failed!")
ctx._rctx_Import(u)
for i in dbgregs:
offset = self.user_dbg_offset + (self.psize * i)
r = v_posix.ptrace(v_posix.PT_READ_U, tid, offset, 0)
ctx.setRegister(self.dbgidx+i, r & self.reg_val_mask)
return ctx
开发者ID:Fitblip,项目名称:vdb-fork,代码行数:14,代码来源:linux.py
示例11: platformContinue
def platformContinue(self):
cmd = v_posix.PT_CONTINUE
if self.getMode("Syscall", False):
cmd = PT_SYSCALL
pid = self.getPid()
sig = self.getMeta("PendingSignal", 0)
# Only deliver signals to the main thread
if v_posix.ptrace(cmd, pid, 0, sig) != 0:
raise Exception("ERROR ptrace failed for tid %d" % pid)
for tid in self.pthreads:
if tid == pid:
continue
if v_posix.ptrace(cmd, tid, 0, 0) != 0:
pass
开发者ID:mwollenweber,项目名称:rebridge,代码行数:15,代码来源:linux.py
示例12: platformGetRegCtx
def platformGetRegCtx(self, tid):
"""
"""
ctx = self.archGetRegCtx()
u = user_regs_i386()
if v_posix.ptrace(PT_GETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_GETREGS...) failed!")
ctx._rctx_Import(u)
for i in range(8):
r = v_posix.ptrace(v_posix.PT_READ_U, tid, self.dbgoff+(4*i), 0)
ctx.setRegister(self.dbgidx+i, r & 0xffffffff)
return ctx
开发者ID:gdisneyleugers,项目名称:vdebug,代码行数:15,代码来源:linux.py
示例13: platformGetRegCtx
def platformGetRegCtx(self, tid):
ctx = LinuxMixin.platformGetRegCtx( self, tid )
for i in intel_dbgregs:
offset = self.user_dbg_offset + (self.psize * i)
r = v_posix.ptrace(v_posix.PT_READ_U, tid, offset, 0)
ctx.setRegister(self.dbgidx+i, r & self.reg_val_mask)
return ctx
开发者ID:d4nnyk,项目名称:vivisect,代码行数:7,代码来源:linux.py
示例14: platformAttach
def platformAttach(self, pid):
print 'CLASSIC',machhelper.is_pid_classic(pid)
self.task = self.taskForPid(pid)
self.setExceptionPort()
if v_posix.ptrace(PT_ATTACHEXC, pid, 0, 0) != 0:
#self.libc.perror('ptrace( PT_ATTACHEXC, %d, 0, 0) Failed' % (pid))
raise Exception("PT_ATTACH failed!")
开发者ID:Fitblip,项目名称:vdb-fork,代码行数:7,代码来源:__init__.py
示例15: platformStepi
def platformStepi(self):
# This is a total rediculous hack to account
# for the fact that the arm platform couldn't
# be bothered to implement single stepping in
# the stupid hardware...
self.stepping = True
pc = self.getProgramCounter()
op = self.parseOpcode( pc )
branches = op.getBranches( self )
if not branches:
raise Exception('''
The branches for the instruction %r were not decoded correctly. This means that
we cant properly predict the possible next instruction executions in a way that allows us
to account for the STUPID INSANE FACT THAT THERE IS NO HARDWARE SINGLE STEP CAPABILITY ON
ARM (non-realtime or JTAG anyway). We *would* have written invalid instructions to each
of those locations and cleaned them up before you ever knew anything was amiss... which is
how we pretend arm can single step... even though IT CANT. (please tell visi...)
''' % op)
# Save the memory at the branches for later
# restoration in the _fireStep callback.
self._step_cleanup = []
for bva,bflags in op.getBranches( self ):
self._step_cleanup.append( (bva, self.readMemory( bva, 4 )) )
self.writeMemory( bva, arm_break_le )
tid = self.getMeta('ThreadId')
if v_posix.ptrace(v_posix.PT_CONTINUE, tid, 0, 0) != 0:
raise Exception("ERROR ptrace failed for tid %d" % tid)
开发者ID:d4nnyk,项目名称:vivisect,代码行数:34,代码来源:linux.py
示例16: platformAttach
def platformAttach(self, pid):
self.pthreads = [pid,]
self.setMeta("ThreadId", pid)
if v_posix.ptrace(PT_ATTACH, pid, 0, 0) != 0:
raise Exception("PT_ATTACH failed!")
self.setupPtraceOptions(pid)
self.setMeta("ExeName", self._findExe(pid))
开发者ID:Fitblip,项目名称:vdb-fork,代码行数:7,代码来源:linux.py
示例17: platformSetRegCtx
def platformSetRegCtx(self, tid, ctx):
u = self.user_reg_struct()
# Populate the reg struct with the current values (to allow for
# any regs in that struct that we don't track... *fs_base*ahem*
if v_posix.ptrace(PT_GETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_GETREGS...) failed!")
ctx._rctx_Export(u)
if v_posix.ptrace(PT_SETREGS, tid, 0, addressof(u)) == -1:
raise Exception("Error: ptrace(PT_SETREGS...) failed!")
for i in dbgregs:
val = ctx.getRegister(self.dbgidx + i)
offset = self.user_dbg_offset + (self.psize * i)
if v_posix.ptrace(v_posix.PT_WRITE_U, tid, offset, val) != 0:
libc.perror('PT_WRITE_U failed for debug%d' % i)
开发者ID:Fitblip,项目名称:vdb-fork,代码行数:16,代码来源:linux.py
示例18: platformExec
def platformExec(self, cmdline):
# Very similar to posix, but not
# quite close enough...
self.execing = True
cmdlist = e_cli.splitargs(cmdline)
os.stat(cmdlist[0])
pid = os.fork()
if pid == 0:
try:
# Don't use PT_TRACEME -- on some linux (tested on ubuntu)
# it will cause immediate asignment of ptrace slot to parent
# without parent having PT_ATTACH'D.... MAKES SYNCHRONIZATION HARD
# SIGSTOP ourself until parent continues us
os.kill(os.getpid(),signal.SIGSTOP)
os.execv(cmdlist[0], cmdlist)
except Exception as e:
print e
sys.exit(-1)
# Attach to child. should cause SIGSTOP
if 0 != v_posix.ptrace(PT_ATTACH, pid, 0, 0):
raise Exception("PT_ATTACH failed! linux platformExec")
# Eat all SIGSTOP (or other signal) and break from loop on SIGTRAP.
# SIGTRAP triggered by execv while PTRACE_ATTACH'd
while True:
wpid,status = os.waitpid(pid,os.WUNTRACED)
if wpid != pid: #should never happen
continue
if os.WIFSTOPPED(status):
cause = os.WSTOPSIG(status)
if cause == signal.SIGTRAP:
break
if v_posix.ptrace(v_posix.PT_CONTINUE, pid, 0, 0) != 0:
raise Exception("PT_CONTINUE failed! linux platformExec")
# Do a single step, which will allow a new stop event for the
# rest of vtrace to eat up.
if v_posix.ptrace(v_posix.PT_STEP, pid, 0, 0) != 0:
raise Exception("PT_CONTINUE failed! linux platformExec")
self.pthreads = [pid,]
self.setMeta("ExeName", self._findExe(pid))
return pid
开发者ID:TarantulaTechnology,项目名称:vivisect,代码行数:45,代码来源:linux.py
示例19: detachThread
def detachThread(self, tid, ecode):
self.setMeta('ThreadId', tid)
self._fireExitThread(tid, ecode)
if v_posix.ptrace(PT_DETACH, tid, 0, 0) != 0:
raise Exception("ERROR ptrace detach failed for thread %d" % tid)
self.pthreads.remove(tid)
开发者ID:d4nnyk,项目名称:vivisect,代码行数:9,代码来源:linux.py
示例20: platformGetThreads
def platformGetThreads(self):
ret = {}
cnt = self._getThreadCount()
buf = (ctypes.c_int * cnt)()
if v_posix.ptrace(PT_GETLWPLIST, self.pid, ctypes.addressof(buf), cnt) != cnt:
raise Exception("ptrace PW_GETLWPLIST failed")
for x in buf:
ret[x] = x
return ret
开发者ID:gdisneyleugers,项目名称:vdebug,代码行数:9,代码来源:freebsd.py
注:本文中的vtrace.platforms.posix.ptrace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论