aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn0p <0x90@n0p.cc>2018-03-07 19:32:57 +0100
committern0p <0x90@n0p.cc>2018-03-07 19:32:57 +0100
commitbabc99e7b4c0c6f79a0fe548a34dd0d42b08d30d (patch)
treedcdd2009dc6445c50c05da161a32308c6892a3ad
parent51bf0cc01cdab239de086aff63dd990b6c5e941e (diff)
downloadidaSystemCalls-babc99e7b4c0c6f79a0fe548a34dd0d42b08d30d.tar.gz
idaSystemCalls-babc99e7b4c0c6f79a0fe548a34dd0d42b08d30d.zip
Just use miasm, if it's been imported successfully.
-rw-r--r--SystemCalls.py34
1 files 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