Skip to content

Commit

Permalink
Merge pull request #122 from doronz88/feature/extended_symbol_info
Browse files Browse the repository at this point in the history
Feature/extended symbol info
  • Loading branch information
doronz88 authored Mar 30, 2022
2 parents 6abe685 + fb9cfc6 commit 7a860eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rpcclient/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pygments
objc_types_decoder
pycrashreport>=0.0.8
lief
capstone
7 changes: 7 additions & 0 deletions src/rpcclient/rpcclient/darwin/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ def objc_call(self, selector, *params, **kwargs):

return self._client.symbols.objc_msgSend(self, sel, *params, **kwargs)

@property
def region(self):
""" get corresponding region """
for region in self._client.processes.get_by_pid(self._client.pid).regions:
if (self >= region.start) and (self <= region.end):
return region

@property
def cfdesc(self):
"""
Expand Down
12 changes: 12 additions & 0 deletions src/rpcclient/rpcclient/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
import os
import struct
from contextlib import contextmanager
from typing import List

from capstone import Cs, CS_ARCH_ARM64, CS_MODE_LITTLE_ENDIAN, CS_ARCH_X86, CS_MODE_64, CsInsn
from construct import FormatField

from rpcclient.protocol import arch_t

ADDRESS_SIZE_TO_STRUCT_FORMAT = {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}
RETVAL_BIT_COUNT = 64

Expand Down Expand Up @@ -110,6 +114,14 @@ def tell(self):
""" Construct compliance. """
return self + self._offset

def disass(self, size=40) -> List[CsInsn]:
""" peek disassembled lines of 'size' bytes """
if self._client.arch == arch_t.ARCH_ARM64:
return list(Cs(CS_ARCH_ARM64, CS_MODE_LITTLE_ENDIAN).disasm(self.peek(size), self))
else:
# assume x86_64 by default
return list(Cs(CS_ARCH_X86, CS_MODE_LITTLE_ENDIAN | CS_MODE_64).disasm(self.peek(size), self))

@property
def c_int64(self) -> int:
""" cast to c_int64 """
Expand Down

0 comments on commit 7a860eb

Please sign in to comment.