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

Public Member Functions

def __init__
 
def update_parser
 

Public Attributes

 libs
 
 pe
 
 entry_point
 

Static Public Attributes

list ALL_IMP_DLL
 

Detailed Description

Definition at line 152 of file sandbox.py.

Constructor & Destructor Documentation

def miasm2.analysis.sandbox.OS_Win.__init__ (   self,
  custom_methods,
  args,
  kwargs 
)

Definition at line 159 of file sandbox.py.

160  def __init__(self, custom_methods, *args, **kwargs):
161  from miasm2.jitter.loader.pe import vm_load_pe, vm_load_pe_libs, preload_pe, libimp_pe
162  from miasm2.os_dep import win_api_x86_32
163  methods = win_api_x86_32.__dict__
164  methods.update(custom_methods)
165 
166  super(OS_Win, self).__init__(methods, *args, **kwargs)
167 
168  # Import manager
169  libs = libimp_pe()
170  self.libs = libs
171  win_api_x86_32.winobjs.runtime_dll = libs
172 
173  # Load library
174  if self.options.loadbasedll:
175  all_pe = []
176 
177  # Load libs in memory
178  all_pe = vm_load_pe_libs(self.jitter.vm, self.ALL_IMP_DLL, libs)
179 
180  # Patch libs imports
181  for pe in all_pe.values():
182  preload_pe(self.jitter.vm, pe, libs)
183 
184  # Load main pe
185  with open(self.fname) as fstream:
186  self.pe = vm_load_pe(self.jitter.vm, fstream.read())
187 
188  win_api_x86_32.winobjs.current_pe = self.pe
189 
190  # Fix pe imports
191  preload_pe(self.jitter.vm, self.pe, libs)
192 
193  # Library calls handler
194  self.jitter.add_lib_handler(libs, methods)
195 
196  # Manage SEH
197  if self.options.use_seh:
198  win_api_x86_32_seh.main_pe_name = self.fname
199  win_api_x86_32_seh.main_pe = self.pe
200  win_api_x86_32_seh.loaded_modules = self.ALL_IMP_DLL
201  win_api_x86_32_seh.init_seh(self.jitter)
202  win_api_x86_32_seh.set_win_fs_0(self.jitter)
204  self.entry_point = self.pe.rva2virt(self.pe.Opthdr.AddressOfEntryPoint)

Member Function Documentation

def miasm2.analysis.sandbox.OS_Win.update_parser (   cls,
  parser 
)

Definition at line 206 of file sandbox.py.

207  def update_parser(cls, parser):
208  parser.add_argument('-o', "--loadhdr", action="store_true",
209  help="Load pe hdr")
210  parser.add_argument('-e', "--loadmainpe", action="store_true",
211  help="Load main pe")
212  parser.add_argument('-y', "--use-seh", action="store_true",
213  help="Use windows SEH")
214  parser.add_argument('-l', "--loadbasedll", action="store_true",
215  help="Load base dll (path './win_dll')")
216  parser.add_argument('-r', "--parse-resources",
217  action="store_true", help="Load resources")
218 

Member Data Documentation

list miasm2.analysis.sandbox.OS_Win.ALL_IMP_DLL
static
Initial value:
1 = ["ntdll.dll", "kernel32.dll", "user32.dll",
2  "ole32.dll", "urlmon.dll",
3  "ws2_32.dll", 'advapi32.dll', "psapi.dll",
4  ]

Definition at line 154 of file sandbox.py.

miasm2.analysis.sandbox.OS_Win.entry_point

Definition at line 203 of file sandbox.py.

miasm2.analysis.sandbox.OS_Win.libs

Definition at line 169 of file sandbox.py.

miasm2.analysis.sandbox.OS_Win.pe

Definition at line 185 of file sandbox.py.


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