-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuserinfo.sh
1718 lines (1622 loc) · 57.7 KB
/
userinfo.sh
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
#!/bin/bash
###############################################
# Utility to present information about #
# users in a clear and related manner. #
# Jacky Fox 2012 #
# Dependancies regdump.pl #
###############################################
#############################################
# variable settings #
#############################################
regdump_location="/usr/local/bin/regdump.pl"
expert_log_location="user_expert.log" # location of unfiltered output for evidential purposes
log_location="user.log" # location of sorted and related user log
device_counter=1
long_name_1="not blank"
i=0
x=0
bslash='\'
crlf="\r\n"
lfcr="\n\r"
lfcr=`echo -e $lfcr`
linefeed=$'\n'
##########################################
# command line help function #
##########################################
# comment out lines for unrequired hives/files
cmd_line_help_func() {
echo "usage : "$0" -S ../hives/SYSTEM "
echo " -S (path and name of System hive) -S /hives/system"
#echo " -N (path and name of ntuser.dat hive) -N hives/NTUSER.DAT"
#echo " -A (path and name of setupapi.log file) -A ../hives/setupapi.dev.log"
echo " -W (path and name of Software hive) -W /samples/software"
echo " -D (default location of hives) -D xphives"
#echo " -C (path and name of Security hive) -C ../hives/SECURITY"
echo " -M (path and name of the SAM) -M ../hives/SAM"
echo " -E (switch off expert logs) -E off"
echo " -L (give explicit path for logs) -L /logdir"
exit
}
###################################################################
# Check current control set number #
# HKLM\SYSTEM\Select #
# Assigns: $ccs #
###################################################################
current_control_set_func () {
temp_string=`perl $regdump_location $system_hive_location "Select" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" > $expert_log_location # first entry so new file ie >
fi
if [ -z "$temp_string" ] # if this is empty
then
ccs="Not available (check SYSTEM hive location)"
else
ccs=`echo ${temp_string##*Current (REG_DWORD) = 0x}` #cut out leading info
ccs=`echo ${ccs:5:3}` #cut off trailing info
fi
}
###################################################################
# Get the computer name from #
# HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName #
# Assigns: $comp_name #
###################################################################
get_compname_func () {
temp_string=`perl $regdump_location $system_hive_location "ControlSet$ccs\Control\ComputerName\ComputerName" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location # append entries to existing file ie >>
fi
if [ -z "$temp_string" ]
then
echo Unable to extract computer name check SYSTEM hive location
else
comp_name=`echo "${temp_string##*ComputerName (REG_SZ) = }"` # cut off leading info
comp_name=`echo ${comp_name%%$linefeed*}` # truncate at linefeed
fi
}
#################################################################
# Get the windows version from #
# HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProductName #
# Assigns: $win_ver #
# $wpd #
# $win7 #
#################################################################
get_winver_func () {
temp_string=`perl $regdump_location $software_hive_location "Microsoft\Windows NT\CurrentVersion" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
echo Unable to extract windows version check software hive location
else
win_ver=`echo "${temp_string##*ProductName (REG_SZ) = }"`
win_ver=`echo ${win_ver%%$linefeed*}`
fi
echo $win_ver | grep -q "Windows 7\|Windows Vista" # check if windows is >= Vista
if [ $? = "0" ]
then
wpd="yes"
fi
echo $win_ver | grep -q "Windows 7" # check if windows is 7
if [ $? = "0" ]
then
win7="yes"
fi
}
##################################################
# Get all the usernames recorded in the registry #
# HKLM\SAM\SAM\Domains\Account\Users\Names #
# Assigns: $name[$i] #
# $name_rid[$i] #
# $rid[$i] (in hex) #
##################################################
get_usernames_func () {
temp_string=`perl $regdump_location $sam_location "SAM\Domains\Account\Users\Names" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ] # if this is empty
then
echo="Check SAM hive location"
else
i=0
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
if [ "${eachline:0:2}" = ".." ] # if the line holds a username
then
(( i++ ))
name[$i]=${eachline##*..?}
name_rid[$i]=`perl $regdump_location $sam_location "SAM\Domains\Account\Users\Names$bslash${name[$i]}" -v`
if [ "$logging" != "off" ]
then
echo "${name_rid[$i]}" >> $expert_log_location
fi
name_rid[$i]=`echo "${name_rid[$i]#*(REG_}"`
name_rid[$i]=`echo "${name_rid[$i]%%)*}"`
temp=$(echo "obase=16;${name_rid[$i]}" | bc)
rid[$i]="00000000"
rid[$i]=${rid[$i]:0:(8-${#temp})}$temp # 8 digit hex number
fi
done
IFS=$p
((num_users=i))
fi
}
#################################################################
# get the profilelists from the registry from #
# HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Profilelist #
# Assigns : $profile_rid[$z] #
# $profile_image_path[$z] #
# $profile_ntu_loc[$z] #
# $profile_rid[$z] #
# note these are not assigned to users yet hence $z #
#################################################################
profile_list_func () {
temp_string=`perl $regdump_location $software_hive_location "Microsoft\Windows NT\CurrentVersion\Profilelist" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
z=0
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
if [ "${eachline:0:2}" = ".." ] # if the line holds a profile
then
(( z++ ))
profile_list[$z]=${eachline##*..?}
profile_rid[$z]=`echo ${profile_list[$z]##*-}`
profile_sid[$z]=`perl $regdump_location $software_hive_location "Microsoft\Windows NT\CurrentVersion\Profilelist$bslash${profile_list[$z]}" -v`
if [ "$logging" != "off" ]
then
echo "${profile_sid[$z]}" >> $expert_log_location
fi
profile_image_path[$z]=`echo "${profile_sid[$z]##*ProfileImagePath (REG_EXPAND_SZ) = }"`
profile_image_path[$z]=`echo ${profile_image_path[$z]%%$linefeed*}`
if [ "$wpd" = "yes" ] # this bit sets the expected ntuser.dat file name for each profile
then
profile_ntu_loc[$z]=`echo "NTUSER.DAT."${profile_image_path[$z]##*\\\\Users\\\\}` # vista+
else
profile_ntu_loc[$z]=`echo "NTUSER.DAT."${profile_image_path[$z]##*Settings\\\\}` # xp
fi
fi
done
IFS=$p
((num_profiles=z))
}
######################################################################
# Use the RIDs to get the F values (timestamps) for each user #
# HKLM\SAM\SAM\Domains\Account\Users\{RID} #
# Assigns : $last_logon[$i] #
# $password_change[$i] #
# $account_expires[$i] #
# $failed_logon[$i] #
# $num_logons[$i] #
# $ac_enabled[$i] #
# if the user has logged in then also get the following #
# $user_profile_folder[$i] #
######################################################################
get_timestamps_func () {
i=0
while [ $i -lt $num_users ]
do
(( i++ ))
temp_string[$i]=`perl $regdump_location $sam_location "SAM\Domains\Account\Users\$bslash${rid[$i]}" -v`
if [ "$logging" != "off" ]
then
echo "${temp_string[$i]}" >> $expert_log_location
fi
f_value[$i]=`echo "${temp_string[$i]##*F (REG_BINARY) = }"`
f_value[$i]=`echo ${f_value[$i]%%$linefeed*} | tr -d " "`
x=30 # marker for start of this value in the "F" value
last_logon[$i]=${f_value[$i]:($x):2}${f_value[$i]:($x-2):2}${f_value[$i]:($x-4):2}${f_value[$i]:($x-6):2}${f_value[$i]:($x-8):2}${f_value[$i]:($x-10):2}${f_value[$i]:($x-12):2}${f_value[$i]:($x-14):2}
if [ "${last_logon[$i]}" = "0000000000000000" ]
then
last_logon[$i]="No logon recorded"
else
last_logon[$i]=`echo $((0x${last_logon[$i]}/10000000-11644473600))` #convert windowstime to unix time
last_logon[$i]=`date -d @${last_logon[$i]}` #convert unixtime
z=0
while [ $z -lt $num_profiles ] #check the profiles for matching rids to assign userprofilefolder
do
(( z++ ))
if [ ${name_rid[$i]} = ${profile_rid[$z]} ]
then
user_profile_folder[$i]=${profile_image_path[$z]}
user_ntuser_loc[$i]=${profile_ntu_loc[$z]}
fi
done
fi
x=62 # marker for start of this value in the "F" value
password_change[$i]=${f_value[$i]:($x):2}${f_value[$i]:($x-2):2}${f_value[$i]:($x-4):2}${f_value[$i]:($x-6):2}${f_value[$i]:($x-8):2}${f_value[$i]:($x-10):2}${f_value[$i]:($x-12):2}${f_value[$i]:($x-14):2}
if [ "${password_change[$i]}" = "0000000000000000" ]
then
password_change[$i]="Never"
else
password_change[$i]=`echo $((0x${password_change[$i]}/10000000-11644473600))`
password_change[$i]=`date -d @${password_change[$i]}`
fi
x=78 # marker for start of this value in the "F" value
account_expires[$i]=${f_value[$i]:($x):2}${f_value[$i]:($x-2):2}${f_value[$i]:($x-4):2}${f_value[$i]:($x-6):2}${f_value[$i]:($x-8):2}${f_value[$i]:($x-10):2}${f_value[$i]:($x-12):2}${f_value[$i]:($x-14):2}
if ( [ "${account_expires[$i]}" = "7FFFFFFFFFFFFFFF" ] || [ "${account_expires[$i]}" = "7fffffffffffffff" ] )
then
account_expires[$i]="Does not expire"
else
if [ "${account_expires[$i]}" = "0000000000000000" ]
then
account_expires[$i]="No expiry set"
else
account_expires[$i]=`echo $((0x${account_expires[$i]}/10000000-11644473600))`
account_expires[$i]=`date -d @${account_expires[$i]}`
fi
fi
x=94 # marker for start of this value in the "F" value
failed_logon[$i]=${f_value[$i]:($x):2}${f_value[$i]:($x-2):2}${f_value[$i]:($x-4):2}${f_value[$i]:($x-6):2}${f_value[$i]:($x-8):2}${f_value[$i]:($x-10):2}${f_value[$i]:($x-12):2}${f_value[$i]:($x-14):2}
if [ "${failed_logon[$i]}" = "0000000000000000" ]
then
failed_logon[$i]="Never"
else
failed_logon[$i]=`echo $((0x${failed_logon[$i]}/10000000-11644473600))`
failed_logon[$i]=`date -d @${failed_logon[$i]}`
fi
num_logons[$i]=`echo ${f_value[$i]:134:2}${f_value[$i]:132:2} | tr '[:lower:]' '[:upper:]'` # bc likes uppercase
num_logons[$i]=`echo "ibase=16;obase=A;${num_logons[$i]}" | bc`
ac_enabled[$i]=${f_value[$i]:113:1}
case ${ac_enabled[$i]} in
[0,2,6,8,a,c,e,A,C,E]) ac_enabled[$i]="Yes" ;;
4) ac_enabled[$i]="Yes (Password required)" ;;
[1,3,5,7,b,d,f,B,D,F]) ac_enabled[$i]="No" ;;
*) ac_enabled[$i]="Unknown" ;;
esac
done
}
##################################################
# Get all the groupnames recorded in the registry#
# HKLM\SAM\SAM\Domains\Builtin\Aliases\Names #
# Assigns : $groupname[$i] #
# $groupname_rid[$i] #
# $group_rid[$i] (in hex) #
# $num_groups #
##################################################
get_groupnames_func () {
temp_string=`perl $regdump_location $sam_location "SAM\Domains\Builtin\Aliases\Names" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ] # if this is empty
then
echo="Check SAM hive location"
else
i=0
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
if [ "${eachline:0:2}" = ".." ] # if the line holds a username
then
(( i++ ))
groupname[$i]=${eachline##*..?}
groupname_rid[$i]=`perl $regdump_location $sam_location "SAM\Domains\Builtin\Aliases\Names$bslash${groupname[$i]}" -v`
if [ "$logging" != "off" ]
then
echo "${groupname_rid[$i]}" >> $expert_log_location
fi
groupname_rid[$i]=`echo "${groupname_rid[$i]#*(REG_}"`
groupname_rid[$i]=`echo "${groupname_rid[$i]%%)*}"`
temp=$(echo "obase=16;${groupname_rid[$i]}" | bc)
group_rid[$i]="00000000"
group_rid[$i]=${group_rid[$i]:0:(8-${#temp})}$temp # 8 digit hex number
fi
done
IFS=$p
((num_groups=i))
fi
}
######################################################################
# Get username RIDs for members of each group #
# HKLM\SAM\SAM\Domains\Builtin\Aliases\{RID} #
# Assigns: $num_members[$i] #
# $offset_to_sids[$i] #
# $group_members_rid[$i$y] #
# $group_members_name[$i$y] #
# $memberof[$z] (user specific list of groups) #
######################################################################
get_members_func () {
i=0
while [ $i -lt $num_groups ]
do
(( i++ ))
temp_string[$i]=`perl $regdump_location $sam_location "SAM\Domains\Builtin\Aliases\$bslash${group_rid[$i]}" -v`
if [ "$logging" != "off" ]
then
echo "${temp_string[$i]}" >> $expert_log_location
fi
c_value[$i]=`echo "${temp_string[$i]##*C (REG_BINARY) = }"`
c_value[$i]=`echo ${c_value[$i]%%$linefeed*} | tr -d " "`
x=102 # marker for position to extract little endian data
num_members[$i]=${c_value[$i]:($x):2}${c_value[$i]:($x-2):2}${c_value[$i]:($x-4):2}${c_value[$i]:($x-6):2}
x=86 # marker for position to extract little endian data
offset_to_sids[$i]=${c_value[$i]:($x):2}${c_value[$i]:($x-2):2}${c_value[$i]:($x-4):2}${c_value[$i]:($x-6):2}
offset_to_sids[$i]=$((0x${offset_to_sids[$i]}+0x34)) # get the offset to the 1st sid in decimal
y=0
while [ $y -lt ${num_members[$i]} ] # populate the array with users
do
(( y++ ))
x=$((((${offset_to_sids[$i]}*2))+(($y*56))-8))
if [ ${groupname[$i]} = "Users" ]
then
if [ $y -lt "3" ] # to accomodate the two unrecorded users once
then
y=$((y+2))
else
x=$((x-112)) # move the marker back to pick up the right RID
fi
x=$((x+48)) # in users the sids are recorded later
fi
group_members_rid[$i$y]=${c_value[$i]:($x+6):2}${c_value[$i]:($x+4):2}${c_value[$i]:($x+2):2}${c_value[$i]:$x:2}
group_members_rid[$i$y]=`echo ${group_members_rid[$i$y]} | tr '[:lower:]' '[:upper:]'`
z=0
while [ $z -lt $num_users ]
do
(( z++ ))
if [ "${group_members_rid[$i$y]}" = "${rid[$z]}" ] # if the rids match
then
group_members_name[$i$y]=${name[$z]} # add the usernames to the group array
memberof[$z]=${memberof[$z]}": "${groupname[$i]}"\n\r\t\t\t" # add the groupname to the user
fi
done
done
done
}
######################################################################
# Scan ntuser hives given and tries to allocate them to a username #
# Assigns: $ntu_files #
# $num_ntuser_hives #
# $ntu_loc[$z] #
# $ntu_name[$z] #
######################################################################
get_ntuser_hives_func () {
#### get the ntuser.dat files that are there and put them in an array ####
ntu_files=`find $default_location -maxdepth 1 -iname NTUSER.DA*`
num_ntuser_hives=`echo "$ntu_files" | grep -ic "NTUSER.DAT"` # ic = ignore case and count
z=0
temp=$ntu_files
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp"`
do
(( z++ ))
ntu_loc[$z]=$eachline
done
IFS=$p
#### allocate users to ntuser.dat files if possible ####
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
i=0
while [ $i -lt $num_users ]
do
(( i++ ))
if [ "${ntu_loc[$z]}" = "$default_location/${user_ntuser_loc[$i]}" ]
then
ntu_name[$z]=${name[$i]}
ntu_profile_folder[$z]=${user_profile_folder[$i]}
i=$num_users #stop
fi
if ( [ $i = $num_users ] && [ -z "${ntu_name[$z]}" ] ) # if you've checked all the users and no match
then
ntu_name[$z]="Unable to associate with a username"
ntu_profile_folder[$z]="Unrecorded"
fi
done
done
}
##############################################################################
# Get shell folders #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders #
# Assigns: $ntu_user_shell_folders[$z] #
# Get recent docs mrulists - this function get the extentions used #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs #
# Assigns: $rdocs_num_ext[$z] #
# $rdocs_ext[$z$i] ($z indicates user $i indicates ext #) #
##############################################################################
get_ntuser_data_func () {
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -v`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
ntu_user_shell_folders[$z]=`echo "$temp_string" | sed -e 's/(REG_EXPAND_SZ) //'`
ntu_user_shell_folders[$z]="${ntu_user_shell_folders[$z]##*]}"
################### start of recent docs #################################
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
i=0
rdocs_date[$z]=${temp_string%%]*}
rdocs_date[$z]=`echo ${rdocs_date[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
if [ "${rdocs_date[$z]}" = "(UTC)" ]
then
rdocs_date[$z]="No recent docs MRU associated with this user"
fi
rdocs_ext[$z$i]=${temp_string%%]*} # $z$i = $z0 to root mru
#################### extract MRU for each extention #######################
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
if [ "${eachline:0:2}" = ".." ] # if the line holds an extention subkey
then
(( i++ ))
rdocs_ext[$z$i]=${eachline##*..?}
rdocs_name[$z$i]=${rdocs_ext[$z$i]}
rdocs_ext[$z$i]=`perl $regdump_location ${ntu_loc[$z]} "Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs$bslash${rdocs_ext[$z$i]}" -v`
last_folder[$z$i]=${rdocs_ext[$z$i]} # set the last folder each time so that temp_string can
if [ "$logging" != "off" ] # be truncated to isolate general mru list from .ext(s)
then
echo "${rdocs_ext[$z$i]}" >> $expert_log_location
fi
fi
done
IFS=$p
((rdocs_num_exts[$z]=i))
rdocs_ext[$z"0"]=${rdocs_ext[$z"0"]#*${last_folder[$z$i]}} # get rid of the folders in the mru root string
done
}
###########################################################
# Goes through each hive, pulls up each mrulist extention #
# and generates and converts each MRU list to ascii #
# Assigns: $mrulist_date[$z$i] #
# $mrulist[$z] #
###########################################################
get_ntuser_mrulist_func () {
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
mrustring=""
i=0
while [ $i -le ${rdocs_num_exts[$z]} ]
do
exist=`echo "${rdocs_ext[$z$i]}" | grep -c "MRUListEx"`
if [ $exist -gt "0" ] # if there is an MRUList
then
mrulist_date[$z$i]=${rdocs_ext[$z$i]%%]*}
mrulist_date[$z$i]=`echo ${mrulist_date[$z$i]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
mrulist[$z$i]=`echo ${rdocs_ext[$z$i]}|awk -F'MRUListEx \(REG_BINARY\) = |ff ff ff ff' '{print $2}'`
mrustring=$mrustring${rdocs_name[$z$i]}" MRU List - "${mrulist_date[$z$i]}$crlf
y=0 # counter for number of mru entries
x=0 # marker for position to extract little endian data nb 1 space between data
finish="no"
while [ $finish = "no" ]
do
mru_num[$y]=${mrulist[$z$i]:($x+9):2}${mrulist[$z$i]:($x+6):2}${mrulist[$z$i]:($x+3):2}${mrulist[$z$i]:$x:2}
x=$x+12 # move to the next entry
if [ -z "${mru_num[$y]}" ] # if the last mru entry didn't exist
then
no_entries[$z$i]=$y
finish="yes"
else
mru_num[$y]=`echo ${mru_num[$y]}| tr '[:lower:]' '[:upper:]'`
mru_num[$y]=`echo "ibase=16;obase=A;${mru_num[$y]}" | bc` # convert to decimal
mru_data[$y]=${rdocs_ext[$z$i]##*${mru_num[$y]} (REG_BINARY) = } # cut to start
mru_data[$y]=${mru_data[$y]%%00 00 00*} # cut to first 00 00 to get UTF-16 name
# loop to convert to text note last unicode only 2 chars long echo -e "\u????" ok
mru_data_length[$y]=$((((${#mru_data[$y]}+4))/6)) # get the number of chars
j=0
name=""
while [ $j -lt ${mru_data_length[$y]} ]
do
# turn 45 00 into 0045
nextbit=${mru_data[$y]:(((($j*3))+3*(($j+1)))):2}${mru_data[$y]:(($j*6)):2}
name=$name`echo -e "\u"$nextbit`
(( j++ ))
done
mrustring=$mrustring" "$name$crlf
(( y++ ))
fi
done
fi
(( i++))
done
mru_list[$z]=$mrustring
done
}
######################################################################
# Get media player mrulist #
# HKCU\Software\Microsoft\MediaPlayer\Player\RecentFileList #
# Assigns: $mediaplayer[$z] for each user hive #
######################################################################
get_ntuser_mediaplayer_mru_func () {
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\MediaPlayer\Player\RecentFileList" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
mediaplayer[$z]="There are no entries associated with this user"
else
mediaplayer[$z]=${temp_string%%]*}
mediaplayer[$z]=`echo ${mediaplayer[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
firstbit=${eachline%%\(*}
lastbit=${eachline##* = }
mediaplayer[$z]=${mediaplayer[$z]}$crlf$firstbit$lastbit
done
IFS=$p
fi
done
}
######################################################################
# Get typed url list #
# HKCU\Software\Microsoft\Internet Explorer\TypedURLs #
# Assigns: $urllist[$z] for each user hive #
######################################################################
get_ntuser_typed_urls_func () {
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Internet Explorer\TypedURLs" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
urllist[$z]="There are no entries associated with this user"
else
urllist[$z]=${temp_string%%]*}
urllist[$z]=`echo ${urllist[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
firstbit=${eachline%%\(*}
firstbit=${firstbit##*url}
lastbit=${eachline##* = }
urllist[$z]=${urllist[$z]}$crlf" "$firstbit$lastbit
done
IFS=$p
fi
done
}
######################################################################
# Get Userassist strings, do ROT13 "decryption" #
# Window 7 #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist #
# \{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count #
# Assigns: $uassist_intexp[$z] for each user hive #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist #
# \{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count #
# Assigns: $uassist_desktop[$z] #
# XP & Vista (subtracts 5 from some counts) #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist #
# \{5E6AB780-7743-11CF-A12B-00AA004AE837}\Count #
# Assigns: $uassist_intexp[$z] #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist #
# \{75048700-EF1F-11D0-9888-006097DEACF9}\Count #
# Assigns: $uassist_desktop[$z] #
######################################################################
get_userassist_func () {
if [ "$win7" = "yes" ] # win 7 only #
then
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
uassist_intexp[$z]="There are no entries associated with this user"
else
uassist_intexp[$z]=${temp_string%%]*}
uassist_intexp[$z]=`echo ${uassist_intexp[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
rot13=""
firstbit=${eachline%% \(*}
firstbit=${firstbit##*\}}
firstbit=`echo $firstbit | xxd -u -ps` # | tr -d " "`
firstbit=`echo $firstbit | tr -d " "`
len_firstbit=$((${#firstbit}/2))
x=0
while [ $x -lt $len_firstbit ] # do ROT-13
do
char=${firstbit:($x*2):2}
case $char in
41|42|43|44|45|46|47|48|49|4A|4B|4C|4D) dechar=`printf "%X" $((0x$char+0xD))`;;
4E|4F|50|51|52|53|54|55|56|57|58|59|5A) dechar=`printf "%X" $((0x$char-0xD))`;;
61|62|63|64|65|66|67|68|69|6A|6B|6C|6D) dechar=`printf "%X" $((0x$char+0xD))`;;
6E|6F|70|71|72|73|74|75|76|77|78|79|7A) dechar=`printf "%X" $((0x$char-0xD))`;;
*) dechar=$char;;
esac
rot13=$rot13$dechar
(( x++ ))
done
firstbit=`echo $rot13 | xxd -r -p`
lastbit=`echo ${eachline##* = } | tr -d " "`
uacount=${lastbit:14:2}${lastbit:12:2}${lastbit:10:2}${lastbit:8:2}
uacount2=${lastbit:22:2}${lastbit:20:2}${lastbit:18:2}${lastbit:16:2}
uatime=${lastbit:134:2}${lastbit:132:2}${lastbit:130:2}${lastbit:128:2}${lastbit:126:2}${lastbit:124:2}${lastbit:122:2}${lastbit:120:2} # uatime = timestamp of last usage
input_string=$uacount # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount=$output_string # win 7 uacount seems to be # uses in current month not total
uacount=`echo "ibase=16;obase=A;$uacount" | bc`
input_string=$uacount2 # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount2=$output_string
uacount2=`echo "ibase=16;obase=A;$uacount2" | bc`
if [ "$uatime" = "0000000000000000" ]
then
uatime=""
else
uatime=`echo $((0x$uatime/10000000-11644473600))` #convert windowstime to unix time
uatime=`date -d @$uatime 2>/dev/null` #convert unixtime
fi
uassist_intexp[$z]=${uassist_intexp[$z]}"$lfcr"" "$firstbit" ("$uacount") "" ("$uacount2") "$uatime
done
IFS=$p
fi
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
uassist_desktop[$z]="There are no entries associated with this user"
else
uassist_desktop[$z]=${temp_string%%]*}
uassist_desktop[$z]=`echo ${uassist_desktop[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
rot13=""
firstbit=${eachline%% \(*}
firstbit=${firstbit##*\}}
firstbit=`echo $firstbit | xxd -u -ps` # | tr -d " "`
firstbit=`echo $firstbit | tr -d " "`
len_firstbit=$((${#firstbit}/2))
x=0
while [ $x -lt $len_firstbit ] # do ROT-13
do
char=${firstbit:($x*2):2}
case $char in
41|42|43|44|45|46|47|48|49|4A|4B|4C|4D) dechar=`printf "%X" $((0x$char+0xD))`;;
4E|4F|50|51|52|53|54|55|56|57|58|59|5A) dechar=`printf "%X" $((0x$char-0xD))`;;
61|62|63|64|65|66|67|68|69|6A|6B|6C|6D) dechar=`printf "%X" $((0x$char+0xD))`;;
6E|6F|70|71|72|73|74|75|76|77|78|79|7A) dechar=`printf "%X" $((0x$char-0xD))`;;
*) dechar=$char;;
esac
rot13=$rot13$dechar
(( x++ ))
done
firstbit=`echo $rot13 | xxd -r -p`
lastbit=`echo ${eachline##* = } | tr -d " "`
uacount=${lastbit:14:2}${lastbit:12:2}${lastbit:10:2}${lastbit:8:2}
uacount2=${lastbit:22:2}${lastbit:20:2}${lastbit:18:2}${lastbit:16:2}
uatime=${lastbit:134:2}${lastbit:132:2}${lastbit:130:2}${lastbit:128:2}${lastbit:126:2}${lastbit:124:2}${lastbit:122:2}${lastbit:120:2} # uatime = timestamp of last usage
input_string=$uacount # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount=$output_string # win 7 uacount seems to be # uses in current month not total
uacount=`echo "ibase=16;obase=A;$uacount" | bc`
input_string=$uacount2 # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount2=$output_string
uacount2=`echo "ibase=16;obase=A;$uacount2" | bc`
if [ "$uatime" = "0000000000000000" ]
then
uatime=""
else
uatime=`echo $((0x$uatime/10000000-11644473600))` #convert windowstime to unix time
uatime=`date -d @$uatime 2>/dev/null` #convert unixtime
fi
uassist_desktop[$z]=${uassist_desktop[$z]}"$lfcr"" "$firstbit" ("$uacount") "" ("$uacount2") "$uatime
done
IFS=$p
fi
done
################################ the xp/vista bit ##########################################################################
else
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{5E6AB780-7743-11CF-A12B-00AA004AE837}\Count" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
uassist_intexp[$z]="There are no entries associated with this user"
else
uassist_intexp[$z]=${temp_string%%]*}
uassist_intexp[$z]=`echo ${uassist_intexp[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
rot13=""
firstbit=${eachline%% \(*}
firstbit=${firstbit##*\}}
firstbit=`echo $firstbit | xxd -u -ps` # | tr -d " "`
firstbit=`echo $firstbit | tr -d " "`
len_firstbit=$((${#firstbit}/2))
x=0
while [ $x -lt $len_firstbit ] # do ROT-13
do
char=${firstbit:($x*2):2}
case $char in
41|42|43|44|45|46|47|48|49|4A|4B|4C|4D) dechar=`printf "%X" $((0x$char+0xD))`;;
4E|4F|50|51|52|53|54|55|56|57|58|59|5A) dechar=`printf "%X" $((0x$char-0xD))`;;
61|62|63|64|65|66|67|68|69|6A|6B|6C|6D) dechar=`printf "%X" $((0x$char+0xD))`;;
6E|6F|70|71|72|73|74|75|76|77|78|79|7A) dechar=`printf "%X" $((0x$char-0xD))`;;
*) dechar=$char;;
esac
rot13=$rot13$dechar
(( x++ ))
done
firstbit=`echo $rot13 | xxd -r -p`
lastbit=`echo ${eachline##* = } | tr -d " "`
uacount=${lastbit:14:2}${lastbit:12:2}${lastbit:10:2}${lastbit:8:2}
uatime=${lastbit:30:2}${lastbit:28:2}${lastbit:26:2}${lastbit:24:2}${lastbit:22:2}${lastbit:20:2}${lastbit:18:2}${lastbit:16:2} # uatime = timestamp of last usage
input_string=$uacount # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount=$output_string
uacount=`echo "ibase=16;obase=A;$uacount" | bc` # counting starts @ 6
if [ "$uacount" -lt "6" ] && [ "${firstbit:0:12}" = "UEME_RUNPIDL" ]
then # if the count is < 6 for pidl then not a run eg mouseover
uacount="0" # if it's greater than 6 and pidl same rules as for path
else # and cpl, -5 to get actual run count
if [ "${firstbit:0:12}" = "UEME_RUNPATH" ] || [ "${firstbit:0:11}" = "UEME_RUNCPL" ] || [ "${firstbit:0:12}" = "UEME_RUNPIDL" ]
then
uacount=$(($uacount-5))
fi
fi
if [ "$uatime" = "0000000000000000" ]
then
uatime=""
else
uatime=`echo $((0x$uatime/10000000-11644473600))` #convert windowstime to unix time
uatime=`date -d @$uatime 2>/dev/null` #convert unixtime
fi
uassist_intexp[$z]=${uassist_intexp[$z]}"$lfcr"" "$firstbit" ("$uacount") "$uatime
done
IFS=$p
fi
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
uassist_desktop[$z]="There are no entries associated with this user"
else
uassist_desktop[$z]=${temp_string%%]*}
uassist_desktop[$z]=`echo ${uassist_desktop[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
rot13=""
firstbit=${eachline%% \(*}
firstbit=${firstbit##*\}}
firstbit=`echo $firstbit | xxd -u -ps` # | tr -d " "`
firstbit=`echo $firstbit | tr -d " "`
len_firstbit=$((${#firstbit}/2))
x=0
while [ $x -lt $len_firstbit ] # do ROT-13
do
char=${firstbit:($x*2):2}
case $char in
41|42|43|44|45|46|47|48|49|4A|4B|4C|4D) dechar=`printf "%X" $((0x$char+0xD))`;;
4E|4F|50|51|52|53|54|55|56|57|58|59|5A) dechar=`printf "%X" $((0x$char-0xD))`;;
61|62|63|64|65|66|67|68|69|6A|6B|6C|6D) dechar=`printf "%X" $((0x$char+0xD))`;;
6E|6F|70|71|72|73|74|75|76|77|78|79|7A) dechar=`printf "%X" $((0x$char-0xD))`;;
*) dechar=$char;;
esac
rot13=$rot13$dechar
(( x++ ))
done
firstbit=`echo $rot13 | xxd -r -p`
lastbit=`echo ${eachline##* = } | tr -d " "`
uacount=${lastbit:14:2}${lastbit:12:2}${lastbit:10:2}${lastbit:8:2}
uatime=${lastbit:30:2}${lastbit:28:2}${lastbit:26:2}${lastbit:24:2}${lastbit:22:2}${lastbit:20:2}${lastbit:18:2}${lastbit:16:2} # uatime = timestamp of last usage
input_string=$uacount # chop off the leading zeros
input_string_length=8
leading_zeros_func
uacount=$output_string
uacount=`echo "ibase=16;obase=A;$uacount" | bc` # counting starts @ 6
if [ $uacount -lt "6" ] && [ ${firstbit:0:12} = "UEME_RUNPIDL" ]
then # if the count is < 6 for pidl then not a run eg mouseover
uacount="0" # if it's greater than 6 and pidl same rules as for path
else # and cpl, -5 to get actual run count
if [ "${firstbit:0:12}" = "UEME_RUNPATH" ] || [ "${firstbit:0:11}" = "UEME_RUNCPL" ] || [ "${firstbit:0:12}" = "UEME_RUNPIDL" ]
then
uacount=$(($uacount-5))
fi
fi
if [ "$uatime" = "0000000000000000" ]
then
uatime=""
else
uatime=`echo $((0x$uatime/10000000-11644473600))` #convert windowstime to unix time
uatime=`date -d @$uatime 2>/dev/null` #convert unixtime
fi
uassist_desktop[$z]=${uassist_desktop[$z]}"$lfcr"" "$firstbit" ("$uacount") "$uatime
done
IFS=$p
fi
done
fi
}
######################################################################
# Get run MRUlist #
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU #
# Assigns: runmru[$z] for each user hive #
######################################################################
get_ntuser_runmru_func () {
z=0
while [ $z -lt $num_ntuser_hives ]
do
(( z++ ))
temp_string=`perl $regdump_location "${ntu_loc[$z]}" "Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" -v 2>/dev/null`
if [ "$logging" != "off" ]
then
echo "$temp_string" >> $expert_log_location
fi
if [ -z "$temp_string" ]
then
runmru[$z]="There are no entries associated with this user"
else
runmru[$z]=${temp_string%%]*}
runmru[$z]=`echo ${runmru[$z]##*[} | tr "T" " " | tr "Z" " "`"(UTC)"
temp_string=${temp_string#*]} # take the timestamp etc out of temp_string
i=0
p=$IFS
IFS=$'\n'
for eachline in `echo "$temp_string"`
do
(( i++ ))
firstbit[$i]=${eachline%% \(*} # the a,b,c etc or MRUlist
cmdbit[$i]=${eachline##* = } # just the command
if [ "${firstbit[$i]}" = "MRUList" ]
then
mruorder=${cmdbit[$i]}
(( i-- )) # don't increment i if its the mrulist rather than an entry
else
cmdbit[$i]=${cmdbit[$i]%%??} # all bar the last two chars typically \1
fi
done
((num_runmru=i))
IFS=$p
i=0 # the pointer for each element in mruorder
while [ $i -lt $num_runmru ]
do
x=0 # the pointer for each firstbit[$?]
(( i++ ))
while [ $x -lt $num_runmru ]
do
(( x++ ))
if [ "${mruorder:($i-1):1}" = "${firstbit[$x]}" ]
then
runmru[$z]=${runmru[$z]}$crlf" "${cmdbit[$x]}
x=$num_runmru # if you find a match stop looking
fi
done