-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInterface.py
2085 lines (1812 loc) · 96.8 KB
/
Interface.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
import datetime as dt
import logging
import os
import shutil
import subprocess
import threading as thread
import time
import tkinter.filedialog as fd
import tkinter.messagebox as mb
import tkinter.simpledialog as sd
import tkinter.ttk as tkk
import webbrowser
from tkinter import *
from Registry import Registry
import Parse
import Reports
import Verification
class UserInterface:
def __init__(self, master):
self.master = master
self.report_log = ""
self.timeline_log = []
self.investigator = "RegSmart"
self.intro()
# Declarations
self.directory = ""
self.stop_processing = False
self.finished_parse = [False, False, False, False, False]
self.current_user = None
self.current_config = None
self.local_machine = None
self.users = None
self.session = ""
self.session_name = StringVar()
self.full_session = ""
self.location = ""
self.business = ""
self.hash_gui = ""
self.has_report = ""
self.business_setting = ""
self.location_setting = ""
self.settings = ""
self.db = {
"services": IntVar(),
"user_registered": IntVar(),
"user_start": IntVar(),
"user_installed": IntVar(),
"system_registered": IntVar(),
"system_start": IntVar(),
"system_installed": IntVar(),
"services_hash": "a4a40a3e5b91043137b5072da9a70832",
"user_registered_hash": "d41d8cd98f00b204e9800998ecf8427e",
"user_start_hash": "d41d8cd98f00b204e9800998ecf8427e",
"user_installed_hash": "d41d8cd98f00b204e9800998ecf8427e",
"system_registered_hash": "d41d8cd98f00b204e9800998ecf8427e",
"system_start_hash": "d41d8cd98f00b204e9800998ecf8427e",
"system_installed_hash": "d41d8cd98f00b204e9800998ecf8427e"
}
self.report = ""
self.shim = ""
self.shim_options = {
"system": IntVar(),
"ntuser": IntVar(),
"software": IntVar(),
"default": IntVar(),
"sam": IntVar(),
"security": IntVar()
}
self.system_report = IntVar()
self.os_report = IntVar()
self.app_report = IntVar()
self.network_report = IntVar()
self.device_report = IntVar()
self.user_app_report = IntVar()
# Hives
self.default = ""
self.ntuser = ""
self.sam = ""
self.security = ""
self.software = ""
self.system = ""
self.control_set = ""
self.sa_windir = ""
self.sa_processor = ""
self.sa_computer_name = ""
self.sa_process_num = 0
self.sa_path = ""
self.sa_curr_version = ""
self.sa_shutdown = ""
self.sa_bios_vendor = "Processing ..."
self.sa_bios_version = "Processing ..."
self.sa_system_manufacturer = "Processing ..."
self.sa_system_product_name = "Processing ..."
self.os = {}
# Function initializations
self.toolbar()
self.main_menu()
self.load_settings()
self.status = Label(self.master, text="STATUS: Ready", bd=1, relief=SUNKEN, anchor=W)
self.progress = tkk.Progressbar(self.master, orient="horizontal", length=200, mode="indeterminate")
self.progress.step(5)
self.progress["value"] = 0
self.status.pack(side=BOTTOM, fill=X, anchor=S, expand=True)
self.progress.pack(side=RIGHT, fill=X, anchor=S, padx=2, in_=self.status)
self.frame = Frame(self.master, width=800, height=500)
self.root_tree = tkk.Treeview(self.master, height=400, columns=('Created', 'Modified'),
selectmode='extended')
self.session_frame = Frame(self.frame, width=300, height=500)
self.session_frame.grid_rowconfigure(0, weight=1)
self.session_frame.grid_columnconfigure(0, weight=1)
self.session_frame.pack(side=LEFT, fill=BOTH, expand=True)
xscrollbar = Scrollbar(self.session_frame, orient=HORIZONTAL)
xscrollbar.grid(row=1, column=0, sticky=E + W)
yscrollbar = Scrollbar(self.session_frame)
yscrollbar.grid(row=0, column=1, sticky=N + S)
self.canvas = Canvas(self.session_frame, bg='white', width=300, height=500)
self.canvas_frame = Frame(self.canvas)
self.canvas.config(xscrollcommand=xscrollbar.set, yscrollcommand=xscrollbar.set)
yscrollbar.config(command=self.canvas.yview)
xscrollbar.config(command=self.canvas.xview)
self.canvas.grid(row=0, column=0, sticky="nsew")
self.canvas.create_window((0, 0), window=self.canvas_frame, anchor=N+W, width=550)
self.canvas_frame.bind("<Configure>", lambda event, canvas=self.canvas: self.onFrameConfigure(self.canvas))
r = 0
Label(self.canvas_frame, text="Sessions", font="Arial 14 bold", fg="white", bg="orange").pack(fill=BOTH, expand=True)
try:
if not os.path.exists(os.getcwd()+"\\data\\sessions"):
os.makedirs(os.getcwd() + "\\data\\sessions")
for filename in os.listdir(os.getcwd()+"\\data\\sessions"):
r += 1
image = PhotoImage(file="data/img/regticksession.png", height=50, width=50)
image.zoom(50, 50)
tmp = filename
session_info = self.get_config(filename)
b = Button(self.canvas_frame, image=image, compound=LEFT, text=session_info, anchor=W, justify=LEFT,
command=lambda tmp=tmp: self.load_session(tmp))
b.image = image
b.pack(fill=BOTH, expand=True)
except Exception:
logging.error('[RegSmart] An error occurred in (Session loading)', exc_info=True, extra={'investigator': 'RegSmart'})
self.display_message('error', 'An error occurred while Loading sessions.\nPlease try again.')
tool_frame = Frame(self.frame, width=500, height=500)
tool_frame.pack(side=RIGHT)
Label(tool_frame, textvariable=self.session_name, font="Algerian 14 bold")\
.grid(row=0, column=0, columnspan=6, sticky="nsew")
image = PhotoImage(file="data/img/system.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="System Analysis", image=image, compound=TOP, command=self.system_analysis)
b.image = image
b.grid(row=2, column=2, sticky="nsew")
image = PhotoImage(file="data/img/os.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="OS Analysis", image=image, compound=TOP, command=self.os_analysis)
b.image = image
b.grid(row=2, column=4, sticky="nsew")
image = PhotoImage(file="data/img/application.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Application Analysis", image=image, compound=TOP,
command=self.application_analysis)
b.image = image
b.grid(row=4, column=2, sticky="nsew")
image = PhotoImage(file="data/img/network.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Network Analysis", image=image, compound=TOP, command=self.network_analysis)
b.image = image
b.grid(row=4, column=4, sticky="nsew")
image = PhotoImage(file="data/img/device.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Device Analysis", image=image, compound=TOP, command=self.device_analysis)
b.image = image
b.grid(row=6, column=2, sticky="nsew")
image = PhotoImage(file="data/img/cache.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="ShimCache Analysis", image=image, compound=TOP, command=self.shim_cache_gui)
b.image = image
b.grid(row=6, column=4, sticky="nsew")
image = PhotoImage(file="data/img/regview.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Registry Viewer", image=image, compound=TOP, command=self.regview)
b.image = image
b.grid(row=8, column=2, sticky="nsew")
image = PhotoImage(file="data/img/report.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Report", image=image, compound=TOP, command=self.make_report)
b.image = image
b.grid(row=8, column=4, sticky="nsew")
image = PhotoImage(file="data/img/hash.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Hash Generator", image=image, compound=TOP, command=self.hash_checker)
b.image = image
b.grid(row=10, column=2, sticky="nsew")
image = PhotoImage(file="data/img/settings.png", height=50, width=50)
image.zoom(50, 50)
b = Button(tool_frame, text="Settings", image=image, compound=TOP, command=self.settings_gui)
b.image = image
b.grid(row=10, column=4, sticky="nsew")
self.frame.pack(expand=True, fill=BOTH)
self.master.update()
def help(self):
url = 'file://' + os.getcwd() + "\\data\\help\\index.html#userman"
webbrowser.open_new(url)
def load_settings(self):
try:
i = 0
with open(os.getcwd() + "\\data\\config\\regsmart.conf", 'r') as file:
for line in file:
if i < 7:
(key, val) = line.split()
key = key.strip(":")
self.db[str(key)].set(int(val))
elif i > 6 and i < 14:
(key, val) = line.split()
key = key.strip(":")
self.db[str(key)] = val
elif i == 14:
self.business_setting = line.split(":")[1]
elif i == 15:
self.location_setting = line.split(":")[1].split(",")
i += 1
except Exception as ee:
print(ee)
logging.error('[RegSmart] An error occurred in (load_settings)', exc_info=True,
extra={'investigator': 'RegSmart'})
return "Error occurred"
def update_settings(self, display=None):
self.rep_log("Saved settings")
try:
with open(os.getcwd() + "\\data\\config\\regsmart.conf", 'w') as file:
final = ""
b = self.business_setting.strip("\n")
loc = ""
for i in self.location_setting:
if i != "":
loc += i.strip("\n") + ","
loc = loc[:-1]
j = 0
for i, k in self.db.items():
if j < 7:
final += i + ": " + str(k.get()) + "\n"
else:
final += i + ": " + k + "\n"
j += 1
final += "business_name:" + b + "\n"
final += "business_address:" + loc
file.write(final)
if not display:
self.display_message("info", "Your settings have been updated successfully")
self.settings.destroy()
except Exception as ee:
logging.error('[RegSmart] An error occurred in (Update settings)', exc_info=True,
extra={'investigator': 'RegSmart'})
def hash_folder(self):
try:
filename = fd.askdirectory()
hash = Verification.get_hash(filename)
self.display_message("info", "Filename: " + filename + "\n\nHash: " + hash
+ "\n\nNote: Contents copied to clipboard!")
self.hash_gui.clipboard_clear()
self.hash_gui.clipboard_append("Filename: " + filename + "\nHash: " + hash)
self.hash_gui.focus_force()
except Exception as ee:
logging.error('[RegSmart] An error occurred in (hash folder)', exc_info=True,
extra={'investigator': 'RegSmart'})
def hash_file(self):
try:
filename = fd.askopenfilename()
hash = Verification.hash_file(filename)
self.display_message("info", "Filename: " + filename + "\n\nHash: " + hash
+ "\n\nNote: Contents copied to clipboard!")
self.hash_gui.clipboard_clear()
self.hash_gui.clipboard_append("Filename: " + filename + "\nHash: " + hash)
self.hash_gui.focus_force()
except Exception as ee:
logging.error('[RegSmart] An error occurred in (hash file)', exc_info=True,
extra={'investigator': 'RegSmart'})
def hash_checker(self):
self.rep_log("Opened Hash Generator")
self.hash_gui = Toplevel()
self.center_window(self.hash_gui, 353, 150)
self.hash_gui.title("RegSmart: Hash Generator")
self.hash_gui.iconbitmap("data/img/icon.ico")
r = 1
Label(self.hash_gui, font="Arial 16 bold", fg="black", bg="orange",
text="Hash Generator") \
.grid(row=0, column=0, columnspan=2, sticky="nsew")
r += 1
image = PhotoImage(file="data/img/folder.png", height=50, width=50)
image.zoom(50, 50)
b = Button(self.hash_gui, text="Hash Folder", image=image, compound=TOP, command=self.hash_folder)
b.image = image
b.grid(row=1, column=0, pady=10, sticky="nsew")
image = PhotoImage(file="data/img/file.png", height=50, width=50)
image.zoom(50, 50)
b = Button(self.hash_gui, text="Hash File", image=image, compound=TOP, command=self.hash_file)
b.image = image
b.grid(row=1, column=1, pady=10, sticky="nsew")
Label(self.hash_gui, font="Arial 10 bold", fg="black", bg="grey",
text="Hash information is automatically copied to clipboard!") \
.grid(row=2, column=0, columnspan=2, sticky="nsew")
def human_bytes(self, B):
B = float(B)
KB = float(1024)
MB = float(KB ** 2) # 1,048,576
GB = float(KB ** 3) # 1,073,741,824
TB = float(KB ** 4) # 1,099,511,627,776
if B < KB:
return '{0} {1}'.format(B, 'Bytes' if 0 == B > 1 else 'Byte')
elif KB <= B < MB:
return '{0:.2f} KB'.format(B / KB)
elif MB <= B < GB:
return '{0:.2f} MB'.format(B / MB)
elif GB <= B < TB:
return '{0:.2f} GB'.format(B / GB)
elif TB <= B:
return '{0:.2f} TB'.format(B / TB)
def get_config(self, filename):
filename = "data\\sessions\\" + filename + "\\regsmart.session"
try:
with open(filename, 'r') as file:
return file.read()
except Exception:
return "Error occurred"
def get_size(self, start_path='.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
def donothing(self):
filewin = Toplevel(self.master)
button = Button(filewin, text="Do nothing button")
button.pack()
def onFrameConfigure(self, t=None):
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
def main_menu(self):
menubar = Menu(self.master)
self.master.config(menu=menubar)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New Session", command=self.open_directory)
# filemenu.add_command(label="Open ", command=self.open_directory)
# filemenu.add_command(label="Save", command=self.donothing)
# filemenu.add_command(label="Save as...", command=self.donothing)
filemenu.add_command(label="Close Session", command=self.close_session)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=self.confirm_quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_separator()
editmenu.add_command(label="System Analysis", command=self.system_analysis)
editmenu.add_command(label="OS Analysis", command=self.os_analysis)
editmenu.add_command(label="Application Analysis", command=self.application_analysis)
editmenu.add_command(label="Network Analysis", command=self.network_analysis)
editmenu.add_command(label="Device Analysis", command=self.device_analysis)
editmenu.add_command(label="ShimCache Analysis", command=self.shim_cache_gui)
editmenu.add_command(label="Registry Viewer", command=self.regview)
editmenu.add_command(label="Hash Generator", command=self.hash_checker)
editmenu.add_command(label="Report", command=self.make_report)
menubar.add_cascade(label="Tools", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help", command=self.help)
helpmenu.add_command(label="About...", command=self.intro)
menubar.add_cascade(label="Help", menu=helpmenu)
def display_message(self, types, message):
if types == "info":
# thread.Thread(target=mb.showinfo, args=("RegSmart", message,)).start()
mb.showinfo("RegSmart", message)
if types == "error":
# thread.Thread(target=mb.showerror, args=("RegSmart", message,)).start()
mb.showerror("RegSmart", message)
if types == "warning":
# thread.Thread(target=mb.showwarning, args=("RegSmart", message,)).start()
mb.showwarning("RegSmart", message)
if types == "success":
# mb._show(title="RegSmart", message=message, _icon="info", type="ok")
tmp = Toplevel()
tmp.title("RegSmart")
tmp.iconbitmap("data/img/icon.ico")
Frame(tmp, width=200, height=8).pack()
photo = PhotoImage(file="data/img/regticksmall.png", height=100, width=100)
label = Label(tmp, image=photo)
label.image = photo
label.pack(side=LEFT, padx=20, pady=10)
Label(tmp, text="Successfully verified dumps!", font="Bold", pady=20).pack()
Button(tmp, text="OK", command=tmp.destroy).pack(side=RIGHT, padx=100, pady=20, ipadx=20, ipady=2)
self.center_window(tmp, 400, 150)
tmp.focus_force()
def get_answer(self, message):
return mb.askquestion("RegSmart",message)
def stop(self):
self.stop_processing = True
self.set_status("Stopped")
self.progress.stop()
logging.info("Stopped processing", extra={'investigator': self.investigator})
def toolbar(self):
toolbar = Frame(self.master, bg="gray")
# Button(toolbar, text="Quit", command=self.stop, anchor=S).pack(side=LEFT)
toolbar.pack(side=TOP, fill=X)
def set_status(self, msg):
self.status['text'] = "STATUS: " + msg
def intro(self):
self.rep_log("Opened about window")
logging.info("Initiated about window", extra={'investigator': self.investigator})
about = Toplevel(bg='white')
about.title("RegSmart")
about.iconbitmap("data/img/icon.ico")
frame = Frame(about, width=400, height=100, bg='white')
reg = PhotoImage(file="data/img/regsmart.png")
label = Label(about, image=reg)
label.image = reg
label.pack()
welcome = open("data/info/welcome", 'r').read()
Label(about, text=welcome, bd=1, wraplength=500, bg='white').pack(fill=X)
disclaimer = open("data/info/disclaimer", 'r').read()
year = dt.datetime.now().year
Label(about, text="Copyright@"+str(year), bd=1, relief=SUNKEN, anchor=E, wraplength=200)\
.pack(side=BOTTOM, fill=X)
Label(about, text=disclaimer, bd=1, bg="lightgrey", relief=SUNKEN, anchor=S).pack(side=BOTTOM, fill=X)
frame.pack()
self.center_window(about, 750, 400)
about.focus_force()
self.rep_log("Getting Investigator information")
if self.investigator == "RegSmart":
self.investigator = sd.askstring("RegSmart", "Investigators Name:")
if not self.investigator or self.investigator == "" or self.investigator == " ":
self.investigator = "RegSmart"
self.rep_log("User failed to enter their name on the first try.")
self.display_message("warning", "Please enter your name")
self.investigator = sd.askstring("RegSmart", "Investigators Name:")
if not self.investigator or self.investigator == "" or self.investigator == " ":
logging.info('Failed to get investigator name exiting ...', extra={'investigator': 'RegSmart'})
mb.showerror("RegSmart", "Failed to get Investigator Name.\nExiting ...")
exit(0)
id = sd.askstring("RegSmart", "Investigators ID: ")
if not id or id == "" or id == " ":
self.rep_log("User failed to enter their ID on the first try.")
self.display_message("warning", "Please enter your ID")
id = sd.askstring("RegSmart", "Investigators ID:")
if not id or id == "" or id == " ":
logging.info('Failed to get investigator id exiting ...', extra={'investigator': 'RegSmart'})
mb.showerror("RegSmart", "Failed to get Investigator ID.\nExiting ...")
exit(0)
self.rep_log("Investigator entered name: " + self.investigator)
self.rep_log("Investigator entered id: " + id)
self.display_message("info", "Hello " + self.investigator + ".\nPlease wait while sessions are loading.")
self.investigator += " (" + id + ")"
else:
about.focus_force()
# self.master.update()
self.master.deiconify()
about.focus_force()
def confirm_quit(self):
tmp = self.get_answer("Do you want to quit?")
if tmp == "yes":
logging.info("Exiting RegSmart ...", extra={'investigator': self.investigator})
self.master.destroy()
exit(0)
def update_loading(self):
if self.directory != "":
self.progress.start()
self.set_status("Verifying dumps ...")
self.display_message("info", "Verifying dumps for session. \nPress OK to continue.")
tmp = Verification.verify_dump(self.directory)
# tmp = 1
if tmp == 2:
self.display_message("warning", "No dumps were found in this directory please choose another.")
self.set_status("No dumps found")
elif tmp:
self.display_message("info", "Successfully verified integrity of dumps")
self.set_status("Processing ...")
# name = self.directory.split("\\")
# fold = name[len(name) - 1]
# self.session = fold
# self.session_name.set(fold.split("_")[0])
thread.Thread(target=self.read_dumps).start()
else:
self.set_status("Dumps are not authentic")
self.display_message("error", "The integrity of the dumps is not valid.")
self.display_message("error", "RegSmart cannot process due to difference in original file"
" and forensic copy.")
self.display_message("info", "Please get new dumps and make sure that the dumps were"
" successfully acquired.")
self.progress['value'] = 0
self.progress.stop()
thread.Thread(target=self.reset_progress).start()
def read_dumps(self):
if self.directory != "":
self.set_status("Processing dumps ...")
self.progress.start()
self.master.update()
try:
for filename in os.listdir(self.directory):
if filename == "DEFAULT":
self.default = Registry.Registry(self.directory + "/" + filename)
# thread.Thread(target=self.get_keys, args=(self.default.root(), self.u,)).start()
elif filename == "NTUSER.DAT":
self.ntuser = Registry.Registry(self.directory + "/" + filename)
# thread.Thread(target=self.get_keys, args=(self.ntuser.root(), self.cu,)).start()
elif filename == "SAM":
self.sam = Registry.Registry(self.directory + "/" + filename)
# thread.Thread(target=self.get_keys, args=(self.sam.root(), self.lm,)).start()
elif filename == "SECURITY":
self.security = Registry.Registry(self.directory + "/" + filename)
# thread.Thread(target=self.get_keys, args=(self.security.root(), self.lm,)).start()
elif filename == "SOFTWARE":
self.software = Registry.Registry(self.directory + "/" + filename)
# thread.Thread(target=self.get_keys, args=(self.software.root(), self.lm,)).start()
elif filename == "SYSTEM":
self.system = Registry.Registry(self.directory + "/" + filename)
key = self.system.open("Select")
for v in key.values():
if v.name() == "Current":
self.control_set = str(v.value())
key = self.system.open("ControlSet00" + self.control_set + "\\Control\\Session Manager\\Environment")
for v in key.values():
if v.name() == "PROCESSOR_ARCHITECTURE":
self.sa_processor = v.value()
except Exception as ee:
logging.error('An error occurred in (parsing registry)', exc_info=True,
extra={'investigator': 'RegSmart'})
self.display_message("error", "Failed to Parse registry dumps.\nSession is now closing.")
self.close_session()
self.set_status("Ready")
def utf8(self, data):
# Returns a Unicode object on success, or None on failure
try:
return data.decode('utf-8')
except UnicodeDecodeError:
return None
def get_keys(self, key, tree, depth=0):
create = ""
mod = ""
if "DateCreated" in key.values():
create = key.value("DateCreated")
if "DateLastModified" in key.values():
mod = key.value("DateLastModified")
if "DateLastConnected" in key.values():
mod = key.value("DateLastConnected")
self.root_tree.insert(tree, 'end', text=key.path(), values=(create, mod))
for subkey in key.subkeys():
self.get_keys(subkey, tree, depth + 1)
def reset_progress(self):
time.sleep(2)
self.progress['value'] = 0
self.progress.stop()
def close_session(self):
self.rep_log("Session closed [" + self.full_session + "]")
logging.info("Closed session ["+self.full_session+"]", extra={'investigator': self.investigator})
self.stop_processing = False
self.finished_parse = [False, False, False, False, False]
self.current_user = None
self.current_config = None
self.local_machine = None
self.users = None
self.session = ""
self.full_session = ""
self.session_name.set("")
# Hives
self.default = ""
self.ntuser = ""
self.sam = ""
self.security = ""
self.software = ""
self.system = ""
self.session_name.set("")
self.control_set = ""
self.sa_windir = ""
self.sa_processor = ""
self.sa_computer_name = ""
self.sa_process_num = 0
self.sa_path = ""
self.sa_curr_version = ""
self.sa_shutdown = ""
self.sa_bios_vendor = "Processing ..."
self.sa_bios_version = "Processing ..."
self.sa_system_manufacturer = "Processing ..."
self.sa_system_product_name = "Processing ..."
self.os = {}
self.directory = ""
self.master.title("RegSmart")
def load_session(self, dir):
self.close_session()
sess = os.getcwd()+"\\data\\sessions\\"+dir
if self.get_answer("Are you sure you want to load this session?\n"+dir) == "yes":
self.rep_log("Loading session: " + dir)
self.directory = sess
tmp = self.directory.split("\\")
self.full_session = tmp[len(tmp) - 1]
if self.get_config(self.full_session) == "Error occurred":
self.display_message("error", "Invalid session selected. Please re-import the session.")
return
self.session_name.set(self.full_session.split("_")[0])
self.master.title("RegSmart: [" + tmp[len(tmp) - 1] + "]")
self.update_loading()
logging.info("Loaded session [" + self.full_session + "]", extra={'investigator': self.investigator})
def reload_sessions(self):
self.canvas.delete("all")
self.canvas.pack_forget()
self.session_frame.pack_forget()
self.session_frame = Frame(self.frame, width=300, height=500)
self.session_frame.grid_rowconfigure(0, weight=1)
self.session_frame.grid_columnconfigure(0, weight=1)
self.session_frame.pack(side=LEFT, fill=BOTH, expand=True)
xscrollbar = Scrollbar(self.session_frame, orient=HORIZONTAL)
xscrollbar.grid(row=1, column=0, sticky=E + W)
yscrollbar = Scrollbar(self.session_frame)
yscrollbar.grid(row=0, column=1, sticky=N + S)
self.canvas = Canvas(self.session_frame, bg='white', width=300, height=500)
self.canvas_frame = Frame(self.canvas)
self.canvas.config(xscrollcommand=xscrollbar.set, yscrollcommand=xscrollbar.set)
yscrollbar.config(command=self.canvas.yview)
xscrollbar.config(command=self.canvas.xview)
self.canvas.grid(row=0, column=0, sticky="nsew")
self.canvas.create_window((0, 0), window=self.canvas_frame, anchor=N + W, width=550)
self.canvas_frame.bind("<Configure>", lambda event, canvas=self.canvas: self.onFrameConfigure(self.canvas))
r = 0
Label(self.canvas_frame, text="Sessions", font="Arial 14 bold", fg="white", bg="orange").pack(fill=BOTH,
expand=True)
try:
for filename in os.listdir(os.getcwd() + "\\data\\sessions"):
r += 1
image = PhotoImage(file="data/img/regticksession.png", height=50, width=50)
image.zoom(50, 50)
tmp = filename
session_info = self.get_config(filename)
b = Button(self.canvas_frame, image=image, compound=LEFT, text=session_info, anchor=W, justify=LEFT,
command=lambda tmp=tmp: self.load_session(tmp))
b.image = image
b.pack(fill=BOTH, expand=True)
except Exception:
logging.error('[RegSmart] An error occurred in (Session loading)', exc_info=True,
extra={'investigator': 'RegSmart'})
self.display_message('error', 'An error occurred while Loading sessions.\nPlease try again.')
def copy_dumps(self, src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
def create_config(self, case, dest, folder_name):
folder_name = folder_name.split("_")
file = open(dest+"\\regsmart.session", 'w')
file.write(" Name: " + folder_name[0] + "\n")
file.write(" Machine: " + folder_name[1] + "\n")
file.write(" Date: " + folder_name[2] + "\n")
file.write(" Size: " + self.human_bytes(self.get_size(dest)) + "\t\t\t\t")
file.write(" Case: " + str(case) + "\n")
file.close()
def import_concurrent(self, dest, case, name):
if not os.path.exists(dest):
os.makedirs(dest)
self.copy_dumps(self.directory, dest)
self.create_config(case, dest, name)
self.reload_sessions()
self.update_loading()
else:
if self.get_answer("Session already exists.\nDo you want to replace it?") == "yes":
try:
shutil.rmtree(dest)
os.makedirs(dest)
self.copy_dumps(self.directory, dest)
self.reload_sessions()
self.update_loading()
except Exception:
self.display_message("error", "Failed to overwrite session.\nAccess is denied.\n"
"Please delete the folder from data/sessions/[session]")
else:
self.display_message("warning", "Please note that this new session is not going to be created.")
def open_directory(self):
self.rep_log("Creating new session")
self.set_status("Ready")
self.directory = fd.askdirectory()
if self.directory != "":
if Verification.is_valid_regacquire(self.directory):
case = sd.askstring("RegSmart", "Enter Case Number:")
if not case or case == "" or case == " ":
self.display_message("warning", "Please enter case number")
case = sd.askstring("RegSmart", "Enter Case Number:")
if not case or case == "" or case == " ":
self.display_message("error", "Failed to get case number, session will not be imported.")
return
tmp = self.directory.split("/")
self.master.title("RegSmart: ["+tmp[len(tmp)-1]+"]")
self.session = tmp[len(tmp)-1].split("_")[0]
self.full_session = tmp[len(tmp)-1]
self.rep_log("New session [" + tmp[len(tmp)-1] + "]")
self.rep_log("Case number [" + case + "]")
self.session_name.set(self.session)
self.set_status("Importing dumps...")
self.progress.start()
self.display_message("info", "Importing dumps...\nPlease wait\n\nYou will be notified when it's done.")
dest = os.getcwd() + "\\data\\sessions\\"+tmp[len(tmp)-1]
name = tmp[len(tmp) - 1]
thread.Thread(target=self.import_concurrent, args=(dest, case, name,)).start()
else:
self.close_session()
self.display_message("error", "This is not a valid RegAcquire folder!")
else:
self.close_session()
self.display_message("warning", "Failed to create new session!")
def center_window(self, tmp, width=300, height=200):
# get screen width and height
screen_width = tmp.winfo_screenwidth()
screen_height = tmp.winfo_screenheight()
# calculate position x and y coordinates
x = (screen_width / 2) - (width / 2)
y = (screen_height / 2) - (height / 2)
tmp.geometry('%dx%d+%d+%d' % (width, height, x, y))
def system_analysis_data(self):
services = []
system = {}
system["release_id"] = ""
try:
key = self.system.open("ControlSet00" + self.control_set + "\\Control\\Session Manager\\Environment")
for v in key.values():
if v.name() == "windir":
system["windir"] = v.value()
except Exception:
logging.error('An error occurred in (system_analysis - WinDir)', exc_info=True,
extra={'investigator': 'RegSmart'})
try:
key = self.system.open("ControlSet00" + self.control_set + "\\Control\\Session Manager\\Environment")
for v in key.values():
if v.name() == "PROCESSOR_ARCHITECTURE":
system["process_arch"] = v.value()
if v.name() == "NUMBER_OF_PROCESSORS":
system["process_num"] = str(v.value())
if v.name() == "Path":
system["path"] = v.value()
except Exception:
logging.error('An error occurred in (system_analysis - Processor)', exc_info=True,
extra={'investigator': 'RegSmart'})
try:
key = self.system.open("ControlSet00" + self.control_set + "\\Control\\ComputerName\\ComputerName")
for v in key.values():
if v.name() == "ComputerName":
system["computer_name"] = v.value()
except Exception:
logging.error('An error occurred in (system_analysis - Computer Name)', exc_info=True,
extra={'investigator': 'RegSmart'})
try:
key = self.system.open("ControlSet00" + self.control_set + "\\Control\\Windows")
for v in key.values():
if v.name() == "ShutdownTime":
system["shutdown"] = Parse.hex_windows_to_date(v.value().hex())
except Exception:
logging.error('An error occurred in (system_analysis - Shutdown time)', exc_info=True,
extra={'investigator': 'RegSmart'})
try:
key = self.software.open("Microsoft\\Windows NT\\CurrentVersion")
for v in key.values():
if v.name() == "ProductName":
system["product_name"] = v.value()
if v.name() == "ReleaseId":
system["release_id"] = v.value()
except Exception:
logging.error('An error occurred in (system_analysis - Product info)', exc_info=True,
extra={'investigator': 'RegSmart'})
try:
key = self.system.open("ControlSet00" + self.control_set + "\\Services")
for v in key.subkeys():
services.append(v.name())
except Exception:
logging.error('An error occurred in (system_analysis - Services)', exc_info=True,
extra={'investigator': 'RegSmart'})
return services, system
def system_analysis(self):
self.rep_log("Viewed system analysis")
try:
if self.directory != "" and self.system != "":
logging.info("System Analysis on [" + self.full_session + "]", extra={'investigator': self.investigator})
tk = Tk()
tk.grid_columnconfigure(0, weight=1)
tk.grid_columnconfigure(1, weight=1)
tk.grid_columnconfigure(2, weight=1)
tk.grid_columnconfigure(3, weight=1)
tk.grid_rowconfigure(0, weight=1)
tk.grid_rowconfigure(1, weight=1)
self.center_window(tk, 500, 600)
tk.title("RegSmart: System Analysis")
tk.iconbitmap("data/img/icon.ico")
services, system = self.system_analysis_data()
r = 1
Label(tk, font="Arial 14 bold", fg="blue", bg="yellow",
text="System Analysis \n["+self.full_session+"]")\
.grid(row=0, columnspan=4, sticky="nsew")
r += 1
Label(tk, text='Computer Name: ').grid(row=r, column=0)
Label(tk, font="Helvetica 10 bold italic", text=system["computer_name"]).grid(row=r, column=1)
r += 1
Label(tk, text='OS: ').grid(row=r, column=0)
Label(tk, font="Helvetica 10 bold italic", text=system["product_name"] + " " + system['release_id'])\
.grid(row=r, column=1)
r += 1
Label(tk, text='Last Shutdown: ').grid(row=r, column=0)
Label(tk, font="Helvetica 10 bold italic", text=system["shutdown"]).grid(row=r, column=1)
r += 1
Label(tk, text='Processor Architecture: ').grid(row=r, column=0)
Label(tk, font="Helvetica 10 bold italic", text=system["process_arch"]).grid(row=r, column=1)
r += 1
Label(tk, text='# of Processors: ').grid(row=r, column=0)
Label(tk, font="Helvetica 10 bold italic", text=system["process_num"]).grid(row=r, column=1)
r += 1
# Label(tk, text="BIOS Vendor: ").grid(row=r, column=0)
# v = Label(tk, font="Helvetica 10 bold italic", text=self.sa_bios_vendor)
# v.grid(row=r, column=1)
# r += 1
#
# Label(tk, text="BIOS Version: ").grid(row=r, column=0)
# vv = Label(tk, font="Helvetica 10 bold italic", text=self.sa_bios_version)
# vv.grid(row=r, column=1)
# r += 1
#
# Label(tk, text="System Manufacturer: ").grid(row=r, column=0)
# m = Label(tk, font="Helvetica 10 bold italic", text=self.sa_system_manufacturer)
# m.grid(row=r, column=1)
# r += 1
#
# Label(tk, text="System Product Name: ").grid(row=r, column=0)
# mm = Label(tk, font="Helvetica 10 bold italic", text=self.sa_system_product_name)
# mm.grid(row=r, column=1)
# r += 1
txt_frm = Frame(tk, width=350, height=200)
txt_frm.grid(row=r, column=1, sticky="nsew")
txt_frm.grid_propagate(False)
txt_frm.grid_rowconfigure(0, weight=1)
txt_frm.grid_columnconfigure(0, weight=1)
txt = Text(txt_frm, borderwidth=3, relief="sunken")
txt.grid(row=0, column=0, sticky="nsew", padx=2, pady=2)
scrollb = Scrollbar(txt_frm, command=txt.yview)
scrollb.grid(row=0, column=1, sticky='nsew')
txt['yscrollcommand'] = scrollb.set
Label(tk, text='Path: ').grid(row=r, column=0)
for p in system["path"].split(";"):
txt.insert(END, p + "\n")
txt.config(font=("consolas", 10), state=DISABLED)
r += 2
Label(tk, text='Services: ').grid(row=r, column=0)
lb_frm = Frame(tk, width=350, height=210)
lb_frm.grid(row=r, column=1, sticky="nsew")
lb_frm.grid_propagate(False)
lb_frm.grid_rowconfigure(0, weight=1)
lb_frm.grid_columnconfigure(0, weight=1)
lb = Listbox(lb_frm)
for s in services:
lb.insert(END, s)
lb.grid(row=0, column=0, sticky="nsew", padx=2, pady=2)
scrollb = Scrollbar(lb_frm, command=lb.yview)
scrollb.grid(row=0, column=1, sticky='nsew')
lb['yscrollcommand'] = scrollb.set
scrollbx = Scrollbar(lb_frm, command=lb.xview, orient=HORIZONTAL)
scrollbx.grid(row=1, column=0, sticky='nsew')
lb['xscrollcommand'] = scrollbx.set
# if self.sa_system_product_name == "Processing ...":
# self.system_analysis_regsmart()
# v['text'] = self.sa_bios_vendor
# vv['text'] = self.sa_bios_version
# m['text'] = self.sa_system_manufacturer
# mm['text'] = self.sa_system_product_name
tk.lift()
else:
self.rep_log("No session loaded")
self.display_message('error', 'Please click on a session to load!')