-
Notifications
You must be signed in to change notification settings - Fork 1
/
parser_AXIOMtoCASE.py
3061 lines (2882 loc) · 114 KB
/
parser_AXIOMtoCASE.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# xml_sax_UFED_to_CASE: UFED SAX parser from XML report to CASE-JSON-LD
#
import xml.sax
import argparse
import os
import codecs
import AXIOMtoJSON as CJ
#from inspectrutils.case_builder import *
import timeit
from time import localtime, strftime
# import logging
class AXIOMparser():
'''
It represents all attributes and methods to process the traces extracted from XML reports by using
the SAX parser.
'''
def __init__(self, report_xml=None, json_output=None, report_type=None,
base_local_path="", case_bundle=None, verbose=False):
'''
It initialises the main attributes for processing the XML report.
:param report_xml: The filename of the XML report, provided as argumnent in the command line (string).
:param json_output: The filename of the JSON-LD to be generated, provided as argumnent in the command line (string).
:param case_bundle: The container of all Objects in the JSON-LD file (list).
:param mode_verbose: True if the processing progress will be shown in the standard output (boolean).
'''
self.xmlReport = report_xml
self.jsonCASE = json_output
self.reportType = report_type
self.baseLocalPath = os.path.join(base_local_path, 'Attachments')
self.tic_start = timeit.default_timer()
self.bundle = case_bundle
self.verbose = verbose
# logging.basicConfig(filename='_axiom_log.txt', level=logging.INFO,
# filemode='w', format='%(asctime)s - %(levelname)s - %(message)s')
# logging.basicConfig(filename='_ufed_log.txt', level=logging.INFO,
# filemode='w', format='%(message)s')
def show_elapsed_time(self, tic, message):
'''
It shows the processing time gone.
:param tic: The initial time for calculating the processing time passed (float).
:param message: The message to be shown (string).
:return: None.
'''
toc = timeit.default_timer()
C_CYAN = '\033[36m'
C_BLACK = '\033[0m'
elapsed_seconds = round(toc - tic, 2)
(ss, ms) = divmod(elapsed_seconds, 1)
elapsedMm = str(int(ss) // 60)
elapsedSs = str(int(ss) % 60)
elapsedMs = str(round(ms, 2))[2:]
elapsed_time = elapsedMm + ' min. ' + elapsedSs + ' sec. and ' + \
elapsedMs + ' hundredths'
if self.verbose:
print('\n' + C_CYAN + 'elapsed time - ' + message + ': ' + elapsed_time + '\n' + C_BLACK)
def processXmlReport(self):
'''
It implements the SAX parser overriding the default ContextHandler method.
:return: Handler of the JSON-LD file created.
'''
SAXparser = xml.sax.make_parser()
Handler = ExtractTraces(self.baseLocalPath, self.verbose)
Handler.createOutFile(self.jsonCASE)
SAXparser.setContentHandler(Handler)
SAXparser.parse(self.xmlReport)
self.show_elapsed_time(self.tic_start, 'Extraction Traces')
if self.verbose:
print('\n\n\nCASE JSON-LD file is being generated ...')
tic_case_start = timeit.default_timer()
if self.reportType == 'mobile':
if self.verbose:
print("".join([Handler.C_cyan, "owner's phone number / name: ", Handler.CALLphoneNumberDevice,
' / ', Handler.CALLphoneNameDevice, '\n', Handler.C_end]))
#--- create object and open JSON file and define the boolean value that
# indicates if the line with comma plus return must be written before
# writing the next ObservableObject
caseTrace = CJ.AXIOMtoJSON(json_output=Handler.fOut, case_bundle=self.bundle)
#--- write CASE @context, version and description JSON file
caseTrace.writeHeader()
#--- write phoneAccountFacet for the device phone number
if self.reportType == 'mobile':
caseTrace.writeDeviceMobile(Handler.DEVICEidText, Handler.DEVICEimsiText,
Handler.DEVICEbluetoothAddressText, Handler.DEVICEbluetoothNameText,
Handler.DEVICEimeiText, Handler.DEVICEserialNumberText,
Handler.DEVICEnameText, Handler.DEVICEmodelText, Handler.DEVICEiccidText,
Handler.DEVICEosVersionText)
caseTrace.writePhoneOwner(Handler.CALLphoneNumberDevice,
Handler.CALLphoneNameDevice)
caseTrace.writePhoneAccountFromContacts(Handler.CONTACTname,
Handler.CONTACTphoneNumber)
else:
caseTrace.writeDeviceDisk(Handler.FILE_SYS_INFOvolumeSn,
Handler.FILE_SYS_INFOfileSystem, Handler.FILE_SYS_INFOcapacity,
Handler.FILE_SYS_INFOunallocated, Handler.FILE_SYS_INFOallocated,
Handler.FILE_SYS_INFOoffset)
caseTrace.writeFiles(Handler.FILEid, Handler.FILEtag, Handler.FILEfileName,
Handler.FILEfileLocalPath, Handler.FILEimage, Handler.FILEfileSize,
Handler.FILEcreated, Handler.FILEmodified, Handler.FILEaccessed,
Handler.FILEmd5, Handler.FILEexifMake, Handler.FILEexifModel,
Handler.FILEexifLatitudeRef, Handler.FILEexifLatitude,
Handler.FILEexifLongitudeRef, Handler.FILEexifLongitude, Handler.FILEexifAltitude,
Handler.FILEsource, Handler.FILElocation,
Handler.FILErecoveryMethod)
if self.reportType == 'mobile':
caseTrace.writeCall(Handler.CALLid, Handler.CALLappName, Handler.CALLtimeStamp,
Handler.CALLdirection, Handler.CALLduration, Handler.CALLpartner,
Handler.CALLpartnerName, Handler.CALLsource, Handler.CALLlocation,
Handler.CALLrecoveryMethod)
caseTrace.writeCell_Tower(Handler.CELL_TOWERid, Handler.CELL_TOWERmcc,
Handler.CELL_TOWERmnc, Handler.CELL_TOWERlac, Handler.CELL_TOWERcid,
Handler.CELL_TOWERlongitude,Handler.CELL_TOWERlatitude,
Handler.CELL_TOWERtimeStamp, Handler.CELL_TOWERsource,
Handler.CELL_TOWERlocation, Handler.CELL_TOWERrecoveryMethod)
caseTrace.writeWireless_Net(Handler.WIRELESS_NETid, Handler.WIRELESS_NETmacAddress,
Handler.WIRELESS_NETchannel, Handler.WIRELESS_NETlongitude,
Handler.WIRELESS_NETlatitude, Handler.WIRELESS_NETtimeStamp,
Handler.WIRELESS_NETaccuracy, Handler.WIRELESS_NETsource,
Handler.WIRELESS_NETlocation, Handler.WIRELESS_NETrecoveryMethod)
caseTrace.writeDeviceEvent(Handler.EVENT_LOCKid, Handler.EVENT_LOCKdeviceStatus,
Handler.EVENT_LOCKdateTime, Handler.EVENT_LOCKsource,
Handler.EVENT_LOCKlocation, Handler.EVENT_LOCKrecoveryMethod)
caseTrace.writeAppUsage(Handler.EVENT_APP_USEid, Handler.EVENT_APP_USEapplication,
Handler.EVENT_APP_USEstartTime, Handler.EVENT_APP_USEendTime,
Handler.EVENT_APP_USEsource, Handler.EVENT_APP_USElocation,
Handler.EVENT_APP_USErecoveryMethod)
caseTrace.writeSearched_Item(Handler.SEARCHED_ITEMid, Handler.SEARCHED_ITEMvalue,
Handler.SEARCHED_ITEMtimeStamp, Handler.SEARCHED_ITEMappSource,
Handler.SEARCHED_ITEMsource, Handler.SEARCHED_ITEMlocation,
Handler.SEARCHED_ITEMrecoveryMethod)
caseTrace.writeSms(Handler.SMSid, Handler.SMSsender,
Handler.SMSrecipient, Handler.SMSreceivedDateTime,
Handler.SMSsentDateTime, Handler.SMSmessage, Handler.SMSdirection,
Handler.SMSsource, Handler.SMSlocation, Handler.SMSrecoveryMethod)
caseTrace.writeChat(Handler.CHATid, Handler.CHATsender, Handler.CHATreceiver,
Handler.CHATdateTimeSent, Handler.CHATdateTimeReceived,
Handler.CHATmessage, Handler.CHATmessageStatus,
Handler.CHATapplication, Handler.CHATsource,
Handler.CHATlocation, Handler.CHATrecoveryMethod)
caseTrace.writeCookie(Handler.COOKIEid, Handler.COOKIEappSource, Handler.COOKIEname,
Handler.COOKIEpath, Handler.COOKIEdomain, Handler.COOKIEcreatedDate,
Handler.COOKIEaccessedDate, Handler.COOKIEexpirationDate,
Handler.COOKIEsource, Handler.COOKIElocation, Handler.COOKIErecoveryMethod)
caseTrace.writeEmail(Handler.EMAILid, Handler.EMAILappSource, Handler.EMAILsender,
Handler.EMAILrecipient, Handler.EMAILcc, Handler.EMAILbcc,
Handler.EMAILbody, Handler.EMAILsubject, Handler.EMAILdateTime,
Handler.EMAILattachment, Handler.EMAILsource,
Handler.EMAILlocation, Handler.EMAILrecoveryMethod)
caseTrace.writeWinTimeline(Handler.WIN_TIMELINEid, Handler.WIN_TIMELINEappName,
Handler.WIN_TIMELINEactivityType, Handler.WIN_TIMELINEtimeStamp,
Handler.WIN_TIMELINEsource, Handler.WIN_TIMELINElocation,
Handler.WIN_TIMELINErecoveryMethod)
caseTrace.writeLocationDevice(Handler.LOCATIONid, Handler.LOCATIONtype,
Handler.LOCATIONlatitude, Handler.LOCATIONlongitude, Handler.LOCATIONcreated,
Handler.LOCATIONsource, Handler.LOCATIONlocation)
caseTrace.writeWebPages(Handler.WEBid, Handler.WEBappSource,
Handler.WEBurl, Handler.WEBtitle, Handler.WEBvisitCount,
Handler.WEBlastVisited, Handler.WEBsource,
Handler.WEBlocation, Handler.WEBrecoveryMethod)
#--- JSON final line
caseTrace.writeLastLine()
self.show_elapsed_time(tic_case_start, 'Generation CASE JSON-LD file')
Handler.fOut.close()
return Handler
class ExtractTraces(xml.sax.ContentHandler):
'''
Used to extract the Traces from the XML reports and fill in the appropriate structure before generatign the JSON-LD file.
'''
def __init__(self, baseLocalPath, verbose):
self.fOut = ''
self.lineXML = 0
self.skipLine = False
self.verbose = verbose
self.inHit = False
self.Observable = False
self.C_green = '\033[32m'
self.C_grey = '\033[37m'
self.C_red = '\033[31m'
self.C_cyan = '\033[36m'
self.C_end = '\033[0m'
#--- DEVICE INFO
self.DEVICE_PATTERN = ('Android Device Information', 'iOS Device Information')
self.DEVICEin = False
self.DEVICEinSerialNumber = False
self.DEVICEinId = False
self.DEVICEinName = False
self.DEVICEinImsi = False
self.DEVICEinBluetoothAddress = False
self.DEVICEinBluetoothName = False
self.DEVICEinImei = False
self.DEVICEinIccid = False
self.DEVICEinModel = False
self.DEVICEinOsVersion = False
self.DEVICEserialNumberText = ''
self.DEVICEidText = ''
self.DEVICEnameText = ''
self.DEVICEimsiText = ''
self.DEVICEimeiText = ''
self.DEVICEbluetoothAddressText = ''
self.DEVICEbluetoothNameText = ''
self.DEVICEmodelText = ''
self.DEVICEiccidText = ''
self.DEVICEosVersionText = ''
#--- CALL section
self.CALL_PATTERN = ('Android Call Logs', 'iOS Call Logs')
self.CALLin = False
self.CALLinPartner = False
self.CALLinPartnerName = False
self.CALLinDirection = False
self.CALLinTimeStamp = False
self.CALLinDuration = False
self.CALLinSource = False
self.CALLinLocation = False
self.CALLinRecoveryMethod = False
#--- Device phone number
# //Artifact[@name="Android WhatsApp Accounts Information"]
# /Hits/Hit/Fragment[@name="Phone Number"]
self.CALL_PHONE_NUM_DEVICEin = False
self.CALL_PHONE_NUM_DEVICE_VALUEin = False
self.CALL_PHONE_NAME_DEVICE_VALUEin = False
self.CALLpartnerText = ''
self.CALLpartnerNameText = ''
self.CALLdirectionText = ''
self.CALLtimeStampText = ''
self.CALLdurationText = ''
self.CALLsourceText = ''
self.CALLlocationText = ''
self.CALLrecoveyMethodText = ''
self.CALLappNameText = ''
self.CALLphoneNumberDevice = 'DEVICE_PHONE_NUMBER'
self.CALLphoneNameDevice = ''
self.CALLtotal = 0
self.CALLid = []
self.CALLappName = []
self.CALLpartner = []
self.CALLpartnerName = []
self.CALLdirection = []
self.CALLtimeStamp = []
self.CALLduration = []
self.CALLsource = []
self.CALLlocation = []
self.CALLrecoveryMethod = []
#--- The CELL TOWER Artifact, Cellsite class in UCO/CASE
self.CELL_TOWER_PATTERN = ('Cell Tower Locations')
self.CELL_TOWERin = False
self.CELL_TOWERinCID= False
self.CELL_TOWERinLAC= False
self.CELL_TOWERinMCC= False
self.CELL_TOWERinMNC = False
self.CELL_TOWERinTimeStamp = False
self.CELL_TOWERinLatitude = False
self.CELL_TOWERinLongitude = False
self.CELL_TOWERinSource = False
self.CELL_TOWERinLocation = False
self.CELL_TOWERinRecoveryMethod = False
self.CELL_TOWERmccText = ''
self.CELL_TOWERmncText = ''
self.CELL_TOWERlacText = ''
self.CELL_TOWERcidText = ''
self.CELL_TOWERlongitudeText = ''
self.CELL_TOWERlatitudeText = ''
self.CELL_TOWERtimeStampText = ''
self.CELL_TOWERsourceText = ''
self.CELL_TOWERlocationText = ''
self.CELL_TOWERrecoveryMethodText = ''
self.CELL_TOWERtotal = 0
self.CELL_TOWERid = []
self.CELL_TOWERlongitude = []
self.CELL_TOWERlatitude = []
self.CELL_TOWERtimeStamp = []
self.CELL_TOWERmcc = []
self.CELL_TOWERmnc = []
self.CELL_TOWERlac = []
self.CELL_TOWERcid = []
self.CELL_TOWERsource = []
self.CELL_TOWERlocation = []
self.CELL_TOWERrecoveryMethod = []
#--- CHAT section
self.CHAT_PATTERN = ('Android WhatsApp Messages', 'iOS WhatsApp Messages',
'Android Telegram Messages', 'iOS Telegram Messages', 'iOS Telegram Chats',
'Snapchat Chat Messages', 'TikTok Messages', 'Instagram Direct Messages',
'Signal Messages', 'Signal Messages - Windows', 'Signal Messages - iOS',
'Facebook Messenger Messages', 'Discord Messages', 'LINE Messages', 'Skype Activity',
'Telegram Messages - Android', 'Telegram Messages - iOS')
self.CHATin = False
self.CHATinSender = False
self.CHATinReceiver = False
self.CHATinDateTimeSent = False
self.CHATinDateTimeReceived = False
self.CHATinMessage = False
self.CHATinMessageStatus = False
self.CHATinSource = False
self.CHATinLocation = False
self.CHATinRecoveryMethod = False
#--- CHAT Telegram: fields are different from Whatsapp
self.CHATinPartner = False
self.CHATinDateTime = False
self.CHATinMessageType = False
self.CHATsenderText = ''
self.CHATreceiverText = ''
self.CHATpartnerText = ''
self.CHATdateTimeSentText = ''
self.CHATdateTimeReceivedText = ''
self.CHATdateTimeText = ''
self.CHATmessageText = ''
self.CHATmessageStatusText = ''
self.CHATmessageTypeText = ''
self.CHATsourceText = ''
self.CHATlocationText = ''
self.CHATrecoveryMethodText = ''
self.CHATapplicationText = ''
self.CHATtotal = 0
self.CHATid = []
self.CHATsender = []
self.CHATreceiver = []
self.CHATdateTimeSent = []
self.CHATdateTimeReceived = []
self.CHATmessage = []
self.CHATmessageStatus = []
self.CHATapplication = []
self.CHATsource = []
self.CHATlocation = []
self.CHATrecoveryMethod = []
#--- These are list of list: each item contains a list with all the data relating
# to the messages of a single Chat, because they are grouped in the same thread.
# Therefore the item i (Chat[i]) contains many text messages and each of them is
# stored in the item CHATmessages[i] that, actually, is a list. For instance, if
# the Chat[0] contains three messages whose body are "How are you?", "I',m fine, and you?"
# "So far so good", then the CHATmessages[0] is the following list
# ["How are you?", "I'm fine, and you?", "So far so good!"]
self.CHATids = []
self.CHATapplications = []
self.CHATsenders = []
self.CHATreceivers = []
self.CHATdateTimeSents = []
self.CHATdateTimeReceiveds = []
self.CHATmessages = []
self.CHATmessageStatuses = []
self.CHATsources = []
self.CHATlocations = []
self.CHATrecoveryMethods = []
self.CONTACT_PATTERN = ('Android Contacts', 'Apple Contacts - iOS')
self.CONTACTin = False
self.CONTACTinName = False
self.CONTACTinFirstName = False
self.CONTACTinLastName = False
self.CONTACTinPhoneNumber = False
self.CONTACTinSource = False
self.CONTACTinLocation = False
self.CONTACTinRecoveryMethod = False
self.CONTACTnameText = ''
self.CONTACTfirstNameText = ''
self.CONTACTlastNameText = ''
self.CONTACTphoneNumberText = ''
self.CONTACTsourceText = ''
self.CONTACTlocationText = ''
self.CONTACTrecoveryMethodText = ''
self.CONTACTtotal = 0
self.CONTACTid = []
self.CONTACTname = []
self.CONTACTphoneNumber = []
self.CONTACTsource = []
self.CONTACTlocation = []
self.CONTACTrecoveryMethod = []
#--- The Artifacts extracted are: Chrome Cookies,
self.COOKIE_PATTERN = ('Chrome Cookies', 'Edge Chromium Cookies', 'Firefox Cookies')
self.COOKIEin = False
self.COOKIEinName= False
self.COOKIEinPath= False
self.COOKIEinDomain = False
self.COOKIEinCreatedDate = False
self.COOKIEinAccessedDate = False
self.COOKIEinExpirationDate = False
self.COOKIEinSource = False
self.COOKIEinLocation = False
self.COOKIEinRecoveryMethod = False
self.COOKIEappSourceText = ''
self.COOKIEnameText = ''
self.COOKIEpathText = ''
self.COOKIEdomainText = ''
self.COOKIEcreatedDateText = ''
self.COOKIEaccessedDateText = ''
self.COOKIEexpirationDateText = ''
self.COOKIEsourceText = ''
self.COOKIElocationText = ''
self.COOKIErecoveryMethodText = ''
self.COOKIEtotal = 0
self.COOKIEid = []
self.COOKIEappSource = []
self.COOKIEname = []
self.COOKIEpath = []
self.COOKIEdomain = []
self.COOKIEcreatedDate = []
self.COOKIEaccessedDate = []
self.COOKIEexpirationDate = []
self.COOKIEsource = []
self.COOKIElocation = []
self.COOKIErecoveryMethod = []
#--- EVENT Artifacts
self.EVENT_LOCK_PATTERN = ('KnowledgeC Device Lock States')
self.EVENT_LOCKin = False
self.EVENT_LOCKinDeviceStatus= False
self.EVENT_LOCKinDateTime= False
self.EVENT_LOCKinSource = False
self.EVENT_LOCKinLocation = False
self.EVENT_LOCKinRecoveryMethod = False
self.EVENT_LOCKdeviceStatusText = ''
self.EVENT_LOCKdateTimeText = ''
self.EVENT_LOCKsourceText = ''
self.EVENT_LOCKlocationText = ''
self.EVENT_LOCKrecoveryMethodText = ''
self.EVENT_LOCKtotal = 0
self.EVENT_LOCKid = []
self.EVENT_LOCKdeviceStatus = []
self.EVENT_LOCKdateTime = []
self.EVENT_LOCKsource = []
self.EVENT_LOCKlocation = []
self.EVENT_LOCKrecoveryMethod = []
self.EVENT_APP_USE_PATTERN = ('KnowledgeC Application Usage')
self.EVENT_APP_USEin = False
self.EVENT_APP_USEinApplication= False
self.EVENT_APP_USEinStartTime= False
self.EVENT_APP_USEinEndTime= False
self.EVENT_APP_USEinSource = False
self.EVENT_APP_USEinLocation = False
self.EVENT_APP_USEinRecoveryMethod = False
self.EVENT_APP_USEapplicationText = ''
self.EVENT_APP_USEstartTimeText = ''
self.EVENT_APP_USEendTimeText = ''
self.EVENT_APP_USEsourceText = ''
self.EVENT_APP_USElocationText = ''
self.EVENT_APP_USErecoveryMethodText = ''
self.EVENT_APP_USEtotal = 0
self.EVENT_APP_USEid = []
self.EVENT_APP_USEapplication = []
self.EVENT_APP_USEstartTime = []
self.EVENT_APP_USEendTime = []
self.EVENT_APP_USEsource = []
self.EVENT_APP_USElocation = []
self.EVENT_APP_USErecoveryMethod = []
#--- EMAIL Artifacts, not yet extracted: Outlook Emails
self.EMAIL_PATTERN = ('Apple Mail', 'Gmail Emails', 'Android Emails', 'Apple Mail Fragments')
self.EMAILin = False
self.EMAILinSender= False
self.EMAILinRecipients= False
self.EMAILinCC = False
self.EMAILinBCC = False
self.EMAILinDateTime = False
self.EMAILinSubject = False
self.EMAILinBody = False
self.EMAILinAttachment = False
self.EMAILinSource = False
self.EMAILinLocation = False
self.EMAILinRecoveryMethod = False
self.EMAILsenderText = ''
self.EMAILrecipientText = ''
self.EMAILccText = ''
self.EMAILbccText = ''
self.EMAILdateTimeText = ''
self.EMAILsubjectText = ''
self.EMAILbodyText = ''
self.EMAILattachmentText = ''
self.EMAILsourceText = ''
self.EMAILlocationText = ''
self.EMAILrecoveryMethodText = ''
self.EMAILtotal = 0
self.EMAILid = []
self.EMAILappName = ''
self.EMAILappSource = []
self.EMAILsender = []
self.EMAILrecipient = []
self.EMAILcc = []
self.EMAILbcc = []
self.EMAILdateTime = []
self.EMAILsubject = []
self.EMAILbody = []
self.EMAILattachment = []
self.EMAILsource = []
self.EMAILlocation = []
self.EMAILrecoveryMethod = []
#--- FILE Artifacts
self.FILE_PATTERN =('Pictures', 'Videos', 'RTF Documents', 'Excel Documents',
'PowerPoint Documents', 'Audio', 'PDF Documents', 'Word Documents',
'WordPerfect Files', 'Calc Documents', 'Writer Documents', 'Text Documents',
'CSV Documents', 'Live Photos', 'TikTok Videos')
self.FILEin = False
self.FILEinTag = False
self.FILEinFileName = False
self.FILEinImage = False
self.FILEinFileExtension = False
self.FILEinFileSize = False
self.FILEinCreated = False
self.FILEinModified = False
self.FILEinAccessed = False
self.FILEinMD5 = False
self.FILEinExifLatitudeRef = False
self.FILEinExifLatitude = False
self.FILEinExifLongitudeRef = False
self.FILEinExifLongitude = False
self.FILEinExifAltitude = False
self.FILEinExifMake = False
self.FILEinExifModel = False
self.FILEinSource = False
self.FILEinLocation = False
self.FILEinRecoveryMethod = False
self.FILEtotal = 0
self.FILEtagText = ''
self.FILEfileNameText = ''
self.FILEimageText = ''
self.FILEfileExtensionText = ''
self.FILEbaseLocalPath = baseLocalPath
self.FILEfileSizeText = ''
self.FILEcreatedText = ''
self.FILEmodifiedText = ''
self.FILEaccessedText = ''
self.FILEmd5Text = ''
self.FILEexifMakeText = ''
self.FILEexifModelText = ''
self.FILEexifLatitudeRefText = ''
self.FILEexifLatitudeText = ''
self.FILEexifLongitudeRefText = ''
self.FILEexifLongitudeText = ''
self.FILEexifAltitudeText = ''
self.FILEsourceText = ''
self.FILElocationText = ''
self.FILErecoveryMethodText = ''
self.FILEid = []
self.FILEtag = []
self.FILEfileName = []
self.FILEfileLocalPath = []
self.FILEimage = []
self.FILEfileExtension = []
self.FILEfileSize = []
self.FILEcreated = []
self.FILEmodified = []
self.FILEaccessed = []
self.FILEmd5 = []
self.FILEexifMake = []
self.FILEexifModel = []
self.FILEexifLatitudeRef = []
self.FILEexifLatitude = []
self.FILEexifLongitudeRef = []
self.FILEexifLongitude = []
self.FILEexifAltitude = []
self.FILEsource = []
self.FILElocation = []
self.FILErecoveryMethod = []
#--- FILE SYSTEM INFORMATION section (only for HD, USB etc.)
self.FILE_SYS_INFO_PATTERN = ('File System Information')
self.FILE_SYS_INFOin = False
self.FILE_SYS_INFOinVolumeSn = False
self.FILE_SYS_INFOinFileSystem = False
self.FILE_SYS_INFOinCapacity = False
self.FILE_SYS_INFOinUnallocated = False
self.FILE_SYS_INFOinAllocated = False
self.FILE_SYS_INFOinOffest = False
self.FILE_SYS_INFOvolumeSnText = ''
self.FILE_SYS_INFOfileSystemText = ''
self.FILE_SYS_INFOcapacityText = ''
self.FILE_SYS_INFOunallocatedText = ''
self.FILE_SYS_INFOallocatedText = ''
self.FILE_SYS_INFOoffsetText = ''
self.FILE_SYS_INFOtotal = 0
self.FILE_SYS_INFOid = []
self.FILE_SYS_INFOvolumeSn = []
self.FILE_SYS_INFOfileSystem = []
self.FILE_SYS_INFOcapacity = []
self.FILE_SYS_INFOunallocated = []
self.FILE_SYS_INFOallocated = []
self.FILE_SYS_INFOoffset = []
#--- Signficant Location (Location Device)
self.LOCATION_PATTERN = ('Significant Locations')
self.LOCATIONin = False
self.LOCATIONinType = False
self.LOCATIONinCreated = False
self.LOCATIONinLongitude = False
self.LOCATIONinLatitude = False
self.LOCATIONinSource = False
self.LOCATIONinLocation = False
self.LOCATIONinRecoveryMethod = False
self.LOCATIONtotal = 0
self.LOCATIONtypeText = ''
self.LOCATIONcreatedText = ''
self.LOCATIONlongitudeText = ''
self.LOCATIONlatitudeText = ''
self.LOCATIONsourceText = ''
self.LOCATIONlocationText = ''
self.LOCATIONrecoveryMethodText = ''
self.LOCATIONartifact = ''
self.LOCATIONid = []
self.LOCATIONtype = []
self.LOCATIONcreated = []
self.LOCATIONlongitude = []
self.LOCATIONlatitude = []
self.LOCATIONsource = []
self.LOCATIONlocation = []
self.LOCATIONrecoveryMethod = []
#--- Searched Item
self.SEARCHED_ITEM_PATTERN = ('Parsed Search Queries', 'Google Searches',
'iOS Safari Recent Search Terms', 'Chrome Keyword Search Terms')
self.SEARCHED_ITEMin = False
self.SEARCHED_ITEMinAppSource = False
self.SEARCHED_ITEMinTimeStamp = False
self.SEARCHED_ITEMinValue = False
self.SEARCHED_ITEMinSource = False
self.SEARCHED_ITEMinLocation = False
self.SEARCHED_ITEMinRecoveryMethod = False
self.SEARCHED_ITEMtotal = 0
self.SEARCHED_ITEMappSourceText = ''
self.SEARCHED_ITEMtimeStampText = ''
self.SEARCHED_ITEMvalueText = ''
self.SEARCHED_ITEMsourceText = ''
self.SEARCHED_ITEMlocationText = ''
self.SEARCHED_ITEMrecoveryMethodText = ''
self.SEARCHED_ITEMartifact = ''
self.SEARCHED_ITEMid = []
self.SEARCHED_ITEMappSource = []
self.SEARCHED_ITEMtimeStamp = []
self.SEARCHED_ITEMvalue = []
self.SEARCHED_ITEMsource = []
self.SEARCHED_ITEMlocation = []
self.SEARCHED_ITEMrecoveryMethod = []
#--- SMS Artifacts
self.SMS_PATTERN = ('Android SMS', 'Android SMS/MMS', 'iOS iMessage/SMS/MMS')
self.SMSin = False
self.SMSinPartner = False
self.SMSinRecipient = False
self.SMSinSender = False
self.SMSinReceivedDateTime = False
self.SMSinSentDateTime = False
self.SMSinMessage = False
self.SMSinDirection = False
self.SMSinSource = False
self.SMSinLocation = False
self.SMSinRecoveryMethod = False
self.SMSpartnerText = ''
self.SMSrecipientText = ''
self.SMSsenderText = ''
self.SMSreceivedDateTimeText = ''
self.SMSsentDateTimeText = ''
self.SMSmessageText = ''
self.SMSdirectionText = ''
self.SMSsourceText = ''
self.SMSlocationText = ''
self.SMSrecoveryMethodText = ''
self.SMStotal = 0
self.SMSid = []
self.SMSrecipient = []
self.SMSsender = []
self.SMSreceivedDateTime = []
self.SMSsentDateTime = []
self.SMSmessage = []
self.SMSdirection = []
self.SMSsource = []
self.SMSlocation = []
self.SMSrecoveryMethod = []
#--- WEB_HISTORY
self.WEB_PATTERN = ('Chrome Web History', 'Safari History', 'Firefox Web History',
'Samsung Browser Web History', 'Edge Chromium Web History')
self.WEBin = False
self.WEBinUrl = False
self.WEBinLastVisited = False
self.WEBinTitle = False
self.WEBinVisitCount = False
self.WEBinSource = False
self.WEBinLocation = False
self.WEBinRecoveryMethod = False
self.WEBurlText = ''
self.WEBlastVisitedText = ''
self.WEBtitleText = ''
self.WEBvisitCountText = ''
self.WEBsourceText = ''
self.WEBlocationText = ''
self.WEBrecoveryMethodText = ''
self.WEBtotal = 0
self.WEBid = []
self.WEBurl = []
self.WEBappName = ''
self.WEBappSource = []
self.WEBtitle = []
self.WEBlastVisited = []
self.WEBvisitCount = []
self.WEBsource = []
self.WEBlocation = []
self.WEBrecoveryMethod = []
#--- Wireless Network Artifact
self.WIRELESS_NET_PATTERN = ('WiFi Locations')
self.WIRELESS_NETin = False
self.WIRELESS_NETinMacAaddress= False
self.WIRELESS_NETinChannel= False
self.WIRELESS_NETinTimeStamp = False
self.WIRELESS_NETinLatitude = False
self.WIRELESS_NETinLongitude = False
self.WIRELESS_NETinAccuracy = False
self.WIRELESS_NETinSource = False
self.WIRELESS_NETinLocation = False
self.WIRELESS_NETinRecoveryMethod = False
self.WIRELESS_NETmacAddressText = ''
self.WIRELESS_NETchannelText = ''
self.WIRELESS_NETtimeStampText = ''
self.WIRELESS_NETlongitudeText = ''
self.WIRELESS_NETlatitudeText = ''
self.WIRELESS_NETaccuracyText = ''
self.WIRELESS_NETsourceText = ''
self.WIRELESS_NETlocationText = ''
self.WIRELESS_NETrecoveryMethodText = ''
self.WIRELESS_NETtotal = 0
self.WIRELESS_NETid = []
self.WIRELESS_NETmacAddress = []
self.WIRELESS_NETchannel = []
self.WIRELESS_NETtimeStamp = []
self.WIRELESS_NETlongitude = []
self.WIRELESS_NETlatitude = []
self.WIRELESS_NETaccuracy = []
self.WIRELESS_NETsource = []
self.WIRELESS_NETlocation = []
self.WIRELESS_NETrecoveryMethod = []
#--- Windows Timeline Activity, class uco-observable:EventFacet in UCO/CASE
self.WIN_TIMELINE_PATTERN = ('Windows Timeline Activity')
self.WIN_TIMELINEin = False
self.WIN_TIMELINEinAppName = False
self.WIN_TIMELINEinActivityType = False
self.WIN_TIMELINEinTimeStamp = False
self.WIN_TIMELINEinSource = False
self.WIN_TIMELINEinLocation = False
self.WIN_TIMELINEinRecoveryMethod = False
self.WIN_TIMELINEtotal = 0
self.WIN_TIMELINEappNameText = ''
self.WIN_TIMELINEactivityTypeText = ''
self.WIN_TIMELINEtimeStampText = ''
self.WIN_TIMELINEsourceText = ''
self.WIN_TIMELINElocationText = ''
self.WIN_TIMELINErecoveryMethodText = ''
self.WIN_TIMELINEid = []
self.WIN_TIMELINEappName = []
self.WIN_TIMELINEactivityType = []
self.WIN_TIMELINEtimeStamp = []
self.WIN_TIMELINEsource = []
self.WIN_TIMELINElocation = []
self.WIN_TIMELINErecoveryMethod = []
self.CONTEXTimagePath = []
self.CONTEXTimageSize = []
self.CONTEXTimageMetadataHashSHA = []
self.CONTEXTimageMetadataHashMD5 = []
def createOutFile(self, filename):
'''
It transfers all the Traces (Observable in UCO/CASE terminology) from the memory to the file, whose name has been
provided as an argument in the command line.
:param filename: The JSON-LD filename that is being generated, complied with the UCO/CASE ontologies (string).
:return: None.
'''
self.fOut = codecs.open(filename, 'w', encoding='utf8')
def __charactersCALL(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.CALL_PATTERN
:return: None.
'''
if self.CALLinPartner:
self.CALLpartnerText += ch
elif self.CALLinPartnerName:
self.CALLpartnerNameText += ch
elif self.CALLinDirection:
self.CALLdirectionText += ch
elif self.CALLinTimeStamp:
self.CALLtimeStampText += ch
elif self.CALLinDuration:
self.CALLdurationText += ch
elif self.CALLinSource:
self.CALLsourceText += ch
elif self.CALLinLocation:
self.CALLlocationText += ch
elif self.CALLinRecoveryMethod:
self.CALLrecoveyMethodText += ch
def __charactersCELL_TOWER(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.CELL_TOWER_PATTERN
:return: None.
'''
if self.CELL_TOWERinCID:
self.CELL_TOWERcidText += ch
elif self.CELL_TOWERinLAC:
self.CELL_TOWERlacText += ch
elif self.CELL_TOWERinMCC:
self.CELL_TOWERmccText += ch
elif self.CELL_TOWERinMNC:
self.CELL_TOWERmncText += ch
elif self.CELL_TOWERinTimeStamp:
self.CELL_TOWERtimeStampText += ch
elif self.CELL_TOWERinLatitude:
self.CELL_TOWERlatitudeText += ch
elif self.CELL_TOWERinLongitude:
self.CELL_TOWERlongitudeText += ch
elif self.CELL_TOWERinSource:
self.CELL_TOWERsourceText += ch
elif self.CELL_TOWERinLocation:
self.CELL_TOWERlocationText += ch
elif self.CELL_TOWERinRecoveryMethod:
self.CELL_TOWERrecoveryMethodText += ch
def __charactersCONTACT(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.CONTACT_PATTERN
:return: None.
'''
if self.CONTACTinName:
self.CONTACTnameText += ch
elif self.CONTACTinFirstName:
self.CONTACTfirstNameText += ch
elif self.CONTACTinLastName:
self.CONTACTlastNameText += ch
elif self.CONTACTinPhoneNumber:
self.CONTACTphoneNumberText += ch
elif self.CONTACTinSource:
self.CONTACTsourceText += ch
elif self.CONTACTinLocation:
self.CONTACTlocationText += ch
elif self.CONTACTinRecoveryMethod:
self.CONTACTrecoveryMethodText += ch
def __charactersCOOKIE(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.COOKIE_PATTERN
:return: None.
'''
if self.COOKIEinName:
self.COOKIEnameText += ch
elif self.COOKIEinPath:
self.COOKIEpathText += ch
elif self.COOKIEinDomain:
self.COOKIEdomainText += ch
elif self.COOKIEinCreatedDate:
self.COOKIEcreatedDateText += ch
elif self.COOKIEinAccessedDate:
self.COOKIEaccessedDate += ch
elif self.COOKIEinExpirationDate:
self.COOKIEexpirationDateText += ch
elif self.COOKIEinSource:
self.COOKIEsourceText += ch
elif self.COOKIEinLocation:
self.COOKIElocationText += ch
elif self.COOKIEinRecoveryMethod:
self.COOKIErecoveryMethodText += ch
def __charactersCHAT(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.CHAT_PATTERN
:return: None.
'''
if self.CHATinSender:
self.CHATsenderText += ch
elif self.CHATinReceiver:
self.CHATreceiverText += ch
elif self.CHATinPartner:
self.CHATpartnerText += ch
elif self.CHATinDateTimeSent:
self.CHATdateTimeSentText += ch
elif self.CHATinDateTimeReceived:
self.CHATdateTimeReceivedText += ch
elif self.CHATinDateTime:
self.CHATdateTimeText += ch
elif self.CHATinMessage:
self.CHATmessageText += ch
elif self.CHATinMessageStatus:
self.CHATmessageStatusText += ch
elif self.CHATinMessageType:
self.CHATmessageTypeText += ch
elif self.CHATinSource:
self.CHATsourceText += ch
elif self.CHATinLocation:
self.CHATlocationText += ch
elif self.CHATinRecoveryMethod:
self.CHATrecoveryMethodText += ch
def __charactersDEVICE(self, ch):
'''
It captures the the CDATA (text) enclosed in any XML Element matching with the XPath expression
//Artifact[@name="artifact_name"]//Hit/Fragment[@name="..."] with artifact_name in self.DEVICE_PATTERN
:return: None.
'''
if self.DEVICEinId:
if self.DEVICEidText == '':
self.DEVICEidText += ch
elif self.DEVICEinImsi:
if self.DEVICEimsiText == '':
self.DEVICEimsiText += ch
elif self.DEVICEinBluetoothAddress:
if self.DEVICEbluetoothAddressText == '':
self.DEVICEbluetoothAddressText += ch
elif self.DEVICEinBluetoothName:
if self.DEVICEbluetoothNameText == '':
self.DEVICEbluetoothNameText += ch
elif self.DEVICEinImei:
if self.DEVICEimeiText == '':
self.DEVICEimeiText += ch
elif self.DEVICEinSerialNumber:
if self.DEVICEserialNumberText == '':
self.DEVICEserialNumberText += ch
elif self.DEVICEinName:
if self.DEVICEnameText == '':
self.DEVICEnameText += ch
elif self.DEVICEinModel:
if self.DEVICEmodelText == '':
self.DEVICEmodelText += ch
elif self.DEVICEinIccid:
if self.DEVICEiccidText == '':
self.DEVICEiccidText += ch
elif self.DEVICEinOsVersion:
if self.DEVICEosVersionText == '':