forked from abhi-r3v0/Adhrit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adhrit.py
126 lines (97 loc) · 3.46 KB
/
adhrit.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# !/usr/bin/env python
# ADRITH is an open source tool for Android apk analysis
# and CTFs to extract maximum amount of information from an apk
import zipfile
import os
import sys
import subprocess
import argparse
from recons.apk_recon import apk_rip
from recons.apk_extract import apk_info
from recons.virustotal import api_check
from recons.smali_extract import smali_de
from recons.smali_extract import smali_re
from recons.smali_extract import inj_check
from recons.native_recon import native_disas
from recons.dynamic import adb_con
__author__ = 'Abhishek J M ( [email protected] )'
class Adhrit:
def __init__(self):
self.apk_name = ""
def welcome(self):
os.system('toilet -F metal -f bigascii12 ADHRIT')
print "\t\twww.github.com/abhi-r3v0/Adhrit "
print "\n\n"
# Extract APK information without extracting the package
def apkripper(self, apk_name):
apk_rip(apk_name)
# Extract All the contents of the APK into a directory
def apkextractor(self, apk_name):
apk_info(apk_name)
# Check if the APK has been identified by VirusTotal database
def vtanalyzer(self, apk_name):
api_check(apk_name)
# Extract the source code of the APK in smali
def smaliextractor(self, apk_name):
smali_de(apk_name)
# Recompile smali back into APK
def smalirecompile(self, apk_name):
smali_re(apk_name)
# Check for string injection points
def smali_inj(self, apk_name):
inj_check(apk_name)
# Identify and dump the disassembly of the native libraries within the APK
def nativedebug(self, apk_name):
native_disas(apk_name)
# Install the APK in an emulator and analyze its activities
def dynamicanalysis(self, apk_name):
adb_con(apk_name)
# Main fuction starts here
def main():
adhrit = Adhrit()
parser = argparse.ArgumentParser(description="Help")
parser.add_argument("-a", help="Dump package info and extract contents")
parser.add_argument("-r", help="Analyze APK without extraction")
parser.add_argument("-x", help="Extract APK contents only")
parser.add_argument("-s", help="Source code of the APK in Smali")
parser.add_argument("-b", help="Recompile smali back into APK")
parser.add_argument("-i", help="Check for injection points")
parser.add_argument("-n", help="Disassemble native libraries")
parser.add_argument("-w", help="Welcome :P")
parser.add_argument("-v", help="Check footprints in VirusTotal database")
parser.add_argument("-d", help="Analyse the behaviour dynamically in a VM")
args = parser.parse_args()
if args.a:
adhrit.welcome()
adhrit.apkripper(args.a)
adhrit.vtanalyzer(args.a)
adhrit.apkextractor(args.a)
adhrit.smaliextractor(args.a)
adhrit.nativedebug(args.a)
elif args.r:
adhrit.welcome()
adhrit.apkripper(args.r)
elif args.x:
adhrit.welcome()
adhrit.apkextractor(args.x)
elif args.s:
adhrit.welcome()
adhrit.smaliextractor(args.s)
elif args.b:
adhrit.welcome()
adhrit.smalirecompile(args.b)
elif args.i:
adhrit.welcome()
adhrit.smali_inj(args.i)
elif args.n:
adhrit.nativedebug(args.n)
elif args.w:
adhrit.welcome()
elif args.v:
adhrit.welcome()
adhrit.vtanalyzer(args.v)
elif args.d:
adhrit.welcome()
adhrit.dynamicanalysis(args.d)
if __name__ == "__main__":
main()