Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | Private Member Functions | List of all members
miasm2.analysis.sandbox.Sandbox Class Reference
+ Inheritance diagram for miasm2.analysis.sandbox.Sandbox:
+ Collaboration diagram for miasm2.analysis.sandbox.Sandbox:

Public Member Functions

def __init__
 
def parser
 
def run
 

Static Public Member Functions

def code_sentinelle
 

Public Attributes

 fname
 
 options
 
 dbg
 
 gdb
 
 cmd
 

Properties

 classes = property(lambda x:x.__class__._classes_())
 

Private Member Functions

def _classes_
 

Detailed Description

Parent class for Sandbox abstraction

Definition at line 10 of file sandbox.py.

Constructor & Destructor Documentation

def miasm2.analysis.sandbox.Sandbox.__init__ (   self,
  fname,
  options,
  custom_methods = {} 
)
Initialize a sandbox
@fname: str file name
@options: namespace instance of specific options
@custom_methods: { str => func } for custom API implementations

Definition at line 34 of file sandbox.py.

34 
35  def __init__(self, fname, options, custom_methods = {}):
36  """
37  Initialize a sandbox
38  @fname: str file name
39  @options: namespace instance of specific options
40  @custom_methods: { str => func } for custom API implementations
41  """
42 
43  # Initialize
44  self.fname = fname
45  self.options = options
46  for cls in self.classes:
47  if cls == Sandbox:
48  continue
49  if issubclass(cls, OS):
50  cls.__init__(self, custom_methods)
51  else:
52  cls.__init__(self)
53 
54  # Logging options
55  if self.options.singlestep:
56  self.jitter.jit.log_mn = True
57  self.jitter.jit.log_regs = True
58 
59  if not self.options.quiet_function_calls:
60  log_func.setLevel(logging.INFO)
61 
62  if self.options.dumpblocs:
63  self.jitter.jit.log_newbloc = True

Member Function Documentation

def miasm2.analysis.sandbox.Sandbox._classes_ (   cls)
private
Iterator on parent classes except Sanbox

Definition at line 21 of file sandbox.py.

21 
22  def _classes_(cls):
23  """
24  Iterator on parent classes except Sanbox
25  """
26  for base_cls in cls.__bases__:
27  # Avoid infinite loop
28  if base_cls == Sandbox:
29  continue
30 
31  yield base_cls
def miasm2.analysis.sandbox.Sandbox.code_sentinelle (   jitter)
static

Definition at line 16 of file sandbox.py.

16 
17  def code_sentinelle(jitter):
18  jitter.run = False
19  return False
def miasm2.analysis.sandbox.Sandbox.parser (   cls,
  args,
  kwargs 
)
Return instance of instance parser with expecting options.
Extra parameters are passed to parser initialisation.

Definition at line 65 of file sandbox.py.

65 
66  def parser(cls, *args, **kwargs):
67  """
68  Return instance of instance parser with expecting options.
69  Extra parameters are passed to parser initialisation.
70  """
71 
72  parser = ArgumentParser(*args, **kwargs)
73  parser.add_argument('-a', "--address",
74  help="Force entry point address", default=None)
75  parser.add_argument('-x', "--dumpall", action="store_true",
76  help="Load base dll")
77  parser.add_argument('-b', "--dumpblocs", action="store_true",
78  help="Log disasm blocks")
79  parser.add_argument('-z', "--singlestep", action="store_true",
80  help="Log single step")
81  parser.add_argument('-d', "--debugging", action="store_true",
82  help="Debug shell")
83  parser.add_argument('-g', "--gdbserver", type=int,
84  help="Listen on port @port")
85  parser.add_argument("-j", "--jitter",
86  help="Jitter engine. Possible values are: tcc (default), llvm, python",
87  default="tcc")
88  parser.add_argument('-q', "--quiet-function-calls", action="store_true",
89  help="Don't log function calls")
90 
91  for base_cls in cls._classes_():
92  base_cls.update_parser(parser)
93  return parser

+ Here is the caller graph for this function:

def miasm2.analysis.sandbox.Sandbox.run (   self,
  addr = None 
)
Launch emulation (gdbserver, debugging, basic JIT).
@addr: (int) start address

Definition at line 94 of file sandbox.py.

94 
95  def run(self, addr=None):
96  """
97  Launch emulation (gdbserver, debugging, basic JIT).
98  @addr: (int) start address
99  """
100  if addr is None and self.options.address is not None:
101  addr = int(self.options.address, 0)
102 
103  if any([self.options.debugging, self.options.gdbserver]):
104  dbg = debugging.Debugguer(self.jitter)
105  self.dbg = dbg
106  dbg.init_run(addr)
107 
108  if self.options.gdbserver:
109  port = self.options.gdbserver
110  print "Listen on port %d" % port
111  gdb = self.machine.gdbserver(dbg, port)
112  self.gdb = gdb
113  gdb.run()
114  else:
116  self.cmd = cmd
117  cmd.cmdloop()
118 
119  else:
120  self.jitter.init_run(addr)
121  self.jitter.continue_run()
122 

+ Here is the call graph for this function:

Member Data Documentation

miasm2.analysis.sandbox.Sandbox.cmd

Definition at line 115 of file sandbox.py.

miasm2.analysis.sandbox.Sandbox.dbg

Definition at line 104 of file sandbox.py.

miasm2.analysis.sandbox.Sandbox.fname

Definition at line 43 of file sandbox.py.

miasm2.analysis.sandbox.Sandbox.gdb

Definition at line 111 of file sandbox.py.

miasm2.analysis.sandbox.Sandbox.options

Definition at line 44 of file sandbox.py.

Property Documentation

miasm2.analysis.sandbox.Sandbox.classes = property(lambda x:x.__class__._classes_())
static

Definition at line 32 of file sandbox.py.


The documentation for this class was generated from the following file: