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

started to implement ptrace behaviour #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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