-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathadagio.py
executable file
·78 lines (60 loc) · 2.38 KB
/
adagio.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ADAGIO Structural Analysis of Android Binaries
# Copyright (c) 2015 Hugo Gascon <[email protected]>
import sys
import os
# sys.path.insert(0, os.path.abspath("modules/androguard"))
import argparse
from adagio.core.graphs import process_dir
def print_logo():
print("""
_ _
| | (_)
__ _ __| | __ _ __ _ _ ___
/ _` |/ _` |/ _` |/ _` | |/ _ \\
| (_| | (_| | (_| | (_| | | (_) |
\__,_|\__,_|\__,_|\__, |_|\___/
__/ |
|___/
""")
def exit():
print_logo()
parser.print_help()
sys.exit()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Structural Analysis of\
Android Binaries')
parser.add_argument("-c", "--conf", default="adagio/conf",
help="Change default directory for configuration files.\
If no directory is given, the files from 'adagio/conf'\
will be read.")
parser.add_argument("-d", "--dir", default="",
help="Load APK/DEX files from this directory.")
parser.add_argument("-o", "--out", default="",
help="Select output directory for generated graphs.\
If no directory is given, they will be written\
to the data/fcg or data/pdg directory.")
fcga = parser.add_argument_group('CALL GRAPH ANALYSIS')
fcga.add_argument("-f", "--fcgraphs", action="store_true",
help="Extract function call graphs from all APK/DEX files\
in the given directory.")
pdga = parser.add_argument_group('PROGRAM DEPENDENCY GRAPH ANALYSIS')
pdga.add_argument("-p", "--pdgraphs", action="store_true",
help="Extract program dependecy graphs from all APK/DEX\
files in the given directory.")
args = parser.parse_args()
path_conf = os.path.realpath(args.conf)
out = args.out
mode = ""
if args.fcgraphs:
if not args.out:
out = os.path.realpath("data/fcg")
mode='FCG'
elif args.pdgraphs:
if not args.out:
out = os.path.realpath("data/pdg")
mode ='PDG'
if mode:
print_logo()
process_dir(args.dir, out, mode)
else:
exit()