From babc99e7b4c0c6f79a0fe548a34dd0d42b08d30d Mon Sep 17 00:00:00 2001 From: n0p <0x90@n0p.cc> Date: Wed, 7 Mar 2018 19:32:57 +0100 Subject: Just use miasm, if it's been imported successfully. --- SystemCalls.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/SystemCalls.py b/SystemCalls.py index c564029..f47caf0 100644 --- a/SystemCalls.py +++ b/SystemCalls.py @@ -9,10 +9,13 @@ by n0p """ -from miasm2.core.bin_stream_ida import bin_stream_ida -from miasm2.analysis.depgraph import DependencyGraph +try: + from miasm2.core.bin_stream_ida import bin_stream_ida + from miasm2.analysis.depgraph import DependencyGraph -from utils import guess_machine + from utils import guess_machine +except: + guess_machine = None from idaapi import * import idc @@ -182,19 +185,20 @@ class SystemCall(): def __init__(self): # Init miasm stuff. - self.machine = guess_machine() - self.mn, self.dis_engine, self.ira = self.machine.mn, self.machine.dis_engine, self.machine.ira + if guess_machine != None: + self.machine = guess_machine() + self.mn, self.dis_engine, self.ira = self.machine.mn, self.machine.dis_engine, self.machine.ira - self.mdis = self.dis_engine(bin_stream_ida(), dont_dis_nulstart_bloc=True) - self.ir_arch = self.ira(self.mdis.symbol_pool) + self.mdis = self.dis_engine(bin_stream_ida(), dont_dis_nulstart_bloc=True) + self.ir_arch = self.ira(self.mdis.symbol_pool) - # Populate symbols with ida names - for ad, name in Names(): - if name is None: - continue - self.mdis.symbol_pool.add_label(name, ad) + # Populate symbols with ida names + for ad, name in Names(): + if name is None: + continue + self.mdis.symbol_pool.add_label(name, ad) - self.elements = set([self.mn.regs.RAX]) + self.elements = set([self.mn.regs.RAX]) self.x86 = dict() self.x86_64 = dict() @@ -229,8 +233,8 @@ class SystemCall(): func.calls -= calls - # Just proceed with depgraph if IDA detected a function. - if not func.f: + # Just proceed with depgraph if IDA detected a function and miasm had been imported. + if not func.f or guess_machine == None: for call in func.calls: sol.append([call.addr, call.sctype, '']) return sol -- cgit v1.2.3-54-g00ecf