Repository navigation
Expand file tree
/
Copy pathgoogleFitGMS.py
More file actions
executable file
·66 lines (58 loc) · 2.59 KB
/
Copy pathgoogleFitGMS.py
File metadata and controls
executable file
·66 lines (58 loc) · 2.59 KB
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
# Google Fit (GMS)
# Author: Josh Hickman (josh@thebinaryhick.blog)
# Date 2021-02-05
# Version: 0.1
# Note: This module only parses the Google Fit database found in com.google.android.gms/databases
import os
import sqlite3
import textwrap
from scripts.artifact_report import ArtifactHtmlReport
from scripts.ilapfuncs import logfunc, tsv, timeline, is_platform_windows, open_sqlite_db_readonly
def get_googleFitGMS(files_found, report_folder, seeker, wrap_text):
for file_found in files_found:
file_found = str(file_found)
# if not file_found.endswith('fitness.db'):
# continue # Skip all other files
db = open_sqlite_db_readonly(file_found)
cursor = db.cursor()
cursor.execute('''
SELECT
datetime(Sessions.start_time/1000,'unixepoch') AS "Activity Start Time",
datetime(Sessions.end_time/1000,'unixepoch') AS "Activity End Time",
Sessions.app_package AS "Contributing App",
CASE
WHEN Sessions.activity=7 THEN "Walking"
WHEN Sessions.activity=8 THEN "Running"
WHEN Sessions.activity=72 THEN "Sleeping"
ELSE Sessions.activity
END AS "Activity Type",
Sessions.name AS "Activity Name",
Sessions.description AS "Activity Description"
FROM
Sessions
ORDER BY "Activity Start Time" ASC
''')
all_rows = cursor.fetchall()
usageentries = len(all_rows)
if usageentries > 0:
report = ArtifactHtmlReport('Google Fit (GMS)')
report.start_artifact_report(report_folder, 'Activity Sessions')
report.add_script()
data_headers = ('Activity Start Time','Activity End Time','Contributing App','Activity Type','Activity Name','Activity Description')
data_list = []
for row in all_rows:
data_list.append((row[0],row[1],row[2],row[3],row[4],row[5]))
report.write_artifact_data_table(data_headers, data_list, file_found)
report.end_artifact_report()
tsvname = f'Google Fit (GMS) - Activity Sessions'
tsv(report_folder, data_headers, data_list, tsvname)
tlactivity = f'Google Fit (GMS) - Activity Sessions'
timeline(report_folder, tlactivity, data_list, data_headers)
else:
logfunc('No Google Fit (GMS) - Activity Sessions data available')
__artifacts__ = {
"GoogleFitGMS": (
"Google Fit (GMS)",
('*/data/data/com.google.android.gms/databases/fitness.db.*'),
get_googleFitGMS)
}