Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
implements a basic ptrace support
Browse files Browse the repository at this point in the history
now handles PTRACE_TRACEME requests
  • Loading branch information
themaks committed Feb 22, 2017
1 parent d17cffd commit 22f5c7c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions simuvex/procedures/libc___so___6/ptrace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import simuvex

class ptrace(simuvex.SimProcedure):
def run(self, request, pid, addr, data): #pylint:disable=arguments-differ,unused-argument

return self.inline_call(simuvex.SimProcedures['syscalls']['ptrace'],
request,
pid,
addr,
data
).ret_expr
35 changes: 35 additions & 0 deletions simuvex/procedures/syscalls/ptrace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import simuvex
import logging

######################################
# ptrace
######################################

l = logging.getLogger("simuvex.procedures.syscall")

class ptrace(simuvex.SimProcedure):
#pylint:disable=arguments-differ,unused-argument

IS_SYSCALL = True

def run(self, request, pid, addr, data):
if self.state.se.symbolic(request):
l.warning("Symbolic PTRACE_* request, returning unconstrained value")
res = self.state.se.BVS('ptrace_return', self.state.arch.bits)

else:
request_concrete = self.state.se.any_int(request)
# PTRACE_TRACEME
if request_concrete == 0:
# process is already traced
if 'ptrace_istraced' in self.state.procedure_data.global_variables and self.state.procedure_data.global_variables['ptrace_istraced']:
res = self.state.se.BVV(-1, self.state.arch.bits)

else:
self.state.procedure_data.global_variables['ptrace_istraced'] = True
res = self.state.se.BVV(0, self.state.arch.bits)

else:
l.error("Unimplemented PTRACE_* request(#%d), returning unconstrained value", request_concrete)
res = self.state.se.BVS('ptrace_return', self.state.arch.bits)
return res

0 comments on commit 22f5c7c

Please sign in to comment.