-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicBlockAttrBuilder.py
37 lines (30 loc) · 1.04 KB
/
BasicBlockAttrBuilder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
https://github.com/MLDroid/drebin
"""
from PSCout import PSCOUT_SET
def GetBasicBlockDalvikCode(BasicBlock):
'''
Get the list of dalvik code of the instrcutions contained in the BasicBlock
:param DVMBasicBlock BasicBlock
:return DalvikCodeList
:rtype List<String>
'''
DalvikCodeList = []
for Instruction in BasicBlock.get_instructions():
CodeLine = str(Instruction.get_name() + " " + Instruction.get_output())
DalvikCodeList.append(CodeLine)
return DalvikCodeList
def GetInvokedPscoutApis(DalvikCodeList):
DalvikCodeList = set(DalvikCodeList)
ApiList = set()
for DalvikCode in DalvikCodeList:
if "invoke-" in DalvikCode:
Parts = DalvikCode.split(",")
for Part in Parts:
if ";->" in Part:
Part = Part.strip()
FullApi = Part.split('(')[0].strip()
if FullApi in PSCOUT_SET:
# print(FullApi)
ApiList.add(FullApi)
return ApiList