Skip to content

Commit

Permalink
Removed unused imports. Set default output dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Gascon committed Nov 2, 2014
1 parent c6f43cb commit 0ca3c2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
17 changes: 7 additions & 10 deletions adagio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python
# ADAGIO Android Application Graph-based Classification
# adagio.py >> Main wrapper for other modules
# Copyright (c) 2013 Hugo Gascon <[email protected]>
# ADAGIO Structural Analysis of Android Binaries
# Copyright (c) 2014 Hugo Gascon <[email protected]>


import sys
Expand Down Expand Up @@ -45,10 +44,10 @@ def exit():
parser.add_argument("-d", "--dir", default="",
help="Load APK/DEX files from this directory.")

parser.add_argument("-o", "--out", default="",
parser.add_argument("-o", "--out", default="data/fcg",
help="Select output directory for generated graphs.\
If no directory is given, they will be written\
to the input directory.")
to the data/fcg directory.")

fcga = parser.add_argument_group('CALL GRAPHS ANALYSIS')
fcga.add_argument("-f", "--fcgraphs", action="store_true",
Expand All @@ -65,14 +64,12 @@ def exit():

generator = ""
if args.fcgraphs:
if args.out:
args.out = os.path.realpath(args.out)
args.out = os.path.realpath(args.out)
generator = FCGGenerator(args.dir, args.out)

elif args.pdgraphs:
#if args.out:
#args.out = os.path.realpath(args.out)
#generator = PDGGenerator(args.dir, args.out)
# args.out = os.path.realpath(args.out)
# generator = PDGGenerator(args.dir, args.out)
print "Not implemented yet!"
sys.exit()

Expand Down
8 changes: 2 additions & 6 deletions adagio/core/FCG.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/python
# ADAGIO Android Application Graph-based Classification
# fcg_extractor.py >> Read all APKs in dir and save NX graphs as pickle objects
# Copyright (c) 2013 Hugo Gascon <[email protected]>
# ADAGIO Structural Analysis of Android Binaries
# Copyright (c) 2014 Hugo Gascon <[email protected]>

""" A module to build NX objects from APKs call graphs. """

import sys
import os
import zipfile
import networkx as nx
import numpy as np
import adagio.common.pz as pz
Expand All @@ -17,8 +15,6 @@
from adagio.core.instructionSet import INSTRUCTION_CLASSES

from progressbar import *
from modules.androguard.androguard import *
from modules.androguard.androguard.core.analysis import *
from modules.androguard.androlyze import *
from adagio.common.utils import get_sha256

Expand Down
11 changes: 3 additions & 8 deletions adagio/core/PDG.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@

import networkx as nx
import adagio.common.pz as pz


from progressbar import *
from modules.androguard.androguard import *
from modules.androguard.androguard.core.analysis import *
from modules.androguard.androlyze import *

from adagio.common.utils import get_sha256


Expand Down Expand Up @@ -83,15 +78,15 @@ def build_pdg(self, filename):
#TODO
return

def build_icfg_nx(self, file):
def build_icfg_nx(self, filename):
""" Using NX and Androguard, build an interprocedural control flow
graph NX object so that node names are basic blocks names: (class name,
method name, descriptor, bb)
"""
icgnx = nx.DiGraph()
print "Loading file {0}...".format(file)
print "Loading file {0}...".format(filename)
try:
a, d, dx = AnalyzeAPK(file)
a, d, dx = AnalyzeAPK(filename)
except zipfile.BadZipfile:
#if file is not an APK, may be a dex object
d, dx = AnalyzeDex(filename)
Expand Down

0 comments on commit 0ca3c2b

Please sign in to comment.