-
Notifications
You must be signed in to change notification settings - Fork 83
/
Forensicator.ps1
7825 lines (7097 loc) · 344 KB
/
Forensicator.ps1
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
# Live Forensicator Powershell Script
# Part of the Black Widow Tools
# Coded by Ebuka John Onyejegbu
[cmdletbinding()]
param(
[String]$LOG4J,
[String]$RAM,
[String]$EVTX,
[String]$OPERATOR,
[String]$CASE,
[String]$TITLE,
[String]$LOCATION,
[String]$DEVICE,
[String]$RANSOMWARE,
[String]$WEBLOGS,
[String]$BROWSER,
[String]$PCAP,
[String]$ENCRYPTED,
[switch]$UPDATE,
[switch]$VERSION,
[switch]$DECRYPT,
[switch]$USAGE
)
$ErrorActionPreference = 'silentlycontinue'
Write-Host -Fore DarkCyan "[!] Starting... "
##################################################
#region Auto Check Update #
##################################################
$Hostname = $env:computername
$localVersion = Get-Content -Path .\version.txt
# GitHub repository details
$repoOwner = "johnng007"
$repoName = "Live-Forensicator"
$branch = "main"
$versionFile = "version.txt"
$rawUrl = "https://raw.githubusercontent.com/$repoOwner/$repoName/$branch/$versionFile"
# Function to check for updates
function CheckForUpdates {
try {
# Fetch the version from GitHub
$remoteVersion = (Invoke-RestMethod -Uri $rawUrl).Trim() -replace '\s+'
# Compare local and remote versions
if ($localVersion -lt $remoteVersion) {
Write-Host -Fore Cyan "[!] A new version $remoteVersion is available on Github. Please upgrade your copy of Forensicator."
}
else {
Write-Host -Fore Cyan "[!] You are using the latest version $localVersion No updates available."
}
}
catch {
Write-Host "Failed to check for updates. You probably dont have internet connection."
Write-Host "Error: $_"
}
}
# Call the function to check for updates
CheckForUpdates
##################################################
#region Versioning & Update #
##################################################
$version_file = $PSScriptRoot + "\" + "Updated" + "\" + "version.txt"
$current_version = $PSScriptRoot + "\" + "version.txt"
$MyVersion = Get-Content -Path .\version.txt
if ($VERSION.IsPresent) {
Write-Host -Fore Cyan "[!] You are currently running" $MyVersion
Write-Host ''
exit 0
}
if ($UPDATE) {
Write-Host -Fore DarkCyan "[*] Downloading & Comparing Version Files"
New-Item -Name "Updated" -ItemType "directory" -Force | Out-Null
Set-Location Updated
$source = 'https://raw.githubusercontent.com/Johnng007/Live-Forensicator/main/version.txt'
$destination = 'version.txt'
if (((Test-NetConnection www.githubusercontent.com -Port 80 -InformationLevel "Detailed").TcpTestSucceeded) -eq $true) {
Invoke-WebRequest -Uri $source -OutFile $destination
}
else {
Write-Host -Fore DarkCyan "[*] githubusercontent.com is not reacheable, please check your connection"
Set-Location $PSScriptRoot
Remove-Item 'Updated' -Force -Recurse
exit 0
}
if ((Get-FileHash $version_file).hash -eq (Get-FileHash $current_version).hash) {
Write-Host -Fore Cyan "[*] Congratualtion you have the current version"
Set-Location $PSScriptRoot
Remove-Item 'Updated' -Force -Recurse
exit
}
else {
Write-Host -Fore DarkCyan "[!] You have an outdated version, we are sorting that out..."
$source = 'https://github.com/Johnng007/Live-Forensicator/archive/refs/heads/main.zip'
$destination = 'Live-Forensicator-main.zip'
Invoke-WebRequest -Uri $source -OutFile $destination
Write-Host -Fore DarkCyan "[*] Extracting the downloads....."
Expand-Archive -Force $PSScriptRoot\Updated\Live-Forensicator-main.zip -DestinationPath $PSScriptRoot\Updated
Write-Host -Fore DarkCyan "[*] Cleaning Up...."
Remove-Item -Path $PSScriptRoot\Updated\Live-Forensicator-main.zip -Force
Remove-Item -Path $PSScriptRoot\Updated\version.txt -Force
Write-Host -Fore Cyan "[*] All Done Enjoy the new version in the Updated Folder"
Set-Location $PSScriptRoot
exit 0
}
}
##################################################
#endregion Versioning & Update #
##################################################
##################################################
#region ARTIFACT DECRYPTION SWITCH #
##################################################
if ($DECRYPT) {
$DecryptPath = $PSScriptRoot + "\" + "$env:computername" + "\"
if (!(Get-ChildItem $DecryptPath *.forensicator)) {
Write-Host -Fore DarkCyan "[!] Cannot find encrypted file, Did you relocate it?"
$TargetPath = Read-Host -Prompt 'Enter Path to the Encrypted File'
}
else {
$TargetPath = $PSScriptRoot + "\" + "$env:computername" + "\"
}
# Import FileCryptography module
Import-Module "$PSScriptRoot\Forensicator-Share\FileCryptography.psm1"
$key = Read-Host -Prompt 'Enter Decryption Key'
$Extension = ".forensicator"
# Gather all files from the target path and its subdirectories
$FilestoDecrypt = get-childitem -path $TargetPath\* -Include *$Extension -Recurse -force | Where-Object { ! $_.PSIsContainer }
# Decrypt the files
foreach ($file in $FilestoDecrypt) {
Write-Host "Decrypting $file"
Unprotect-File $file -Algorithm AES -KeyAsPlainText $key -Suffix $Extension -RemoveSource
}
exit 0
}
else {
}
##################################################
#endregion ARTIFACT DECRYPTION SWITCH #
##################################################
##################################################
#region USAGE #
##################################################
if ($USAGE) {
Write-Host ''
Write-Host -Fore DarkCyan 'FORESNSICATOR USAGE'
Write-Host ''
Write-Host -Fore DarkCyan '[*] .\Forensicator.ps1 This runs the Basic checks on a system.'
Write-Host ''
Write-Host -Fore DarkCyan 'FLAGS'
Write-Host -Fore Cyan 'The below flags can be added to the Basic Usage'
Write-Host ''
Write-Host -Fore DarkCyan '[*] -EVTX EVTX Also grab Event Logs'
Write-Host -Fore DarkCyan '[*] -WEBLOGS WEBLOGS Also grab Web Logs.'
Write-Host -Fore DarkCyan '[*] -PCAP PCAP Run network tracing and capture PCAP for 120seconds'
Write-Host -Fore Cyan "[!] requires the etl2pcapng file in share folder"
Write-Host -Fore DarkCyan '[*] -RAM RAM Extract RAM Dump'
Write-Host -Fore Cyan "[!] requires the winpmem file in share folder"
Write-Host -Fore DarkCyan '[*] -LOG4J LOG4J Checks for vulnerable log4j files'
Write-Host -Fore DarkCyan '[*] -ENCRYPTED ENCRYPTED Encrypt Artifacts after collecting them'
Write-Host -Fore Cyan "[!] requires the FileCryptography file in share folder"
Write-Host -Fore DarkCyan '[*] -BROWSER BROWSER Grabs a detailed browsing history from system'
Write-Host -Fore Cyan "[!] requires the Nirsoft BrowserView file in share folder"
Write-Host -Fore DarkCyan ''
Write-Host -Fore DarkCyan 'SWITCHES'
Write-Host -Fore DarkCyan ''
Write-Host -Fore DarkCyan '[*] .\Forensicator.ps1 -VERSION This checks the version of Foresicator you have'
Write-Host -Fore DarkCyan '[*] .\Forensicator.ps1 -UPDATE This checks for and updates your copy of Forensicator'
Write-Host -Fore DarkCyan '[*] .\Forensicator.ps1 -DECRYPT DECRYPT This decrypts a Foresicator encrypted Artifact'
Write-Host -Fore Cyan "[!] requires the FileCryptography file in share folder"
Write-Host -Fore DarkCyan '[*] .\Forensicator.ps1 -USAGE Prints this help file'
exit 0
}
else {
}
##################################################
#endregion ARTIFACT DECRYPTION SWITCH #
##################################################
$ErrorActionPreference = 'silentlycontinue'
$t = @"
___________ .__ __
\_ _____/__________ ____ ____ _____|__| ____ _____ _/ |_ ___________
| __)/ _ \_ __ \_/ __ \ / \ / ___/ |/ ___\\__ \\ __\/ _ \_ __ \
| \( <_> ) | \/\ ___/| | \\___ \| \ \___ / __ \| | ( <_> ) | \/
\___ / \____/|__| \___ >___| /____ >__|\___ >____ /__| \____/|__|
\/ \/ \/ \/ \/ \/
$MyVersion
"@
for ($i = 0; $i -lt $t.length; $i++) {
if ($i % 2) {
$c = "red"
}
elseif ($i % 5) {
$c = "yellow"
}
elseif ($i % 7) {
$c = "green"
}
else {
$c = "white"
}
write-host $t[$i] -NoNewline -ForegroundColor $c
}
##################################################
#region Check if the share folder exists #
##################################################
Write-Host ''
$Folder = 'Forensicator-Share'
if (Test-Path -Path $Folder) {
#Write-Host -Fore Cyan "[!] You have the share folder moving on.."
}
else {
Write-Host -Fore Cyan "[!] Forensicator-Share folder not found, some flags and functions will not work! use the -UPDATE flag to import the complete Arsenal.."
Write-Host -Fore Cyan "[!] Moving on...."
}
##################################################
#endregion Check if the share folder exists #
##################################################
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host -Fore DarkCyan '[!] Live Forensicator'
Write-Host ''
Write-Host -Fore DarkCyan '[!] Examines the host for suspicious activities and grabs required data for further forensics.'
Write-Host -Fore DarkCyan '[!] By Ebuka John Onyejegbu.'
Write-Host -Fore DarkCyan '[!] https://github.com/Johnng007/Live-Forensicator'
Write-Host -Fore DarkCyan '[!] https://john.ng'
Write-Host ''
Write-Host ''
Write-Host ''
#######################################################################
#region PARAMETER SETTINGS ###########################################
#######################################################################
#FOR OPERATOR
if ($OPERATOR) {
$Handler = $OPERATOR
}
else {
$Handler = Read-Host -Prompt 'Enter Investigator Name'
}
#FOR CASE REFERENCE
if ($CASE) {
$CASENO = $CASE
}
else {
$CASENO = Read-Host -Prompt 'Enter Case Reference'
}
#EXHIBIT REFERENCE
if ($TITLE) {
$Ref = $TITLE
}
else {
$Ref = Read-Host -Prompt 'Enter Investigation Title'
}
#LOCATION
if ($LOCATION) {
$Loc = $LOCATION
}
else {
$Loc = Read-Host -Prompt 'Enter examination location'
}
#DESCRIPTION
if ($DEVICE) {
$Des = $DEVICE
}
else {
$Des = Read-Host -Prompt 'Enter description of device e.g. "Asus Laptop"'
}
#######################################################################
#endregion END PARAMETER SETTINGS #####################################
#######################################################################
Write-Host ''
Write-Host ''
Write-Host ''
$DateFormat = "yyyy'-'MM'-'dd HH':'mm':'ss"
$StartTime = Get-Date -Format $DateFormat
# creating a directory to store the artifacts of this host
mkdir $env:computername -Force | Out-Null
# Moving to the new folder
Set-Location $env:computername
# Setting index output file
$ForensicatorIndexFile = 'index.html'
# Setting Extras Output file
$ForensicatorExtrasFile = 'extras.html'
# Setting Network Information Output
$NetworkFile = 'network.html'
# Setting Users Information Output
$UserFile = 'users.html'
# Setting System Information Output
$SystemFile = 'system.html'
# Setting Processes Output
$ProcessFile = 'processes.html'
# Setting Other Checks Output
$OthersFile = 'others.html'
# Setting Evtx Checks Output
$EvtxUserFile = 'evtx_user.html'
# Setting Evtx Logon Eents Checks Output
$LogonEventsFile = 'evtx_logons.html'
# Setting Evtx Object Access Checks Output
$ObjectEventsFile = 'evtx_object.html'
# Setting Evtx Process Execution Checks Output
$ProcessEventsFile = 'evtx_process.html'
# Setting Evtx Suspicious Activities Output
$SuspiciousEventsFile = 'evtx_suspicious.html'
##################################################
#region Network Information and Settings #
##################################################
Write-Host -Fore DarkCyan "[*] Gathering Network & Network Settings"
#Gets DNS cache. Replaces ipconfig /dislaydns
$DNSCache = Get-DnsClientCache | Select-Object Entry, Name, Status, TimeToLive, Data #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $DNSCache) {
$DNSCacheFragment += "<tr>"
$DNSCacheFragment += "<td>$($process.Entry)</td>"
$DNSCacheFragment += "<td>$($process.Name)</td>"
$DNSCacheFragment += "<td>$($process.Status)</td>"
$DNSCacheFragment += "<td>$($process.TimeToLive)</td>"
$DNSCacheFragment += "<td>$($process.Data)</td>"
$DNSCacheFragment += "</tr>"
}
$NetworkAdapter = Get-WmiObject -class Win32_NetworkAdapter | Select-Object -Property AdapterType, ProductName, Description, MACAddress, Availability, NetconnectionStatus, NetEnabled, PhysicalAdapter #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetworkAdapter) {
$NetworkAdapterFragment += "<tr>"
$NetworkAdapterFragment += "<td>$($process.AdapterType)</td>"
$NetworkAdapterFragment += "<td>$($process.ProductName)</td>"
$NetworkAdapterFragment += "<td>$($process.Description)</td>"
$NetworkAdapterFragment += "<td>$($process.MACAddress)</td>"
$NetworkAdapterFragment += "<td>$($process.Availability)</td>"
$NetworkAdapterFragment += "<td>$($process.NetconnectionStatus)</td>"
$NetworkAdapterFragment += "<td>$($process.NetEnabled)</td>"
$NetworkAdapterFragment += "<td>$($process.PhysicalAdapter)</td>"
$NetworkAdapterFragment += "</tr>"
}
#Replaces ipconfig:
$IPConfiguration = Get-WmiObject Win32_NetworkAdapterConfiguration | Select-Object Description, @{Name = 'IpAddress'; Expression = { $_.IpAddress -join '; ' } }, @{Name = 'IpSubnet'; Expression = { $_.IpSubnet -join '; ' } }, MACAddress, @{Name = 'DefaultIPGateway'; Expression = { $_.DefaultIPGateway -join '; ' } }, DNSDomain, DNSHostName, DHCPEnabled, ServiceName #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $IPConfiguration) {
$IPConfigurationFragment += "<tr>"
$IPConfigurationFragment += "<td>$($process.Description)</td>"
$IPConfigurationFragment += "<td>$($process.MACAddress)</td>"
$IPConfigurationFragment += "<td>$($process.DNSDomain)</td>"
$IPConfigurationFragment += "<td>$($process.DNSHostName)</td>"
$IPConfigurationFragment += "<td>$($process.DHCPEnabled)</td>"
$IPConfigurationFragment += "<td>$($process.ServiceName)</td>"
$IPConfigurationFragment += "</tr>"
}
$NetIPAddress = Get-NetIPaddress | Select-Object InterfaceAlias, IPaddress, EnabledState, OperatingStatus #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetIPAddress) {
$NetIPAddressFragment += "<tr>"
$NetIPAddressFragment += "<td>$($process.InterfaceAlias)</td>"
$NetIPAddressFragment += "<td>$($process.IPaddress)</td>"
$NetIPAddressFragment += "<td>$($process.EnabledState)</td>"
$NetIPAddressFragment += "<td>$($process.OperatingStatus)</td>"
$NetIPAddressFragment += "</tr>"
}
$NetConnectProfile = Get-NetConnectionProfile | Select-Object Name, InterfaceAlias, NetworkCategory, IPV4Connectivity, IPv6Connectivity #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetConnectProfile) {
$NetConnectProfileFragment += "<tr>"
$NetConnectProfileFragment += "<td>$($process.Name)</td>"
$NetConnectProfileFragment += "<td>$($process.InterfaceAlias)</td>"
$NetConnectProfileFragment += "<td>$($process.NetworkCategory)</td>"
$NetConnectProfileFragment += "<td>$($process.IPV4Connectivity)</td>"
$NetConnectProfileFragment += "<td>$($process.IPv6Connectivity)</td>"
$NetConnectProfileFragment += "</tr>"
}
$NetAdapter = Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, MacAddress, LinkSpeed #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetAdapter) {
$NetAdapterFragment += "<tr>"
$NetAdapterFragment += "<td>$($process.Name)</td>"
$NetAdapterFragment += "<td>$($process.InterfaceDescription)</td>"
$NetAdapterFragment += "<td>$($process.Status)</td>"
$NetAdapterFragment += "<td>$($process.MacAddress)</td>"
$NetAdapterFragment += "<td>$($process.LinkSpeed)</td>"
$NetAdapterFragment += "</tr>"
}
#Replaces arp -a:
$NetNeighbor = Get-NetNeighbor | Select-Object InterfaceAlias, IPAddress, LinkLayerAddress #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetNeighbor) {
$NetNeighborFragment += "<tr>"
$NetNeighborFragment += "<td>$($process.InterfaceAlias)</td>"
$NetNeighborFragment += "<td>$($process.IPAddress)</td>"
$NetNeighborFragment += "<td>$($process.LinkLayerAddress)</td>"
$NetNeighborFragment += "</tr>"
}
#Replaces netstat commands
$NetTCPConnect = Get-NetTCPConnection | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State, OwningProcess, @{Name = "Process"; Expression = { (Get-Process -Id $_.OwningProcess).ProcessName } } #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetTCPConnect) {
$NetTCPConnectFragment += "<tr>"
$NetTCPConnectFragment += "<td>$($process.LocalAddress)</td>"
$NetTCPConnectFragment += "<td>$($process.LocalPort)</td>"
$NetTCPConnectFragment += "<td>$($process.RemoteAddress)</td>"
$NetTCPConnectFragment += "<td>$($process.RemotePort)</td>"
$NetTCPConnectFragment += "<td>$($process.State)</td>"
$NetTCPConnectFragment += "<td>$($process.OwningProcess)</td>"
$NetTCPConnectFragment += "</tr>"
}
#Get Wi-fi Names and Passwords
$WlanPasswords = netsh.exe wlan show profiles | Select-String "\:(.+)$" | ForEach-Object { $wlanname = $_.Matches.Groups[1].Value.Trim(); $_ } | ForEach-Object { (netsh wlan show profile name="$wlanname" key=clear) } | Select-String 'Key Content\W+\:(.+)$' | ForEach-Object { $wlanpass = $_.Matches.Groups[1].Value.Trim(); [PSCustomObject]@{ PROFILE_NAME = $wlanname; PASSWORD = $wlanpass } }
$WlanPasswordsFragment = ""
foreach ($process in $WlanPasswords) {
$WlanPasswordsFragment += "<tr>"
$WlanPasswordsFragment += "<td>$($process.PROFILE_NAME)</td>"
$WlanPasswordsFragment += "<td>$($process.PASSWORD)</td>"
$WlanPasswordsFragment += "</tr>"
}
#Get Firewall Information. Replaces netsh firewall show config
$FirewallRule = Get-NetFirewallRule | select-object Name, DisplayName, Description, Direction, Action, EdgeTraversalPolicy, Owner, EnforcementStatus #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $FirewallRule) {
$FirewallRuleFragment += "<tr>"
$FirewallRuleFragment += "<td>$($process.Name)</td>"
$FirewallRuleFragment += "<td>$($process.DisplayName)</td>"
$FirewallRuleFragment += "<td>$($process.Description)</td>"
$FirewallRuleFragment += "<td>$($process.Direction)</td>"
$FirewallRuleFragment += "<td>$($process.Action)</td>"
$FirewallRuleFragment += "<td>$($process.EdgeTraversalPolicy)</td>"
$FirewallRuleFragment += "<td>$($process.Owner)</td>"
$FirewallRuleFragment += "<td>$($process.EnforcementStatus)</td>"
$FirewallRuleFragment += "</tr>"
}
#Outgoing SMB Session
$outboundSmbSessions = Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 445 -and $_.State -eq "Established" }
foreach ($process in $outboundSmbSessions) {
$outboundSmbSessionsFragment += "<tr>"
$outboundSmbSessionsFragment += "<td>$($process.LocalAddress)</td>"
$outboundSmbSessionsFragment += "<td>$($process.LocalPort)</td>"
$outboundSmbSessionsFragment += "<td>$($process.RemoteAddress)</td>"
$outboundSmbSessionsFragment += "<td>$($process.RemotePort)</td>"
$outboundSmbSessionsFragment += "<td>$($process.State)</td>"
$outboundSmbSessionsFragment += "<td>$($process.AppliedSetting)</td>"
$outboundSmbSessionsFragment += "<td>$($process.OwningProcess)</td>"
$outboundSmbSessionsFragment += "</tr>"
}
#Display active samba sessions
$SMBSessions = Get-SMBSession -ea silentlycontinue #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $SMBSessions) {
$SMBSessionsFragment += "<tr>"
$SMBSessionsFragment += "<td>$($process.SessionId)</td>"
$SMBSessionsFragment += "<td>$($process.ClientComputerName)</td>"
$SMBSessionsFragment += "<td>$($process.ClientUserName)</td>"
$SMBSessionsFragment += "<td>$($process.NumOpens)</td>"
$SMBSessionsFragment += "</tr>"
}
#Display active samba shares
$SMBShares = Get-SMBShare | Select-Object description, path, volume #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $SMBShares) {
$SMBSharesFragment += "<tr>"
$SMBSharesFragment += "<td>$($process.description)</td>"
$SMBSharesFragment += "<td>$($process.path)</td>"
$SMBSharesFragment += "<td>$($process.volume)</td>"
$SMBSharesFragment += "</tr>"
}
#Get IP routes to non-local destinations
$NetHops = Get-NetRoute | Where-Object -FilterScript { $_.NextHop -Ne "::" } | Where-Object -FilterScript { $_.NextHop -Ne "0.0.0.0" } | Where-Object -FilterScript { ($_.NextHop.SubString(0, 6) -Ne "fe80::") } #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $NetHops) {
$NetHopsFragment += "<tr>"
$NetHopsFragment += "<td>$($process.ifIndex)</td>"
$NetHopsFragment += "<td>$($process.DestinationPrefix)</td>"
$NetHopsFragment += "<td>$($process.NextHop)</td>"
$NetHopsFragment += "<td>$($process.RouteMetric)</td>"
$NetHopsFragment += "<td>$($process.ifMetric)</td>"
$NetHopsFragment += "<td>$($process.PolicyStore)</td>"
$NetHopsFragment += "</tr>"
}
#Get network adapters that have IP routes to non-local destinations
$AdaptHops = Get-NetRoute | Where-Object -FilterScript { $_.NextHop -Ne "::" } | Where-Object -FilterScript { $_.NextHop -Ne "0.0.0.0" } | Where-Object -FilterScript { ($_.NextHop.SubString(0, 6) -Ne "fe80::") } | Get-NetAdapter #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
foreach ($process in $AdaptHops) {
$AdaptHopsFragment += "<tr>"
$AdaptHopsFragment += "<td>$($process.Name)</td>"
$AdaptHopsFragment += "<td>$($process.InterfaceDescription)</td>"
$AdaptHopsFragment += "<td>$($process.ifIndex)</td>"
$AdaptHopsFragment += "<td>$($process.Status)</td>"
$AdaptHopsFragment += "<td>$($process.MacAddress)</td>"
$AdaptHopsFragment += "<td>$($process.LinkSpeed)</td>"
$AdaptHopsFragment += "</tr>"
}
#Get IP routes that have an infinite valid lifetime
$IpHops = Get-NetRoute | Where-Object -FilterScript { $_.ValidLifetime -Eq ([TimeSpan]::MaxValue) } #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
# Populate the HTML table with process information
foreach ($process in $IpHops) {
$IpHopsFragment += "<tr>"
$IpHopsFragment += "<td>$($process.ifIndex)</td>"
$IpHopsFragment += "<td>$($process.DestinationPrefix)</td>"
$IpHopsFragment += "<td>$($process.NextHop)</td>"
$IpHopsFragment += "<td>$($process.RouteMetric)</td>"
$IpHopsFragment += "<td>$($process.ifMetric)</td>"
$IpHopsFragment += "<td>$($process.PolicyStore)</td>"
$IpHopsFragment += "</tr>"
}
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region User & Account Information #
##################################################
Write-Host -Fore DarkCyan "[*] Gathering User & Account Information"
$userUID = id
$systemname = Get-WmiObject -Class Win32_ComputerSystem | Select-Object Name, DNSHostName, Domain, Manufacturer, Model, PrimaryOwnerName, TotalPhysicalMemory, Workgroup #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$systemnameFragment = ""
# Populate the HTML table with process information
foreach ($process in $systemname) {
$systemnameFragment += "<tr>"
$systemnameFragment += "<td>$($process.Name)</td>"
$systemnameFragment += "<td>$($process.DNSHostName)</td>"
$systemnameFragment += "<td>$($process.Domain)</td>"
$systemnameFragment += "<td>$($process.Manufacturer)</td>"
$systemnameFragment += "<td>$($process.Model)</td>"
$systemnameFragment += "<td>$($process.PrimaryOwnerName)</td>"
$systemnameFragment += "<td>$($process.TotalPhysicalMemory)</td>"
$systemnameFragment += "<td>$($process.Workgroup)</td>"
$systemnameFragment += "</tr>"
}
#$useraccounts = Get-WmiObject -Class Win32_UserAccount | Select-Object -Property AccountType,Domain,LocalAccount,Name,PasswordRequired,SID,SIDType | ConvertTo-Html -fragment
#$logonsessionhistory = Get-WmiObject -Class Win32_LogonSession | Select-Object -Property LogonID, LogonType, StartTime, @{Name = 'Start Time'; Expression = { $_.ConvertToDateTime($_.starttime) } } | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
#######ADDITIONS
$logonsession = (((quser) -replace '^>', '') -replace '\s{2,}', ',').Trim() | ConvertFrom-Csv #| ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
#$userprocesses = Get-Process -includeusername | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$logonsessionFragment = ""
# Populate the HTML table with process information
foreach ($process in $logonsession) {
$logonsessionFragment += "<tr>"
$logonsessionFragment += "<td>$($process.USERNAME)</td>"
$logonsessionFragment += "<td>$($process.SESSIONNAME)</td>"
$logonsessionFragment += "<td>$($process.STATE)</td>"
$logonsessionFragment += "<td>$($process.ID)</td>"
$logonsessionFragment += "<td>$($process.'IDLE TIME')</td>"
$logonsessionFragment += "<td>$($process.'LOGON TIME')</td>"
$logonsessionFragment += "</tr>"
}
$userprocesses = Get-Process -includeusername | Select-Object Name, Id, Username, CPU, Memory, Path
# Populate the HTML table with process information
$userprocessesFragment = ""
foreach ($process in $userprocesses) {
$userprocessesFragment += "<tr>"
$userprocessesFragment += "<td>$($process.Name)</td>"
$userprocessesFragment += "<td>$($process.Id)</td>"
$userprocessesFragment += "<td>$($process.UserName)</td>"
$userprocessesFragment += "<td>$($process.CPU)</td>"
$userprocessesFragment += "<td>$($process.Memory)</td>"
$userprocessesFragment += "<td>$($process.Path)</td>"
$userprocessesFragment += "</tr>"
}
#$userprofiles = Get-WmiObject -Class Win32_UserProfile | Select-object -property Caption, LocalPath, SID, @{Name = 'Last Used'; Expression = { $_.ConvertToDateTime($_.lastusetime) } } | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$userprofiles = Get-WmiObject -Class Win32_UserProfile | Select-object -property PSComputerName, LocalPath, SID, lastusetime
# Populate the HTML table with process information
$profileFragment = ""
foreach ($process in $userprofiles) {
$profileFragment += "<tr>"
$profileFragment += "<td>$($process.PSComputerName)</td>"
$profileFragment += "<td>$($process.LocalPath)</td>"
$profileFragment += "<td>$($process.SID)</td>"
$profileFragment += "<td>$([Management.ManagementDateTimeConverter]::ToDateTime($process.lastusetime))</td>"
$profileFragment += "</tr>"
}
#$administrators = Get-LocalGroupMember -Group "Administrators" | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$administrators = Get-LocalGroupMember -Group "Administrators"
# Populate the HTML table with process information
$adminFragment = ""
foreach ($process in $administrators) {
$adminFragment += "<tr>"
$adminFragment += "<td>$($process.Name)</td>"
$adminFragment += "<td>$($process.ObjectClass)</td>"
$adminFragment += "<td>$($process.PrincipalSource)</td>"
$adminFragment += "</tr>"
}
#$LocalGroup = Get-LocalGroup | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$LocalGroup = Get-LocalGroup
# Populate the HTML table with process information
$localFragment = ""
foreach ($process in $LocalGroup) {
$localFragment += "<tr>"
$localFragment += "<td>$($process.Name)</td>"
$localFragment += "<td>$($process.Description)</td>"
$localFragment += "</tr>"
}
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region Installed Programs #
##################################################
Write-Host -Fore DarkCyan "[*] Gathering Installed Programs"
#$InstProgs = Get-CimInstance -ClassName win32_product | Select-Object Name, Version, Vendor, InstallDate, InstallSource, PackageName, LocalPackage | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$InstProgs = Get-CimInstance -ClassName win32_product | Select-Object Name, Version, Vendor, InstallDate, InstallSource, PackageName, LocalPackage
# Populate the HTML table with process information
foreach ($process in $InstProgs) {
$InstProgsFragment += "<tr>"
$InstProgsFragment += "<td>$($process.Name)</td>"
$InstProgsFragment += "<td>$($process.Version)</td>"
$InstProgsFragment += "<td>$($process.Vendor)</td>"
$InstProgsFragment += "<td>$($process.InstallDate)</td>"
$InstProgsFragment += "<td>$($process.InstallSource)</td>"
$InstProgsFragment += "<td>$($process.PackageName)</td>"
$InstProgsFragment += "<td>$($process.LocalPackage)</td>"
$InstProgsFragment += "</tr>"
}
#$InstalledApps = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$InstalledApps = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
# Populate the HTML table with process information
foreach ($process in $InstalledApps) {
$InstalledAppsFragment += "<tr>"
$InstalledAppsFragment += "<td>$($process.DisplayName)</td>"
$InstalledAppsFragment += "<td>$($process.DisplayVersion)</td>"
$InstalledAppsFragment += "<td>$($process.Publisher)</td>"
$InstalledAppsFragment += "<td>$($process.InstallDate)</td>"
$InstalledAppsFragment += "</tr>"
}
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region System Info #
##################################################
Write-Host -Fore DarkCyan "[*] Gathering System Information"
#Environment Settings
#$env = Get-ChildItem ENV: | Select-Object name, value | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$env = Get-ChildItem ENV: | Select-Object name, value
# Populate the HTML table with process information
foreach ($process in $env) {
$envFragment += "<tr>"
$envFragment += "<td>$($process.name)</td>"
$envFragment += "<td>$($process.value)</td>"
$envFragment += "</tr>"
}
#System Info
#$systeminfo = Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property Name, Caption, SystemType, Manufacturer, Model, DNSHostName, Domain, PartOfDomain, WorkGroup, CurrentTimeZone, PCSystemType, HyperVisorPresent | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$systeminfo = Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property Name, Caption, SystemType, Manufacturer, Model, DNSHostName, Domain, PartOfDomain, WorkGroup, CurrentTimeZone, PCSystemType, HyperVisorPresent
# Populate the HTML table with process information
foreach ($process in $systeminfo) {
$systeminfoFragment += "<tr>"
$systeminfoFragment += "<td>$($process.Name)</td>"
$systeminfoFragment += "<td>$($process.Caption)</td>"
$systeminfoFragment += "<td>$($process.SystemType)</td>"
$systeminfoFragment += "<td>$($process.Manufacturer)</td>"
$systeminfoFragment += "<td>$($process.Model)</td>"
$systeminfoFragment += "<td>$($process.DNSHostName)</td>"
$systeminfoFragment += "<td>$($process.Domain)</td>"
$systeminfoFragment += "<td>$($process.PartOfDomain)</td>"
$systeminfoFragment += "<td>$($process.WorkGroup)</td>"
$systeminfoFragment += "<td>$($process.CurrentTimeZone)</td>"
$systeminfoFragment += "<td>$($process.PCSystemType)</td>"
$systeminfoFragment += "<td>$($process.HyperVisorPresent)</td>"
$systeminfoFragment += "</tr>"
}
#OS Info
#$OSinfo = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -Property Name, Description, Version, BuildNumber, InstallDate, SystemDrive, SystemDevice, WindowsDirectory, LastBootupTime, Locale, LocalDateTime, NumberofUsers, RegisteredUser, Organization, OSProductSuite | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$OSinfo = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -Property Name, Description, Version, BuildNumber, InstallDate, SystemDrive, SystemDevice, WindowsDirectory, LastBootupTime, Locale, LocalDateTime, NumberofUsers, RegisteredUser, Organization, OSProductSuite
# Populate the HTML table with process information
foreach ($process in $OSinfo) {
$OSinfoFragment += "<tr>"
$OSinfoFragment += "<td>$($process.Name)</td>"
$OSinfoFragment += "<td>$($process.Description)</td>"
$OSinfoFragment += "<td>$($process.Version)</td>"
$OSinfoFragment += "<td>$($process.BuildNumber)</td>"
$OSinfoFragment += "<td>$($process.InstallDate)</td>"
$OSinfoFragment += "<td>$($process.SystemDrive)</td>"
$OSinfoFragment += "<td>$($process.SystemDevice)</td>"
$OSinfoFragment += "<td>$($process.WindowsDirectory)</td>"
$OSinfoFragment += "<td>$($process.LastBootupTime)</td>"
$OSinfoFragment += "<td>$($process.Locale)</td>"
$OSinfoFragment += "<td>$($process.LocalDateTime)</td>"
$OSinfoFragment += "<td>$($process.NumberofUsers)</td>"
$OSinfoFragment += "<td>$($process.RegisteredUser)</td>"
$OSinfoFragment += "<td>$($process.Organization)</td>"
$OSinfoFragment += "<td>$($process.OSProductSuite)</td>"
$OSinfoFragment += "</tr>"
}
#Hotfixes
#$Hotfixes = Get-Hotfix | Select-Object -Property CSName, Caption, Description, HotfixID, InstalledBy, InstalledOn | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$Hotfixes = Get-Hotfix | Select-Object -Property CSName, Caption, Description, HotfixID, InstalledBy, InstalledOn
# Populate the HTML table with process information
foreach ($process in $Hotfixes) {
$HotfixesFragment += "<tr>"
$HotfixesFragment += "<td>$($process.CSName)</td>"
$HotfixesFragment += "<td>$($process.Caption)</td>"
$HotfixesFragment += "<td>$($process.Description)</td>"
$HotfixesFragment += "<td>$($process.HotfixID)</td>"
$HotfixesFragment += "<td>$($process.InstalledBy)</td>"
$HotfixesFragment += "<td>$($process.InstalledOn)</td>"
$HotfixesFragment += "</tr>"
}
#Get Windows Defender Status
#$WinDefender = Get-MpComputerStatus | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$WinDefender = Get-MpComputerStatus | Select-Object -Property AMProductVersion, AMRunningMode, AMServiceEnabled, AntispywareEnabled, AntispywareSignatureLastUpdated, AntivirusEnabled, AntivirusSignatureLastUpdated, BehaviorMonitorEnabled, DefenderSignaturesOutOfDate, DeviceControlPoliciesLastUpdated, DeviceControlState, NISSignatureLastUpdated, QuickScanEndTime, RealTimeProtectionEnabled
# Populate the HTML table with process information
foreach ($process in $WinDefender) {
$WinDefenderFragment += "<tr>"
$WinDefenderFragment += "<td>$($process.AMProductVersion)</td>"
$WinDefenderFragment += "<td>$($process.AMRunningMode)</td>"
$WinDefenderFragment += "<td>$($process.AMServiceEnabled)</td>"
$WinDefenderFragment += "<td>$($process.AntispywareEnabled)</td>"
$WinDefenderFragment += "<td>$($process.AntispywareSignatureLastUpdated)</td>"
$WinDefenderFragment += "<td>$($process.AntivirusEnabled)</td>"
$WinDefenderFragment += "<td>$($process.AntivirusSignatureLastUpdatedn)</td>"
$WinDefenderFragment += "<td>$($process.BehaviorMonitorEnabled)</td>"
$WinDefenderFragment += "<td>$($process.DefenderSignaturesOutOfDate)</td>"
$WinDefenderFragment += "<td>$($process.DeviceControlPoliciesLastUpdated)</td>"
$WinDefenderFragment += "<td>$($process.DeviceControlState)</td>"
$WinDefenderFragment += "<td>$($process.NISSignatureLastUpdated)</td>"
$WinDefenderFragment += "<td>$($process.QuickScanEndTime)</td>"
$WinDefenderFragment += "<td>$($process.RealTimeProtectionEnabled)</td>"
$WinDefenderFragment += "</tr>"
}
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region Live Running Processes & Scheduled Tasks #
##################################################
Write-Host -Fore DarkCyan "[*] Gathering Processes and Tasks"
#$Processes = Get-Process | Select-Object Handles, StartTime, PM, VM, SI, id, ProcessName, Path, Product, FileVersion | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$Processes = Get-Process | Select-Object Handles, StartTime, PM, VM, SI, id, ProcessName, Path, Product, FileVersion
# Populate the HTML table with process information
foreach ($process in $Processes) {
$ProcessesFragment += "<tr>"
$ProcessesFragment += "<td>$($process.Handles)</td>"
$ProcessesFragment += "<td>$($process.StartTime)</td>"
$ProcessesFragment += "<td>$($process.PM)</td>"
$ProcessesFragment += "<td>$($process.VM)</td>"
$ProcessesFragment += "<td>$($process.SI)</td>"
$ProcessesFragment += "<td>$($process.id)</td>"
$ProcessesFragment += "<td>$($process.ProcessName)</td>"
$ProcessesFragment += "<td>$($process.Path)</td>"
$ProcessesFragment += "<td>$($process.Product)</td>"
$ProcessesFragment += "<td>$($process.FileVersion)</td>"
$ProcessesFragment += "</tr>"
}
#Items set to run on startup
#$StartupProgs = Get-WmiObject Win32_StartupCommand | Select-Object Command, User, Caption | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$StartupProgs = Get-CimInstance Win32_StartupCommand | Select-Object Name, command, Location, User
# Populate the HTML table with process information
foreach ($process in $StartupProgs) {
$StartupProgsFragment += "<tr>"
$StartupProgsFragment += "<td>$($process.Name)</td>"
$StartupProgsFragment += "<td>$($process.command)</td>"
$StartupProgsFragment += "<td>$($process.Location)</td>"
$StartupProgsFragment += "<td>$($process.User)</td>"
$StartupProgsFragment += "</tr>"
}
# Scheduled Tasks
#$ScheduledTask = Get-ScheduledTask | Where-Object State -eq running | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$ScheduledTask = Get-ScheduledTask | Select-Object TaskPath, TaskName, State
# Populate the HTML table with process information
foreach ($process in $ScheduledTask) {
$ScheduledTaskFragment += "<tr>"
$ScheduledTaskFragment += "<td>$($process.TaskPath)</td>"
$ScheduledTaskFragment += "<td>$($process.TaskName)</td>"
$ScheduledTaskFragment += "<td>$($process.State)</td>"
$ScheduledTaskFragment += "</tr>"
}
# Get Running Tasks and Their state
#$ScheduledTask2 = Get-ScheduledTask | Where-Object State -eq running | Get-ScheduledTaskInfo | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$ScheduledTask2 = Get-ScheduledTask | Get-ScheduledTaskInfo | Select-Object -Property LastRunTime, LastTaskResult, NextRunTime, NumberOfMissedRuns, TaskName, TaskPath, PSComputerName
# Populate the HTML table with process information
foreach ($process in $ScheduledTask2) {
$ScheduledTask2Fragment += "<tr>"
$ScheduledTask2Fragment += "<td>$($process.LastRunTime)</td>"
$ScheduledTask2Fragment += "<td>$($process.LastTaskResult)</td>"
$ScheduledTask2Fragment += "<td>$($process.NextRunTime)</td>"
$ScheduledTask2Fragment += "<td>$($process.NumberOfMissedRuns)</td>"
$ScheduledTask2Fragment += "<td>$($process.TaskName)</td>"
$ScheduledTask2Fragment += "<td>$($process.TaskPath)</td>"
$ScheduledTask2Fragment += "<td>$($process.PSComputerName)</td>"
$ScheduledTask2Fragment += "</tr>"
}
#Services
#$Services = Get-Service | Select-Object Name, DisplayName, Status, StartType | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$Services = Get-Service | Select-Object -Property DisplayName, ServiceName, Status, StartType, @{Name = 'StartName'; Expression = { $_.StartName } }, @{Name = 'Description'; Expression = { (Get-WmiObject -Class Win32_Service -Filter "Name='$($_.Name)'").Description } }
foreach ($process in $Services) {
$ServicesFragment += "<tr>"
$ServicesFragment += "<td>$($process.ServiceName)</td>"
$ServicesFragment += "<td>$($process.DisplayName)</td>"
$ServicesFragment += "<td>$($process.Status)</td>"
$ServicesFragment += "<td>$($process.StartType)</td>"
$ServicesFragment += "<td>$($process.Description)</td>"
$ServicesFragment += "</tr>"
}
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region Settings from the Registry #
##################################################
Write-Host -Fore DarkCyan "[*] Checking Registry for persistance"
$RegRun = Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Run | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$RegRunOnce = Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$RegRunOnceEx = Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnceEx | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
Write-Host -Fore Cyan "[!] Done"
#endregion
##################################################
#region Checking other worthwhiles #
##################################################
Write-Host -Fore DarkCyan "[*] Running Peripheral Checks..."
#Logical drives (current session)
#$LogicalDrives = get-wmiobject win32_logicaldisk | Select-Object DeviceID, DriveType, FreeSpace, Size, VolumeName | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$LogicalDrives = get-wmiobject win32_logicaldisk | Select-Object DeviceID, DriveType, FreeSpace, Size, VolumeName
# Populate the HTML table with process information
foreach ($process in $LogicalDrives) {
$LogicalDrivesFragment += "<tr>"
$LogicalDrivesFragment += "<td>$($process.DeviceID)</td>"
$LogicalDrivesFragment += "<td>$($process.DriveType)</td>"
$LogicalDrivesFragment += "<td>$($process.FreeSpace)</td>"
$LogicalDrivesFragment += "<td>$($process.Size)</td>"
$LogicalDrivesFragment += "<td>$($process.VolumeName)</td>"
$LogicalDrivesFragment += "</tr>"
}
#Gets list of USB devices
#$USBDevices = Get-ItemProperty -Path HKLM:\System\CurrentControlSet\Enum\USB*\*\* | Select-Object FriendlyName, Driver, mfg, DeviceDesc | ConvertTo-Html -As LIST -fragment | Select-Object -Skip 1 | Select-Object -SkipLast 1
$USBDevices = Get-ItemProperty -Path HKLM:\System\CurrentControlSet\Enum\USB*\*\* | Select-Object FriendlyName, Driver, mfg, DeviceDesc
# Populate the HTML table with process information
foreach ($process in $USBDevices) {
$USBDevicesFragment += "<tr>"
$USBDevicesFragment += "<td>$($process.FriendlyName)</td>"
$USBDevicesFragment += "<td>$($process.Driver)</td>"
$USBDevicesFragment += "<td>$($process.mfg)</td>"
$USBDevicesFragment += "<td>$($process.DeviceDesc)</td>"
$USBDevicesFragment += "</tr>"
}