|
| 1 | +__artifacts_v2__ = { |
| 2 | + "DND_knowledgeC": { |
| 3 | + "name": "DNDknowledgeC", |
| 4 | + "description": "Do not Disturb Status from knowledgeC database. Based on research by Geraldine Blay and Dan Ogden", |
| 5 | + "author": "Geraldine Blay", |
| 6 | + "version": "0.0.1", |
| 7 | + "date": "2024-02-20", |
| 8 | + "requirements": "none", |
| 9 | + "category": "KnowledgeC", |
| 10 | + "notes": "", |
| 11 | + "paths": ('*/mobile/Library/CoreDuet/Knowledge/knowledgeC.db*',), |
| 12 | + "function": "get_DNDknowledgeC_state" |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +import plistlib |
| 17 | +from scripts.artifact_report import ArtifactHtmlReport |
| 18 | +from scripts.ilapfuncs import logfunc, tsv, timeline, open_sqlite_db_readonly, does_column_exist_in_db, convert_ts_human_to_utc, convert_utc_human_to_timezone |
| 19 | + |
| 20 | + |
| 21 | +def get_DNDknowledgeC_state(files_found, report_folder, seeker, wrap_text, timezone_offset): |
| 22 | + for file_found in files_found: |
| 23 | + file_found = str(file_found) |
| 24 | + |
| 25 | + if file_found.endswith('knowledgeC.db'): |
| 26 | + break |
| 27 | + |
| 28 | + db = open_sqlite_db_readonly(file_found) |
| 29 | + cursor = db.cursor() |
| 30 | + |
| 31 | + # Do Not Disturb Status |
| 32 | + |
| 33 | + cursor.execute(''' |
| 34 | + SELECT |
| 35 | + datetime(ZOBJECT.ZSTARTDATE + 978307200, 'unixepoch') AS 'Start Time', |
| 36 | + datetime(ZOBJECT.ZENDDATE + 978307200, 'unixepoch') AS 'End Time', |
| 37 | + CASE |
| 38 | + ZOBJECT.ZVALUEINTEGER |
| 39 | + WHEN '0' THEN 'No' |
| 40 | + WHEN '1' THEN 'Yes' |
| 41 | + ELSE 'Not Specified' |
| 42 | + END AS 'Is Do Not Disturb On?', |
| 43 | + |
| 44 | + datetime(ZOBJECT.ZCREATIONDATE + 978307200, 'unixepoch') AS 'Date Added' |
| 45 | + FROM ZOBJECT |
| 46 | + WHERE ZOBJECT.ZSTREAMNAME = '/settings/doNotDisturb' |
| 47 | + ORDER BY ZOBJECT.ZSTARTDATE |
| 48 | + ''') |
| 49 | + |
| 50 | + all_rows = cursor.fetchall() |
| 51 | + usageentries = len(all_rows) |
| 52 | + |
| 53 | + if usageentries > 0: |
| 54 | + data_list = [] |
| 55 | + for row in all_rows: |
| 56 | + start_time = convert_ts_human_to_utc(row[0]) |
| 57 | + start_time = convert_utc_human_to_timezone(start_time,timezone_offset) |
| 58 | + |
| 59 | + end_time = convert_ts_human_to_utc(row[1]) |
| 60 | + end_time = convert_utc_human_to_timezone(end_time,timezone_offset) |
| 61 | + |
| 62 | + added_time = convert_ts_human_to_utc(row[3]) |
| 63 | + added_time = convert_utc_human_to_timezone(added_time,timezone_offset) |
| 64 | + |
| 65 | + data_list.append((start_time, end_time, row[2], added_time)) |
| 66 | + |
| 67 | + description = "Do Not Disturb Status from knowledgeC Database" |
| 68 | + report = ArtifactHtmlReport('knowledgeC - Do Not Disturb') |
| 69 | + report.start_artifact_report(report_folder, 'knowledgeC - Do Not Disturb', description) |
| 70 | + report.add_script() |
| 71 | + |
| 72 | + data_headers = ('Start Time', 'End Time', 'Do Not Disturb?', 'Time Added') |
| 73 | + report.write_artifact_data_table(data_headers, data_list, file_found) |
| 74 | + report.end_artifact_report() |
| 75 | + |
| 76 | + tsvname = 'knowledgeC - Do Not Disturb' |
| 77 | + tsv(report_folder, data_headers, data_list, tsvname) |
| 78 | + |
| 79 | + tlactivity = 'knowledgeC - Do Not Disturb' |
| 80 | + timeline(report_folder, tlactivity, data_list, data_headers) |
| 81 | + |
| 82 | + else: |
| 83 | + logfunc('No Do Not Disturb events found in knowledgeC database') |
| 84 | + |
| 85 | + |
| 86 | + db.close() |
| 87 | + |
0 commit comments