-
Notifications
You must be signed in to change notification settings - Fork 58
/
Updater.ps1
1952 lines (1657 loc) · 67.1 KB
/
Updater.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
# MemProcFS-Analyzer Updater v0.3
#
# @author: Martin Willing
# @copyright: Copyright (c) 2024 Martin Willing. All rights reserved. Licensed under the MIT license.
# @contact: Any feedback or suggestions are always welcome and much appreciated - [email protected]
# @url: https://lethal-forensics.com/
# @date: 2024-10-29
#
#
# ██╗ ███████╗████████╗██╗ ██╗ █████╗ ██╗ ███████╗ ██████╗ ██████╗ ███████╗███╗ ██╗███████╗██╗ ██████╗███████╗
# ██║ ██╔════╝╚══██╔══╝██║ ██║██╔══██╗██║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝████╗ ██║██╔════╝██║██╔════╝██╔════╝
# ██║ █████╗ ██║ ███████║███████║██║█████╗█████╗ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║███████╗██║██║ ███████╗
# ██║ ██╔══╝ ██║ ██╔══██║██╔══██║██║╚════╝██╔══╝ ██║ ██║██╔══██╗██╔══╝ ██║╚██╗██║╚════██║██║██║ ╚════██║
# ███████╗███████╗ ██║ ██║ ██║██║ ██║███████╗ ██║ ╚██████╔╝██║ ██║███████╗██║ ╚████║███████║██║╚██████╗███████║
# ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝╚══════╝
#
#
# Changelog:
# Version 0.1
# Release Date: 2024-09-02
# Initial Release
#
# Version 0.2
# Release Date: 2024-09-15
# Added: Sync for RECmd Batch Files
# Added: Check if the download of the packaged Zircolite binary was successful. Note: Some AV may not like the packaged binaries.
#
# Version 0.3
# Release Date: 2024-10-29
# Added: ClamAV Update
#
#
# Tested on Windows 10 Pro (x64) Version 22H2 (10.0.19045.5011) and PowerShell 5.1 (5.1.19041.5007)
# Tested on Windows 10 Pro (x64) Version 22H2 (10.0.19045.5011) and PowerShell 7.4.6
#
#
#############################################################################################################################################################################################
#############################################################################################################################################################################################
<#
.SYNOPSIS
MemProcFS-Analyzer Updater v0.3 - Automated Installer/Updater for MemProcFS-Analyzer
.DESCRIPTION
Updater.ps1 is a PowerShell script utilized to automate the installation and the update process of MemProcFS-Analyzer (incl. all dependencies).
https://github.com/evild3ad/MemProcFS-Analyzer
.EXAMPLE
PS> .\Updater.ps1
.NOTES
Author - Martin Willing
.LINK
https://lethal-forensics.com/
#>
#############################################################################################################################################################################################
#############################################################################################################################################################################################
#region Initialisations
# Set Progress Preference to Silently Continue
$OriginalProgressPreference = $Global:ProgressPreference
$Global:ProgressPreference = 'SilentlyContinue'
#endregion Initialisations
#############################################################################################################################################################################################
#############################################################################################################################################################################################
#region Declarations
# Declarations
# Script Root
if ($PSVersionTable.PSVersion.Major -gt 2)
{
# PowerShell 3+
$script:SCRIPT_DIR = $PSScriptRoot
}
else
{
# PowerShell 2
$script:SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition
}
# Tools
# 7-Zip
$script:7za = "$SCRIPT_DIR\Tools\7-Zip\7za.exe"
# AmcacheParser
$script:AmcacheParser = "$SCRIPT_DIR\Tools\AmcacheParser\AmcacheParser.exe"
# AppCompatCacheParser
$script:AppCompatCacheParser = "$SCRIPT_DIR\Tools\AppCompatCacheParser\AppCompatCacheParser.exe"
# ClamAV
$script:freshclam = "C:\Program Files\ClamAV\freshclam.exe"
$script:clamscan = "C:\Program Files\ClamAV\clamscan.exe"
$script:clamd = "C:\Program Files\ClamAV\clamd.exe"
$script:clamdscan = "C:\Program Files\ClamAV\clamdscan.exe"
# Elasticsearch
$script:Elasticsearch = "$SCRIPT_DIR\Tools\Elasticsearch\bin\elasticsearch.bat"
# entropy
$script:entropy = "$SCRIPT_DIR\Tools\entropy\entropy.exe"
# EvtxECmd
$script:EvtxECmd = "$SCRIPT_DIR\Tools\EvtxECmd\EvtxECmd.exe"
# IPinfo CLI
$script:IPinfo = "$SCRIPT_DIR\Tools\IPinfo\ipinfo.exe"
# jq
$script:jq = "$SCRIPT_DIR\Tools\jq\jq-win64.exe"
# Kibana
$script:Kibana = "$SCRIPT_DIR\Tools\Kibana\bin\kibana.bat"
# lnk_parser
$script:lnk_parser = "$SCRIPT_DIR\Tools\lnk_parser\lnk_parser_x86_64.exe"
# MemProcFS
$script:MemProcFS = "$SCRIPT_DIR\Tools\MemProcFS\MemProcFS.exe"
# RECmd
$script:RECmd = "$SCRIPT_DIR\Tools\RECmd\RECmd.exe"
# SBECmd
$script:SBECmd = "$SCRIPT_DIR\Tools\SBECmd\SBECmd.exe"
# xsv
$script:xsv = "$SCRIPT_DIR\Tools\xsv\xsv.exe"
# YARA
$script:yara64 = "$SCRIPT_DIR\Tools\YARA\yara64.exe"
# Zircolite
$script:zircolite = "$SCRIPT_DIR\Tools\Zircolite\zircolite.exe"
#endregion Declarations
#############################################################################################################################################################################################
#############################################################################################################################################################################################
#region Header
# Windows Title
$DefaultWindowsTitle = $Host.UI.RawUI.WindowTitle
$Host.UI.RawUI.WindowTitle = "MemProcFS-Analyzer Updater v0.3 - Automated Installer/Updater for MemProcFS-Analyzer"
# Check if the PowerShell script is being run with admin rights
if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Host "[Error] This PowerShell script must be run with admin rights." -ForegroundColor Red
Exit
}
# Create a record of your PowerShell session to a text file
Start-Transcript -Path "$SCRIPT_DIR\Logs\Updater.txt"
# Get Start Time
$startTime = (Get-Date)
# Logo
$Logo = @"
██╗ ███████╗████████╗██╗ ██╗ █████╗ ██╗ ███████╗ ██████╗ ██████╗ ███████╗███╗ ██╗███████╗██╗ ██████╗███████╗
██║ ██╔════╝╚══██╔══╝██║ ██║██╔══██╗██║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝████╗ ██║██╔════╝██║██╔════╝██╔════╝
██║ █████╗ ██║ ███████║███████║██║█████╗█████╗ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║███████╗██║██║ ███████╗
██║ ██╔══╝ ██║ ██╔══██║██╔══██║██║╚════╝██╔══╝ ██║ ██║██╔══██╗██╔══╝ ██║╚██╗██║╚════██║██║██║ ╚════██║
███████╗███████╗ ██║ ██║ ██║██║ ██║███████╗ ██║ ╚██████╔╝██║ ██║███████╗██║ ╚████║███████║██║╚██████╗███████║
╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝╚══════╝
"@
Write-Output ""
Write-Output "$Logo"
Write-Output ""
# Header
Write-Output "MemProcFS-Analyzer Updater v0.3 - Automated Installer/Updater for MemProcFS-Analyzer"
Write-Output "(c) 2024 Martin Willing at Lethal-Forensics (https://lethal-forensics.com/)"
Write-Output ""
# Update date (ISO 8601)
$script:UpdateDate = [datetime]::Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss")
Write-Output "Update date: $UpdateDate UTC"
Write-Output ""
#endregion Header
#############################################################################################################################################################################################
#############################################################################################################################################################################################
#region Updater
Function Updater {
Function InternetConnectivityCheck {
# Internet Connectivity Check (Vista+)
$NetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]‘{DCB00C01-570F-4A9B-8D69-199FDBA5723B}’)).IsConnectedToInternet
# Offline
if (!($NetworkListManager -eq "True"))
{
Write-Host "[Error] Your computer is NOT connected to the Internet." -ForegroundColor Red
$Host.UI.RawUI.WindowTitle = "$DefaultWindowsTitle"
Exit
}
# Online
if ($NetworkListManager -eq "True")
{
# Check if GitHub is reachable
if (!(Test-NetConnection -ComputerName github.com -Port 443).TcpTestSucceeded)
{
Write-Host "[Error] github.com is NOT reachable. Please check your network connection and try again." -ForegroundColor Red
$Host.UI.RawUI.WindowTitle = "$DefaultWindowsTitle"
Exit
}
# Check if mikestammer.com is reachable
if (!(Test-NetConnection -ComputerName mikestammer.com -Port 443).TcpTestSucceeded)
{
Write-Host "[Error] mikestammer.com is NOT reachable. Please check your network connection and try again." -ForegroundColor Red
$Host.UI.RawUI.WindowTitle = "$DefaultWindowsTitle"
Exit
}
}
}
#############################################################################################################################################################################################
Function Get-MemProcFS {
# Check Current Version of MemProcFS
if (Test-Path "$($MemProcFS)")
{
$CurrentVersion = & $MemProcFS -version | ForEach-Object{($_ -split "MemProcFS v")[1]}
Write-Output "[Info] Current Version: MemProcFS v$CurrentVersion"
Start-Sleep 1
}
else
{
Write-Output "[Info] MemProcFS NOT found."
$CurrentVersion = ""
}
# Determining latest release on GitHub
$Repository = "ufrisk/MemProcFS"
$Releases = "https://api.github.com/repos/$Repository/releases"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = (Invoke-WebRequest -Uri $Releases -UseBasicParsing | ConvertFrom-Json)[0]
$Published = $Response.published_at
$Download = ($Response.assets | Select-Object -ExpandProperty browser_download_url | Select-String -Pattern "win_x64" | Out-String).Trim()
if ($Published -is [String])
{
$ReleaseDate = $Published.split('T')[0] # Windows PowerShell
}
else
{
$ReleaseDate = $Published # PowerShell 7
}
$Version = $Download | ForEach-Object{($_ -split "_")[4]} | ForEach-Object{($_ -split "-")[0]} | ForEach-Object{($_ -replace "v","")}
if ($CurrentVersion)
{
Write-Output "[Info] Latest Release: MemProcFS v$Version ($ReleaseDate)"
}
else
{
Write-Output "[Info] Latest Release: MemProcFS v$Version ($ReleaseDate)"
}
# Check if MemProcFS needs to be downloaded/updated
if ($CurrentVersion -ne $Version -Or $null -eq $CurrentVersion)
{
# Download latest release from GitHub
Write-Output "[Info] Dowloading Latest Release ..."
$Zip = "MemProcFS.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $Download -OutFile "$SCRIPT_DIR\$Zip"
if (Test-Path "$SCRIPT_DIR\$Zip")
{
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\$Zip" -DestinationPath "$SCRIPT_DIR\Tools\MemProcFS" -Force
# Remove Downloaded Archive
Start-Sleep 5
Remove-Item "$SCRIPT_DIR\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of MemProcFS." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-YaraCustomRules {
# Check Current Version of YARA Custom Rules
if (Test-Path "$SCRIPT_DIR\yara\*")
{
if (Test-Path "$SCRIPT_DIR\yara\README.md")
{
$Content = Get-Content "$SCRIPT_DIR\yara\README.md" | Select-String -Pattern "Last updated:"
$Pattern = "[0-9]{4}-[0-9]{2}-[0-9]{2}"
$CurrentVersion = [regex]::Matches($Content, $Pattern).Value
Write-Output "[Info] Current Version of YARA Custom Rules: $CurrentVersion"
}
else
{
Write-Output "[Info] README.md NOT found."
}
}
else
{
Write-Output "[Info] YARA Custom Rules NOT found."
$CurrentVersion = ""
}
# Determining latest update on GitHub
$WebRequest = Invoke-WebRequest -Uri "https://raw.githubusercontent.com/evild3ad/yara/main/README.md"
$Content = $WebRequest.Content.Split([Environment]::NewLine) | Select-String -Pattern "Last updated:"
$Pattern = "[0-9]{4}-[0-9]{2}-[0-9]{2}"
$LatestUpdate = [regex]::Matches($Content, $Pattern).Value
Write-Output "[Info] Latest Update: $LatestUpdate"
# Check if YARA Custom Rules need to be downloaded/updated
if ($CurrentVersion -lt $LatestUpdate -Or $null -eq $CurrentVersion)
{
# Download latest YARA Custom Rules from GitHub
Write-Output "[Info] Downloading YARA Custom Rules ..."
Invoke-WebRequest "https://github.com/evild3ad/yara/archive/refs/heads/main.zip" -OutFile "$SCRIPT_DIR\yara.zip"
if (Test-Path "$SCRIPT_DIR\yara.zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\yara")
{
Get-ChildItem -Path "$SCRIPT_DIR\yara" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\yara" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\yara.zip" -DestinationPath "$SCRIPT_DIR" -Force
# Rename Unpacked Directory
Start-Sleep 10
Rename-Item "$SCRIPT_DIR\yara-main" "$SCRIPT_DIR\yara" -Force
# Remove Downloaded Archive
Start-Sleep 5
Remove-Item "$SCRIPT_DIR\yara.zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent YARA Custom Rules." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-Dokany {
# Check Current Version of Dokany File System Library
$Dokany = "$env:SystemDrive\Windows\System32\dokan2.dll"
if (Test-Path "$($Dokany)")
{
$CurrentVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($Dokany).FileVersion
$LastWriteTime = ((Get-Item $Dokany).LastWriteTime).ToString("yyyy-MM-dd")
Write-Output "[Info] Current Version: Dokany File System Library v$CurrentVersion ($LastWriteTime)"
}
else
{
Write-Output "[Info] Dokany File System Library NOT found."
$CurrentVersion = ""
}
# Determining latest release of DokanSetup.exe on GitHub
# Note: Needs possibly a restart of the computer.
$Repository = "dokan-dev/dokany"
$Releases = "https://api.github.com/repos/$Repository/releases"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = (Invoke-WebRequest -Uri $Releases -UseBasicParsing | ConvertFrom-Json)[0]
$Tag = $Response.tag_name
$Published = $Response.published_at
if ($Published -is [String])
{
$ReleaseDate = $Published.split('T')[0] # Windows PowerShell
}
else
{
$ReleaseDate = $Published # PowerShell 7
}
if ($CurrentVersion)
{
Write-Output "[Info] Latest Release: Dokany File System Library $Tag ($ReleaseDate)"
}
else
{
Write-Output "[Info] Latest Release: Dokany File System Library $Tag ($ReleaseDate)"
}
# Check if Dokany File System Library needs to be downloaded/updated
$LatestRelease = $Tag.Substring(1)
if ($CurrentVersion -ne $LatestRelease -Or $null -eq $CurrentVersion)
{
Write-Host "[Error] Please download/install the latest release of Dokany File System Library manually:" -ForegroundColor Red
Write-Host " https://github.com/dokan-dev/dokany/releases/latest (DokanSetup.exe)" -ForegroundColor Red
}
else
{
Write-Host "[Info] You are running the most recent version of Dokany File System Library." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function ClamAVUpdate {
# ClamAVUpdate
# freshclam.conf
if (!(Test-Path "C:\Program Files\ClamAV\freshclam.conf"))
{
Write-Host "[Error] freshclam.conf is missing." -ForegroundColor Red
Write-Host " https://docs.clamav.net/manual/Usage/Configuration.html#windows --> First Time Set-Up" -ForegroundColor Red
}
# clamd.conf
if (!(Test-Path "C:\Program Files\ClamAV\clamd.conf"))
{
Write-Host "[Error] clamd.conf is missing." -ForegroundColor Red
Write-Host " https://docs.clamav.net/manual/Usage/Configuration.html#windows --> First Time Set-Up" -ForegroundColor Red
}
# Update
if (Test-Path "$($freshclam)")
{
# Internet Connectivity Check (Vista+)
$NetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]‘{DCB00C01-570F-4A9B-8D69-199FDBA5723B}’)).IsConnectedToInternet
if (!($NetworkListManager -eq "True"))
{
Write-Host "[Error] Your computer is NOT connected to the Internet. ClamAV cannot check for any updates." -ForegroundColor Red
}
else
{
# Check if clamav.net is reachable
if (!(Test-Connection -ComputerName clamav.net -Count 1 -Quiet))
{
Write-Host "[Error] clamav.net is NOT reachable. ClamAV cannot check for any updates." -ForegroundColor Red
}
else
{
Write-Output "[Info] Checking for ClamAV Updates ..."
New-Item "$SCRIPT_DIR\Tools\ClamAV" -ItemType Directory -Force | Out-Null
& $freshclam > "$SCRIPT_DIR\Tools\ClamAV\Update.txt" 2> "$SCRIPT_DIR\Tools\ClamAV\Warning.txt"
# Update ClamAV Engine
if (Select-String -Pattern "WARNING: Your ClamAV installation is OUTDATED!" -Path "$SCRIPT_DIR\Tools\ClamAV\Warning.txt" -Quiet)
{
Write-Host "[Info] WARNING: Your ClamAV installation is OUTDATED!" -ForegroundColor Red
if (Select-String -Pattern "Recommended version:" -Path "$SCRIPT_DIR\Tools\ClamAV\Warning.txt" -Quiet)
{
$WARNING = Get-Content "$SCRIPT_DIR\Tools\ClamAV\Warning.txt" | Select-String -Pattern "Recommended version:"
Write-Host "[Info] $WARNING" -ForegroundColor Red
}
}
# Update Signature Databases
$Count = (Get-Content "$SCRIPT_DIR\Tools\ClamAV\Update.txt" | Select-String -Pattern "is up to date" | Measure-Object).Count
if ($Count -match "3")
{
Write-Output "[Info] All ClamAV Virus Databases (CVD) are up-to-date."
}
else
{
Write-Output "[Info] Updating ClamAV Virus Databases (CVD) ... "
}
}
}
}
else
{
Write-Host "[Error] freshclam.exe NOT found." -ForegroundColor Red
}
# Engine Version
if (Test-Path "$($clamscan)")
{
$Version = & $clamscan -V
$EngineVersion = $Version.Split('/')[0]
$Patch = $Version.Split('/')[1]
Write-Output "[Info] Engine Version: $EngineVersion (#$Patch)"
}
else
{
Write-Host "[Error] clamscan.exe NOT found." -ForegroundColor Red
}
}
#############################################################################################################################################################################################
Function Get-Elasticsearch {
# Elasticsearch
# https://github.com/elastic/elasticsearch
# Check Current Version of Elasticsearch
if (Test-Path "$($Elasticsearch)")
{
$CurrentVersion = & $Elasticsearch --version | ForEach-Object{($_ -split "\s+")[1]} | ForEach-Object{($_ -replace ",","")}
Write-Output "[Info] Current Version: Elasticsearch v$CurrentVersion"
Start-Sleep 1
}
else
{
Write-Output "[Info] Elasticsearch NOT found."
$CurrentVersion = ""
}
# Determining latest release of Elasticsearch on GitHub
$Repository = "elastic/elasticsearch"
$Releases = "https://api.github.com/repos/$Repository/releases"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = (Invoke-WebRequest -Uri $Releases -UseBasicParsing | ConvertFrom-Json)
$Versions = $Response.tag_name | Where-Object{($_ -notmatch "-rc")} | ForEach-Object{($_ -replace "v","")}
$Latest = ($Versions | ForEach-Object{[System.Version]$_ } | Sort-Object -Descending | Select-Object -First 1).ToString()
$Item = $Response | Where-Object{($_.tag_name -eq "v$Latest")}
$Tag = $Item.tag_name
$Published = $Item.published_at
if ($Published -is [String])
{
$ReleaseDate = $Published.split('T')[0] # Windows PowerShell
}
else
{
$ReleaseDate = $Published # PowerShell 7
}
if ($CurrentVersion)
{
Write-Output "[Info] Latest Release: Elasticsearch $Tag ($ReleaseDate)"
}
else
{
Write-Output "[Info] Latest Release: Elasticsearch $Tag ($ReleaseDate)"
}
# Check if Elasticsearch needs to be downloaded/updated
$LatestRelease = $Tag.Substring(1)
if ($CurrentVersion -ne $LatestRelease -Or $null -eq $CurrentVersion)
{
# Download latest release from elastic.co
Write-Output "[Info] Dowloading Latest Release ..."
$Download = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$LatestRelease-windows-x86_64.zip"
$Zip = "Elasticsearch.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $Download -OutFile "$SCRIPT_DIR\Tools\$Zip"
if (Test-Path "$SCRIPT_DIR\Tools\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\Elasticsearch")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\Elasticsearch" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\Elasticsearch" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\Tools\$Zip" -DestinationPath "$SCRIPT_DIR\Tools" -Force
# Rename Unpacked Directory
Start-Sleep 10
Rename-Item "$SCRIPT_DIR\Tools\elasticsearch-$LatestRelease" "$SCRIPT_DIR\Tools\Elasticsearch" -Force
# Remove Downloaded Archive
Start-Sleep 5
Remove-Item "$SCRIPT_DIR\Tools\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of Elasticsearch." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-Kibana {
# Kibana
# https://github.com/elastic/kibana
# Check Current Version of Kibana
if (Test-Path "$($Kibana)")
{
$CurrentVersion = & $Kibana --version | Select-Object -Last 1
Write-Output "[Info] Current Version: Kibana v$CurrentVersion"
Start-Sleep 1
}
else
{
Write-Output "[Info] Kibana NOT found."
$CurrentVersion = ""
}
# Determining latest release of Kibana on GitHub
$Repository = "elastic/kibana"
$Releases = "https://api.github.com/repos/$Repository/releases"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = (Invoke-WebRequest -Uri $Releases -UseBasicParsing | ConvertFrom-Json)
$Versions = $Response.tag_name | Where-Object{($_ -notmatch "-rc")} | ForEach-Object{($_ -replace "v","")}
$Latest = ($Versions | ForEach-Object{[System.Version]$_ } | Sort-Object -Descending | Select-Object -First 1).ToString()
$Item = $Response | Where-Object{($_.tag_name -eq "v$Latest")}
$Tag = $Item.tag_name
$Published = $Item.published_at
if ($Published -is [String])
{
$ReleaseDate = $Published.split('T')[0] # Windows PowerShell
}
else
{
$ReleaseDate = $Published # PowerShell 7
}
if ($CurrentVersion)
{
Write-Output "[Info] Latest Release: Kibana $Tag ($ReleaseDate)"
}
else
{
Write-Output "[Info] Latest Release: Kibana $Tag ($ReleaseDate)"
}
# Check if Kibana needs to be downloaded/updated
$LatestRelease = $Tag.Substring(1)
if ($CurrentVersion -ne $LatestRelease -Or $null -eq $CurrentVersion)
{
# Download latest release from elastic.co
Write-Output "[Info] Dowloading Latest Release ..."
$Download = "https://artifacts.elastic.co/downloads/kibana/kibana-$LatestRelease-windows-x86_64.zip"
$Zip = "Kibana.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $Download -OutFile "$SCRIPT_DIR\Tools\$Zip"
if (Test-Path "$SCRIPT_DIR\Tools\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\Kibana")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\Kibana" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\Kibana" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
if (Test-Path "$($7za)")
{
$DestinationPath = "$SCRIPT_DIR\Tools"
& $7za x "$SCRIPT_DIR\Tools\$Zip" "-o$DestinationPath" > $null 2>&1
}
else
{
Write-Host "[Error] 7za.exe NOT found." -ForegroundColor Red
Stop-Transcript
$Host.UI.RawUI.WindowTitle = "$DefaultWindowsTitle"
Exit
}
# Rename Unpacked Directory
Start-Sleep 10
Rename-Item "$SCRIPT_DIR\Tools\kibana-$LatestRelease" "$SCRIPT_DIR\Tools\Kibana" -Force
# Remove Downloaded Archive
Start-Sleep 5
Remove-Item "$SCRIPT_DIR\Tools\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of Kibana." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-AmcacheParser {
# AmcacheParser (.NET 6)
# https://ericzimmerman.github.io
# Check Current Version and ETag of AmcacheParser
if (Test-Path "$($AmcacheParser)")
{
# Current Version
$CurrentVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($AmcacheParser).FileVersion
Write-Output "[Info] Current Version: AmcacheParser v$CurrentVersion"
# ETag
if (Test-Path "$SCRIPT_DIR\Tools\AmcacheParser\ETag.txt")
{
$CurrentETag = Get-Content "$SCRIPT_DIR\Tools\AmcacheParser\ETag.txt"
}
else
{
$CurrentETag = ""
}
# Determining latest release of AmcacheParser
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/AmcacheParser.zip"
$Headers = (Invoke-WebRequest -Uri $URL -UseBasicParsing -Method Head).Headers
$LatestETag = ($Headers["ETag"]).Replace('"','')
}
else
{
Write-Output "[Info] AmcacheParser NOT found."
$CurrentETag = ""
}
if ($null -eq $CurrentETag -or $CurrentETag -ne $LatestETag)
{
# Download latest release from mikestammer.com
Write-Output "[Info] Dowloading Latest Release ..."
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/AmcacheParser.zip"
$Zip = "AmcacheParser.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $URL -OutFile "$SCRIPT_DIR\Tools\$Zip"
if (Test-Path "$SCRIPT_DIR\Tools\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\AmcacheParser")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\AmcacheParser" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\AmcacheParser" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\Tools\$Zip" -DestinationPath "$SCRIPT_DIR\Tools\AmcacheParser" -Force
# Latest ETag of AmcacheParser.zip
$LatestETag | Out-File "$SCRIPT_DIR\Tools\AmcacheParser\ETag.txt"
# Remove Downloaded Archive
Remove-Item "$SCRIPT_DIR\Tools\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of AmcacheParser." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-AppCompatCacheParser {
# AppCompatCacheParser (.NET 6)
# https://ericzimmerman.github.io
# Check Current Version and ETag of AppCompatCacheParser
if (Test-Path "$($AppCompatCacheParser)")
{
# Current Version
$CurrentVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($AppCompatCacheParser).FileVersion
Write-Output "[Info] Current Version: AppCompatCacheParser v$CurrentVersion"
# ETag
if (Test-Path "$SCRIPT_DIR\Tools\AppCompatCacheParser\ETag.txt")
{
$CurrentETag = Get-Content "$SCRIPT_DIR\Tools\AppCompatCacheParser\ETag.txt"
}
else
{
$CurrentETag = ""
}
# Determining latest release of AppCompatCacheParser
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/AppCompatCacheParser.zip"
$Headers = (Invoke-WebRequest -Uri $URL -UseBasicParsing -Method Head).Headers
$LatestETag = ($Headers["ETag"]).Replace('"','')
}
else
{
Write-Output "[Info] AppCompatCacheParser NOT found."
$CurrentETag = ""
}
if ($null -eq $CurrentETag -or $CurrentETag -ne $LatestETag)
{
# Download latest release from Backblaze
Write-Output "[Info] Dowloading Latest Release ..."
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/AppCompatCacheParser.zip"
$Zip = "AppCompatCacheParser.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $URL -OutFile "$SCRIPT_DIR\Tools\$Zip"
if (Test-Path "$SCRIPT_DIR\Tools\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\AppCompatCacheParser")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\AppCompatCacheParser" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\AppCompatCacheParser" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\Tools\$Zip" -DestinationPath "$SCRIPT_DIR\Tools\AppCompatCacheParser" -Force
# Latest ETag of AppCompatCacheParser.zip
$LatestETag | Out-File "$SCRIPT_DIR\Tools\AppCompatCacheParser\ETag.txt"
# Remove Downloaded Archive
Remove-Item "$SCRIPT_DIR\Tools\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of AppCompatCacheParser." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-Entropy {
# entropy
# https://github.com/merces/entropy
# Check Current Version of entropy.exe
if (Test-Path "$($entropy)")
{
# Current Version
if (Test-Path "$SCRIPT_DIR\Tools\entropy\Version.txt")
{
$CurrentVersion = Get-Content "$SCRIPT_DIR\Tools\entropy\Version.txt"
$LastWriteTime = ((Get-Item $entropy).LastWriteTime).ToString("yyyy-MM-dd")
Write-Output "[Info] Current Version: entropy v$CurrentVersion ($LastWriteTime)"
}
else
{
$CurrentVersion = ""
}
}
else
{
Write-Output "[Info] entropy.exe NOT found."
$CurrentVersion = ""
}
# Determining latest release on GitHub
$Repository = "merces/entropy"
$Latest = "https://api.github.com/repos/$Repository/releases/latest"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = (Invoke-WebRequest -Uri $Latest -UseBasicParsing | ConvertFrom-Json)[0]
$Tag = $Response.tag_name
$Published = $Response.published_at
$Download = ($Response.assets | Select-Object -ExpandProperty browser_download_url | Select-String -Pattern "-win64" | Out-String).Trim()
if ($Published -is [String])
{
$ReleaseDate = $Published.split('T')[0] # Windows PowerShell
}
else
{
$ReleaseDate = $Published # PowerShell 7
}
$LatestRelease = $Tag.Substring(1)
if ($CurrentVersion)
{
Write-Output "[Info] Latest Release: entropy $Tag ($ReleaseDate)"
}
else
{
Write-Output "[Info] Latest Release: entropy $Tag ($ReleaseDate)"
}
# Check if entropy.exe needs to be downloaded/updated
if ($CurrentVersion -ne $LatestRelease -Or $null -eq $CurrentVersion)
{
Write-Output "[Info] Dowloading Latest Release ..."
$Zip = "entropy.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $Download -OutFile "$SCRIPT_DIR\$Zip"
if (Test-Path "$SCRIPT_DIR\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\entropy")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\entropy" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\entropy" -Force
}
# Unpacking Archive File
Write-Output "[Info] Extracting Files ..."
Expand-Archive -Path "$SCRIPT_DIR\$Zip" -DestinationPath "$SCRIPT_DIR\Tools" -Force
# Version
Write-Output "$LatestRelease" | Out-File "$SCRIPT_DIR\Tools\entropy\Version.txt"
# Remove Downloaded Archive
Start-Sleep 5
Remove-Item "$SCRIPT_DIR\$Zip" -Force
}
}
else
{
Write-Host "[Info] You are running the most recent version of entropy." -ForegroundColor Green
}
}
#############################################################################################################################################################################################
Function Get-EvtxECmd {
# EvtxECmd (.NET 6)
# https://ericzimmerman.github.io
# Check Current Version and ETag of EvtxECmd
if (Test-Path "$($EvtxECmd)")
{
# Current Version
$CurrentVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($EvtxECmd).FileVersion
Write-Output "[Info] Current Version: EvtxECmd v$CurrentVersion"
# ETag
if (Test-Path "$SCRIPT_DIR\Tools\EvtxECmd\ETag.txt")
{
$CurrentETag = Get-Content "$SCRIPT_DIR\Tools\EvtxECmd\ETag.txt"
}
else
{
$CurrentETag = ""
}
# Determining latest release of EvtxECmd
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/EvtxECmd.zip"
$Headers = (Invoke-WebRequest -Uri $URL -UseBasicParsing -Method Head).Headers
$LatestETag = ($Headers["ETag"]).Replace('"','')
}
else
{
Write-Output "[Info] EvtxECmd NOT found."
$CurrentETag = ""
}
if ($null -eq $CurrentETag -or $CurrentETag -ne $LatestETag)
{
# Download latest release from Backblaze
Write-Output "[Info] Dowloading Latest Release ..."
$ProgressPreference = 'SilentlyContinue'
$URL = "https://download.mikestammer.com/net6/EvtxECmd.zip"
$Zip = "EvtxECmd.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $URL -OutFile "$SCRIPT_DIR\Tools\$Zip"
if (Test-Path "$SCRIPT_DIR\Tools\$Zip")
{
# Delete Directory Content and Remove Directory
if (Test-Path "$SCRIPT_DIR\Tools\EvtxECmd")
{
Get-ChildItem -Path "$SCRIPT_DIR\Tools\EvtxECmd" -Recurse | Remove-Item -Force -Recurse
Remove-Item "$SCRIPT_DIR\Tools\EvtxECmd" -Force
}
# Unpacking Archive File