This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shattered.py
251 lines (199 loc) · 10.9 KB
/
shattered.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
#!/usr/bin/env python3
##################################################################################
## ##
## _____ _ _ _ _ ##
## | __| |_ ___| |_| |_ ___ ___ ___ _| | ##
## |__ | | .'| _| _| -_| _| -_| . | ##
## |_____|_|_|__,|_| |_| |___|_| |___|___| ##
## ##
## ##
## Special Thanks to Julie Desautels, Jon Rajewski, and the LCDI for the ##
## research leading to the success of this script. ##
## ##
## Copyright 2013, Chapin Bryce ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation, either version 3 of the License, or ##
## any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
##################################################################################
"""@package Shattered
This script is built to acquire artifacts from Google Glass in a forensic manner.
Built at the LCDI at Champlain College. Learn More at http://lcdi.champlain.edu
"""
import _thread
import subprocess
import sys
import shutil
import os
import time
#Import Custom Modules
#from logcat_lib import *
def shattered_version():
"""
This function prints the version of the code.
"""
version = 201402192
print("Shattered Acquisition version: ", version)
def adb_path():
"""
This function checks the installation of adb to ensure it is correctly enabled as an executable in a /bin directory
If the check fails, it reccomends the user should run 'sudo ln -s adb /usr/local/bin/adb' to correct the issue
Set this up!
"""
subprocess.call("adb root", shell=True)
def get_serialno():
"""
This command gathers the device serial number and saves it for use later, returning it out of the function
"""
sno_cmd = "adb get-serialno"
sno = os.popen(sno_cmd).read()
sno = sno.strip("\n")
print(sno)
return sno
def prep_dir(outdir, sno):
"""
This function creates the necessary directories for information to be placed within the case directory.
Needs to be updated to use os.mkdir instead of yet another subrocess command
"""
subprocess.call("mkdir %r" % outdir, shell=True)
subprocess.call("mkdir %r/fs-%r" % (outdir,sno), shell=True)
subprocess.call("mkdir %r/dumpsys" % outdir, shell=True)
def dumpsys(outdir):
"""This function runs dumpsys commands for the services available on Glass
:param outdir: Output Directory, str
:return:
"""
outdir = outdir + "/dumpsys"
services = ["SurfaceFlinger", "accessibility", "account", "activity", "alarm", "appwidget", "audio", "backup", "battery", "batteryinfo", "bluetooth", "bluetooth_a2dp", "clipboard", "connectivity", "content", "country_detector", "cpuinfo", "device_policy", "devicestoragemonitor", "diskstats", "drm.drmManager",
"dropbox", "entropy", "eye_gesture", "gfxinfo", "hardware", "hardware.dsswb", "head_gesture", "input_method", "location", "lockscreen", "media.audio_flinger", "media.audio_policy", "media.camera", "media.player", "meminfo", "mount", "netpolicy", "netstats", "network_management", "notification", "package",
"permission", "power", "samplingprofiler", "search", "sensorservice", "statusbar", "telephony.registry", "textservices", "throttle", "timeline", "uimode", "usagestats", "usb", "vibrator", "wallpaper", "wifi", "wifip2p", "window"]
x = len(services)
i = 0
while i < x:
dumpsys_cmd = "adb shell dumpsys " + services[i] + " | tee ./"+ outdir +"/dumpsys-" + services[i] + ".txt"
subprocess.call([dumpsys_cmd], shell=True)
i = i + 1
def sysinfo(outdir):
"""This function runs a series of system tools on Glass
:param outdir: Output Directory, str
:return:
"""
##Removed dumpsys due to instability in logfile termination
information = ["date", "df", "dmesg", "dumpstate", "id", "iptables","logcat", "lsof", "netcfg", "netstat", "mount", "pm", "printenv", "ps", "screencap", "service", "uptime"]
o = len(information)
u = 0
while u < o:
if information[u] == "logcat":
tool = "logcat -d -v long *:V"
outfile = "logcat"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
u = u + 1
elif information[u] == "iptables":
tool = "iptables -L"
outfile = "iptables"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
u = u + 1
elif information[u] == "service":
tool = "service list"
outfile = "service-list"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
u = u + 1
elif information[u] == "pm":
tool = "pm list features"
outfile = "package_manager-list-features"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
tool = "pm list permission-groups"
output = "package_manager-list-permission-groups"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
tool = "pm list permissions -g -f"
output = "package_manager-list-permission-groups"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
tool = "pm list libraries"
output = "package_manager-list-libraries"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
tool = "pm list packages"
output = "package_manager-list-packages"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
"pm get-install-location",
tool = "pm get-install-location"
output = "package_manager-get-install-location"
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
u += 1
else:
tool = information[u]
outfile = information[u]
sysinfo_cmd = "adb shell " + tool + " | tee ./" + outdir + "/" + outfile + ".txt"
subprocess.call([sysinfo_cmd], shell=True)
u += 1
def fspull(outdir):
"""This function runs a series of system tools on Glass.
Excluded Directories:
/proc
/dev
:param outdir: Output Directory, str
:return:
"""
directory = ["/acct", "/cache", "/charger", "/config", "/d", "/data", "/default.prop", "/etc", "/init", "/init.goldfish.rc", "/init.omap4430.bt.rc", "/init.omap4430.rc", "/init.omap4430.usb.rc", "/init.rc", "/mnt", "/res", "/root", "/sbin", "/sdcard", "/sys", "/system", "/ueventd,goldfish.rc", "ueventd.omap4430.rc",
"/ueventd.rc", "/vendor"]
y = len(directory)
t = 0
while t < y:
fspull_cmd = "adb pull " + directory[t] + " ./" + outdir + directory[t]
subprocess.call([fspull_cmd], shell=True)
t += 1
def zip_it_up(outdir):
"""Zip yup the findings into a container to prevent further modification
:param outdir: Output Directory, str
:return:
"""
subprocess.call("tar cfvz %r.tgz %r" % (outdir,outdir), shell=True)
subprocess.call("md5sum %r.tgz | tee %r.md5.txt" % (outdir,outdir), shell=True)
print ("Acquisition Complete!")
if __name__ == "__main__":
# Clear the command window and prepare prompt the user with some basic information.
subprocess.call("clear")
print(" _____ _ _ _ _ ")
print(" | __| |_ ___| |_| |_ ___ ___ ___ _| | ")
print(" |__ | | .'| _| _| -_| _| -_| . | ")
print(" |_____|_|_|__,|_| |_| |___|_| |___|___| \n")
shattered_version()
print(" Google Glass Forensic Tool\n\nBrought to you by:\nThe Leahy Center for Digital Investigation at Champlain"
"College\nLearn more at http://lcdi.champlain.edu\n\nSpecial Thanks to Julie Desautels and Jon Rajewski for the "
"research leading to the success of this script. \n\nCopyright 2013, Chapin Bryce \t GNU GLPv3\n\n")
print("Be sure to check http://code.google.com/p/shattered for frequent updates\n\n")
adb_path()
input("Ensure the device is connected via USB and you you are using root\npress ENTER to continue")
print("\n==================================================================\n")
subprocess.call("adb devices", shell=True)
input("If the device is present, press enter to continue or ^c to cancel")
#setup output
datetime = time.strftime("%Y%m%d%H%M%S")
casename = input ("Enter a Case Name: \t")
outdir = casename + '-' + datetime
sno = get_serialno()
prep_dir(outdir, sno)
outdir_sno = outdir + "/fs-" + sno
#run modules
dumpsys(outdir)
sysinfo(outdir)
fspull(outdir_sno)
zip_it_up(outdir)
print("Shattered Completed")