-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathamtracker.py
290 lines (277 loc) · 11.4 KB
/
amtracker.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/usr/bin/python
__author__ = "Jacob Soo Lead Re"
__version__ = "0.1"
import zipfile, sys, os, re
import base64, zlib, urllib
import yara
import argparse
from typing import List
from sys import argv
from androguard.core.bytecodes import apk
from androguard.core.bytecodes import dvm
from androguard.core.bytecodes.apk import APK
from androguard.core.bytecodes.dvm import DalvikVMFormat
from androguard.core.analysis import analysis
from androguard.decompiler.decompiler import DecompilerJADX
from amtracker.core.AhMyth import AhMyth
from amtracker.core.AndroRat import AndroRat
from amtracker.core.APT_C_23 import APT_C_23
from amtracker.core.APT_C_27 import APT_C_27
from amtracker.core.APT41 import APT41
from amtracker.core.BankBot import BankBot
from amtracker.core.BladeHawk import BladeHawk
from amtracker.core.CapraRAT import CapraRAT
from amtracker.core.ChinaSMSStealer import ChinaSMSStealer
from amtracker.core.Dendroid import Dendroid
from amtracker.core.EventBot import EventBot
from amtracker.core.FakeSpy import FakeSpy
from amtracker.core.FlexBotnet import FlexBotnet
from amtracker.core.MMRat import MMRat
from amtracker.core.moqhao import moqhao
from amtracker.core.MuddyWater import MuddyWater
from amtracker.core.Piom import Piom
from amtracker.core.Saefko import Saefko
from amtracker.core.SandroRat import SandroRat
from amtracker.core.spynote import spynote
from amtracker.core.SyrianMT import SyrianMT
from amtracker.core.TeleRat import TeleRat
from amtracker.core.Triout import Triout
from amtracker.core.Vamp import Vamp
from amtracker.core.WhiteBroad import WhiteBroad
from amtracker.core.Xenomorph import Xenomorph
android_family = ["BladeHawk", "AndroRat", "AhMyth", "apt-c-23", "apt-c-27", "APT41", "BankBot", "CapraRAT", "ChinaSMSStealer", "Dendroid", "EventBot", "FakeSpy", "FlexBotnet", "MMRat", "moqhao", "MuddyWater", "Piom", "Saefko", "SandroRat", "spynote", "SyrianMT", "TeleRat", "Triout", "Vamp", "WhiteBroad", "Xenomorph"]
#---------------------------------------------------
# isNotEmpty : Checks whether string is empty
#---------------------------------------------------
def isNotEmpty(s):
return bool(s and s.strip())
#---------------------------------------------------
# _log : Prints out logs for debug purposes
#---------------------------------------------------
def _log(s):
print(s)
#-------------------------------------------------------------
# check_apk_file : Shitty Check whether file is a apk file.
#-------------------------------------------------------------
def check_apk_file(apk_file):
bJar = False
try:
zf = zipfile.ZipFile(apk_file, 'r')
lst = zf.infolist()
for zi in lst:
fn = zi.filename
if fn.lower()=='androidmanifest.xml':
bJar = True
return bJar
except:
return bJar
#------------------------------------------------------------------------
# verifyMalware : This verify what android family this sample belongs to.
#------------------------------------------------------------------------
def verifyMalware(apkfile):
bRes = False
for family in android_family:
if family=="BladeHawk":
analysis = BladeHawk()
_log("[+] Verifying if it's BladeHawk.")
bRes = analysis.verifyBladeHawk(apkfile)
if bRes==True:
break
elif family=="APT41":
analysis = APT41()
_log("[+] Verifying if it's APT41.")
bRes = analysis.verifyAPT41(apkfile)
if bRes==True:
break
elif family=="AndroRat":
analysis = AndroRat()
_log("[+] Verifying if it's AndroRat.")
bRes = analysis.verifyAndroRat(apkfile)
if bRes==True:
break
elif family=="AhMyth":
analysis = AhMyth()
_log("[+] Verifying if it's AhMyth.")
bRes = analysis.verifyAhMyth(apkfile)
if bRes==True:
break
elif family=="apt-c-23":
analysis = APT_C_23()
_log("[+] Verifying if it's APT-C-23.")
bRes = analysis.verifyAPT_C_23(apkfile)
if bRes==True:
break
elif family=="apt-c-27":
analysis = APT_C_27()
_log("[+] Verifying if it's APT-C-27.")
bRes = analysis.verifyAPT_C_27(apkfile)
if bRes==True:
break
elif family=="BankBot":
analysis = BankBot()
_log("[+] Verifying if it's BankBot.")
bRes = analysis.verifyBankBot(apkfile)
if bRes==True:
break
elif family=="CapraRAT":
analysis = CapraRAT()
_log("[+] Verifying if it's CapraRAT.")
bRes = analysis.verifyCapraRAT(apkfile)
if bRes==True:
break
elif family=="ChinaSMSStealer":
analysis = ChinaSMSStealer()
_log("[+] Verifying if it's ChinaSMSStealer.")
bRes = analysis.verifyChinaSMSStealer(apkfile)
if bRes==True:
break
elif family=="Dendroid":
analysis = Dendroid()
_log("[+] Verifying if it's Dendroid.")
bRes = analysis.verifyDendroid(apkfile)
if bRes==True:
break
elif family=="EventBot":
analysis = EventBot()
_log("[+] Verifying if it's EventBot.")
bRes = analysis.verifyEventBot(apkfile)
if bRes==True:
break
elif family=="FakeSpy":
analysis = FakeSpy()
_log("[+] Verifying if it's FakeSpy.")
bRes = analysis.verifyFakeSpy(apkfile)
if bRes==True:
break
elif family=="FlexBotnet":
analysis = FlexBotnet()
_log("[+] Verifying if it's FlexBotnet.")
bRes = analysis.verifyFlexBotnet(apkfile)
if bRes==True:
break
elif family=="MMRat":
analysis = MMRat()
_log("[+] Verifying if it's MMRat.")
bRes = analysis.verifyMMRat(apkfile)
if bRes==True:
break
elif family=="moqhao":
analysis = moqhao()
_log("[+] Verifying if it's Moqhao.")
bRes = analysis.verifyMoqhao(apkfile)
if bRes==True:
break
elif family=="MuddyWater":
analysis = MuddyWater()
_log("[+] Verifying if it's MuddyWater.")
bRes = analysis.verifyMuddyWater(apkfile)
if bRes==True:
break
elif family=="Piom":
analysis = Piom()
_log("[+] Verifying if it's Piom.")
bRes = analysis.verifyPiom(apkfile)
if bRes==True:
break
elif family=="Saefko":
analysis = Saefko()
_log("[+] Verifying if it's Saefko.")
bRes = analysis.verifySaefko(apkfile)
if bRes==True:
break
elif family=="SandroRat":
analysis = SandroRat()
_log("[+] Verifying if it's SandroRat.")
bRes = analysis.verifySandroRat(apkfile)
if bRes==True:
break
elif family=="spynote":
analysis = spynote()
_log("[+] Verifying if it's SpyNote.")
bRes = analysis.verifySpyNote(apkfile)
if bRes==True:
break
elif family=="SyrianMT":
analysis = SyrianMT()
_log("[+] Verifying if it's SyrianMT.")
bRes = analysis.verifySyrianMT(apkfile)
if bRes==True:
break
elif family=="TeleRat":
analysis = TeleRat()
_log("[+] Verifying if it's TeleRat.")
bRes = analysis.verifyTeleRat(apkfile)
if bRes==True:
break
elif family=="Triout":
analysis = Triout()
_log("[+] Verifying if it's Triout.")
bRes = analysis.verifyTriout(apkfile)
if bRes==True:
break
elif family=="Vamp":
analysis = Vamp()
_log("[+] Verifying if it's Vamp.")
bRes = analysis.verifyVamp(apkfile)
if bRes==True:
break
elif family=="WhiteBroad":
analysis = WhiteBroad()
_log("[+] Verifying if it's WhiteBroad.")
bRes = analysis.verifyWhiteBroad(apkfile)
if bRes==True:
break
elif family=="Xenomorph":
analysis = Xenomorph()
_log("[+] Verifying if it's Xenomorph.")
bRes = analysis.verifyXenomorph(apkfile)
if bRes==True:
break
#-------------------------------------------------------------
# logo : Ascii Logos like the 90s. :P
#-------------------------------------------------------------
def logo():
print('\n')
print(' ______ __ __ __ ______ ______ ______ ______ ______ __ __ ______ __ __ ')
print('/\ ___\ /\ \_\ \ /\ \ /\__ _\ /\ ___\ /\ == \ /\ == \ /\ __ \ /\ \/ / /\ ___\ /\ "-.\ \ ')
print('\ \___ \ \ \ __ \ \ \ \ \/_/\ \/ \ \___ \ \ \ __< \ \ __< \ \ \/\ \ \ \ _"-. \ \ __\ \ \ \-. \ ')
print(' \/\_____\ \ \_\ \_\ \ \_\ \ \_\ \/\_____\ \ \_____\ \ \_\ \_\ \ \_____\ \ \_\ \_\ \ \_____\ \ \_\\\\"\_\\')
print(' \/_____/ \/_/\/_/ \/_/ \/_/ \/_____/ \/_____/ \/_/ /_/ \/_____/ \/_/\/_/ \/_____/ \/_/ \/_/')
print('\n')
print(" Extract intel from this Android mallie!")
print(" Jacob Soo")
print(" Copyright (c) 2018-2022\n")
if __name__ == "__main__":
description='C&C Extraction tool for Android Malware'
parser = argparse.ArgumentParser(description=description,
epilog='--file and --directory are mutually exclusive')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-f','--file',action='store',nargs=1,dest='szFilename',help='filename',metavar="filename")
group.add_argument('-d','--directory',action='store',nargs=1,dest='szDirectory',help='Location of directory.',metavar='directory')
args = parser.parse_args()
Filename = args.szFilename
Directory = args.szDirectory
is_file = False
is_dir = False
try:
is_file = os.path.isfile(Filename[0])
except:
pass
try:
is_dir = os.path.isdir(Directory[0])
except:
pass
logo()
if Filename is not None and is_file:
if check_apk_file(Filename[0])==True:
verifyMalware(Filename[0])
else:
print("This is not a valid apk file : %s" % Filename[0])
if Directory is not None and is_dir:
for root, directories, filenames in os.walk(Directory[0]):
for filename in filenames:
szFile = os.path.join(root,filename)
if check_apk_file(szFile)==True:
verifyMalware(szFile)
else:
print("This is not a valid apk file : %s" % szFile)