-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotebadpp.ps1
More file actions
1808 lines (1586 loc) · 75.2 KB
/
notebadpp.ps1
File metadata and controls
1808 lines (1586 loc) · 75.2 KB
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
#Requires -RunAsAdministrator
<#
.SYNOPSIS
NoteBad++ - IOC Scanner for the Notepad++ supply chain attack (June-December 2025)
.DESCRIPTION
This script checks for indicators of compromise (IoCs) associated with the
Chrysalis backdoor deployed by Lotus Blossom APT via compromised Notepad++
update infrastructure.
Checks include:
- Known malicious file hashes (SHA-1 from Kaspersky, SHA-256 from Rapid7)
- Critical file paths (ProShow\load, Adobe\Scripts\alien.ini, Bluetooth\log.dll)
- Registry/service/scheduled task persistence
- DNS cache and hosts file for C2 domains
- Network connections to C2 infrastructure
- Event logs within the attack window
This script is READ-ONLY and does NOT modify your system.
.PARAMETER ExportResults
Export scan results to a text file (legacy format).
.PARAMETER ExportJson
Export structured evidence as JSON for further analysis.
.PARAMETER OutputPath
Custom path for the exported results file.
.PARAMETER DeepHashScan
Extends hash scanning beyond AppData to Downloads, Temp, ProgramData.
.PARAMETER NoColor
Disables colored output. Useful for piping or logging.
.PARAMETER AttackStart
Start of attack window for log filtering. Default: 2025-06-01
.PARAMETER AttackEnd
End of attack window for log filtering. Default: 2025-12-02
.EXAMPLE
.\notebadpp.ps1
Run a standard scan with colored output.
.EXAMPLE
.\notebadpp.ps1 -DeepHashScan -ExportJson
Run extended scan and export structured JSON evidence.
.EXAMPLE
.\notebadpp.ps1 -AttackStart "2025-09-01" -AttackEnd "2025-11-15"
Scan with custom attack window for log filtering.
.NOTES
IoC Sources:
- Kaspersky GReAT analysis (February 3, 2026)
- Rapid7 Labs "The Chrysalis Backdoor" report (February 2026)
Attack window: June 1, 2025 - December 2, 2025 (attacker access cutoff)
.LINK
https://github.com/maremmano/notebadpp
#>
[CmdletBinding()]
param(
[switch]$ExportResults,
[switch]$ExportJson,
[string]$OutputPath = "$env:USERPROFILE\Desktop\NoteBadPP_Report_$(Get-Date -Format 'yyyyMMdd_HHmmss')",
[switch]$DeepHashScan,
[switch]$NoColor,
[datetime]$AttackStart = '2025-06-01',
[datetime]$AttackEnd = '2025-12-02'
)
# ============================================================================
# SCRIPT STATE & EVIDENCE COLLECTION
# ============================================================================
# Separate IOC findings (real compromise indicators) from Risk findings (config issues)
$script:IOCFindings = @() # Hash matches, malicious files, C2 connections, etc.
$script:RiskFindings = @() # Old version, GUP present, logging disabled, etc.
$script:Evidence = @() # Structured evidence objects for JSON export
$script:Results = @() # Legacy text output
$scanStartTime = Get-Date
function Add-Evidence {
param(
[string]$Category,
[string]$Severity,
[string]$Description,
[string]$Path = "",
[string]$Hash = "",
[datetime]$Timestamp = (Get-Date),
[hashtable]$Extra = @{}
)
$evidence = [PSCustomObject]@{
Category = $Category
Severity = $Severity
Description = $Description
Path = $Path
Hash = $Hash
Timestamp = $Timestamp
ScanTime = Get-Date
Extra = $Extra
}
$script:Evidence += $evidence
return $evidence
}
function Write-IOC {
param([string]$Message, [string]$Severity = "HIGH")
$script:IOCFindings += $Message
$output = "[IOC] [$Severity] $Message"
if ($NoColor) {
Write-Output $output
} else {
Write-Host $output -ForegroundColor Red
}
$script:Results += $output
}
function Write-Risk {
param([string]$Message, [string]$Severity = "MEDIUM")
$script:RiskFindings += $Message
$output = "[RISK] [$Severity] $Message"
if ($NoColor) {
Write-Output $output
} else {
Write-Host $output -ForegroundColor Yellow
}
$script:Results += $output
}
function Write-Clean {
param([string]$Message)
$output = "[OK] $Message"
if ($NoColor) {
Write-Output $output
} else {
Write-Host $output -ForegroundColor Green
}
$script:Results += $output
}
function Write-Info {
param([string]$Message)
$output = "[*] $Message"
if ($NoColor) {
Write-Output $output
} else {
Write-Host $output -ForegroundColor Cyan
}
$script:Results += $output
}
function Write-Section {
param([string]$Title)
$separator = "=" * 70
if ($NoColor) {
Write-Output "`n$separator"
Write-Output " $Title"
Write-Output "$separator"
} else {
Write-Host "`n$separator" -ForegroundColor Yellow
Write-Host " $Title" -ForegroundColor Yellow
Write-Host "$separator" -ForegroundColor Yellow
}
$script:Results += "`n$separator`n $Title`n$separator"
}
# Known malicious SHA1 hashes from the report
$MaliciousHashes = @(
# Malicious updater.exe hashes
"8e6e505438c21f3d281e1cc257abdbf7223b7f5a",
"90e677d7ff5844407b9c073e3b7e896e078e11cd",
"573549869e84544e3ef253bdba79851dcde4963a",
"13179c8f19fbf3d8473c49983a199e6cb4f318f0",
"4c9aac447bf732acc97992290aa7a187b967ee2c",
"821c0cafb2aab0f063ef7e313f64313fc81d46cd",
# Malicious auxiliary files
"06a6a5a39193075734a32e0235bde0e979c27228",
"9c3ba38890ed984a25abb6a094b5dbf052f22fa7",
"ca4b6fe0c69472cd3d63b212eb805b7f65710d33",
"0d0f315fd8cf408a483f8e2dd1e69422629ed9fd",
"2a476cfb85fbf012fdbe63a37642c11afa5cf020",
# Chain #1 files
"defb05d5a91e4920c9e22de2d81c5dc9b95a9a7c",
"259cd3542dea998c57f67ffdd4543ab836e3d2a3",
"46654a7ad6bc809b623c51938954de48e27a5618",
"9df6ecc47b192260826c247bf8d40384aa6e6fd6",
# Chain #2 files
"6444dab57d93ce987c22da66b3706d5d7fc226da",
"2ab0758dda4e71aee6f4c8e4c0265a796518f07d",
"bf996a709835c0c16cce1015e6d44fc95e08a38a",
# Chain #3 and Rapid7 identified files
"d7ffd7b588880cf61b603346a3557e7cce648c93",
"94dffa9de5b665dc51bc36e2693b8a3a0a4cc6b8",
"21a942273c14e4b9d3faa58e4de1fd4d5014a1ed",
"7e0790226ea461bcc9ecd4be3c315ace41e1c122",
"f7910d943a013eede24ac89d6388c1b98f8b3717",
"73d9d0139eaf89b7df34ceeb60e5f8c7cd2463bf",
"bd4915b3597942d88f319740a9b803cc51585c4a",
"c68d09dd50e357fd3de17a70b7724f8949441d77",
"813ace987a61af909c053607635489ee984534f4",
"9fbf2195dee991b1e5a727fd51391dcc2d7a4b16",
"07d2a01e1dc94d59d5ca3bdf0c7848553ae91a51",
"3090ecf034337857f786084fb14e63354e271c5d",
"d0662eadbe5ba92acbd3485d8187112543bcfbf5",
"9c0eff4deeb626730ad6a05c85eb138df48372ce"
)
# Malicious domains (including variants)
$MaliciousDomains = @(
"cdncheck.it.com",
"cdncheck.it",
"self-dns.it.com",
"self-dns.it",
"safe-dns.it.com",
"safe-dns.it",
"api.wiresguard.com",
"wiresguard.com",
"api.skycloudcenter.com",
"skycloudcenter.com",
"temp.sh"
)
# Malicious IPs (Kaspersky + Rapid7)
$MaliciousIPs = @(
"45.76.155.202",
"45.77.31.210",
"45.32.144.255",
"95.179.213.0",
"59.110.7.32",
"124.222.137.114",
"61.4.102.97" # From Rapid7 report
)
# SHA-256 file indicators from Rapid7 Chrysalis report
# Source: https://www.rapid7.com/blog/post/tr-chrysalis-backdoor-dive-into-lotus-blossoms-toolkit/
$Rapid7FileIndicators = @(
@{ Name = "update.exe"; Hash = "a511be5164dc1122fb5a7daa3eef9467e43d8458425b15a640235796006590c9"; Desc = "Malicious NSIS installer delivered via hijacked Notepad++ update" },
@{ Name = "[NSIS.nsi]"; Hash = "8ea8b83645fba6e23d48075a0d3fc73ad2ba515b4536710cda4f1f232718f53e"; Desc = "Installation script extracted from NSIS installer" },
@{ Name = "BluetoothService.exe"; Hash = "2da00de67720f5f13b17e9d985fe70f10f153da60c9ab1086fe58f069a156924"; Desc = "Renamed Bitdefender Submission Wizard used for DLL sideloading" },
@{ Name = "BluetoothService"; Hash = "77bfea78def679aa1117f569a35e8fd1542df21f7e00e27f192c907e61d63a2e"; Desc = "Encrypted shellcode blob decrypted by log.dll (Chrysalis payload)" },
@{ Name = "log.dll"; Hash = "3bdc4c0637591533f1d4198a72a33426c01f69bd2e15ceee547866f65e26b7ad"; Desc = "Malicious DLL sideloaded by BluetoothService.exe - decrypts Chrysalis" },
@{ Name = "u.bat"; Hash = "9276594e73cda1c69b7d265b3f08dc8fa84bf2d6599086b9acc0bb3745146600"; Desc = "Batch script used for cleanup or persistence" },
@{ Name = "conf.c"; Hash = "f4d829739f2d6ba7e3ede83dad428a0ced1a703ec582fc73a4eee3df3704629a"; Desc = "Source with embedded Metasploit block_api shellcode, compiled via TCC" },
@{ Name = "libtcc.dll"; Hash = "4a52570eeaf9d27722377865df312e295a7a23c3b6eb991944c2ecd707cc9906"; Desc = "Tiny C Compiler library used to compile conf.c at runtime" },
@{ Name = "admin"; Hash = "831e1ea13a1bd405f5bda2b9d8f2265f7b1db6c668dd2165ccc8a9c4c15ea7dd"; Desc = "Cobalt Strike beacon payload downloaded from api.wiresguard.com" },
@{ Name = "loader1"; Hash = "0a9b8df968df41920b6ff07785cbfebe8bda29e6b512c94a3b2a83d10014d2fd"; Desc = "Intermediate loader in shellcode execution chain" },
@{ Name = "uffhxpSy"; Hash = "4c2ea8193f4a5db63b897a2d3ce127cc5d89687f380b97a1d91e0c8db542e4f8"; Desc = "Intermediate loader in shellcode execution chain" },
@{ Name = "loader2"; Hash = "e7cd605568c38bd6e0aba31045e1633205d0598c607a855e2e1bca4cca1c6eda"; Desc = "Second-stage loader" },
@{ Name = "3yzr31vk"; Hash = "078a9e5c6c787e5532a7e728720cbafee9021bfec4a30e3c2be110748d7c43c5"; Desc = "Second-stage loader" },
@{ Name = "ConsoleApplication2.exe"; Hash = "b4169a831292e245ebdffedd5820584d73b129411546e7d3eccf4663d5fc5be3"; Desc = "Warbird loader - abuses Microsoft Warbird framework" },
@{ Name = "system"; Hash = "7add554a98d3a99b319f2127688356c1283ed073a084805f14e33b4f6a6126fd"; Desc = "Additional payload in attack toolchain" },
@{ Name = "s047t5g.exe"; Hash = "fcc2765305bcd213b7558025b2039df2265c3e0b6401e4833123c461df2de51a"; Desc = "Additional executable in attack toolchain" }
)
$Rapid7Hashes = $Rapid7FileIndicators | ForEach-Object { $_.Hash.ToLower() }
# ============================================================================
# HASHSETS FOR O(1) LOOKUPS
# ============================================================================
$SHA1HashSet = [System.Collections.Generic.HashSet[string]]::new(
[string[]]($MaliciousHashes | ForEach-Object { $_.ToLower() })
)
$SHA256HashSet = [System.Collections.Generic.HashSet[string]]::new(
[string[]]($Rapid7Hashes)
)
$MaliciousIPSet = [System.Collections.Generic.HashSet[string]]::new([string[]]$MaliciousIPs)
# ============================================================================
# CRITICAL IOC PATHS (Kaspersky's strongest indicators)
# These are HIGH confidence IoCs - if present, likely compromised
# ============================================================================
$CriticalIOCPaths = @(
"$env:APPDATA\ProShow\load",
"$env:APPDATA\Adobe\Scripts\alien.ini",
"$env:APPDATA\Adobe\Scripts\alien.dll",
"$env:APPDATA\Bluetooth\BluetoothService.exe",
"$env:APPDATA\Bluetooth\BluetoothService",
"$env:APPDATA\Bluetooth\log.dll"
)
# Directories that MAY exist legitimately (downgrade to INFO unless files match)
$SuspiciousDirectories = @(
"$env:APPDATA\ProShow",
"$env:APPDATA\Adobe\Scripts",
"$env:APPDATA\Bluetooth"
)
# All suspicious file paths (for broader scanning)
$SuspiciousFiles = @(
# ProShow chain
"$env:APPDATA\ProShow\load",
"$env:APPDATA\ProShow\ProShow.exe",
"$env:APPDATA\ProShow\defscr",
"$env:APPDATA\ProShow\if.dnt",
"$env:APPDATA\ProShow\proshow.crs",
"$env:APPDATA\ProShow\proshow.phd",
"$env:APPDATA\ProShow\proshow_e.bmp",
# Adobe\Scripts chain
"$env:APPDATA\Adobe\Scripts\alien.dll",
"$env:APPDATA\Adobe\Scripts\alien.ini",
"$env:APPDATA\Adobe\Scripts\lua5.1.dll",
"$env:APPDATA\Adobe\Scripts\script.exe",
"$env:APPDATA\Adobe\Scripts\a.txt",
# Bluetooth chain (Chrysalis)
"$env:APPDATA\Bluetooth\BluetoothService.exe",
"$env:APPDATA\Bluetooth\BluetoothService",
"$env:APPDATA\Bluetooth\log.dll",
"$env:APPDATA\Bluetooth\u.bat",
"$env:APPDATA\Bluetooth\conf.c",
"$env:APPDATA\Bluetooth\libtcc.dll"
)
# Specific IOC filenames to search for (used in targeted hash scanning)
$IOCFilenames = @(
'update.exe', 'AutoUpdater.exe', 'install.exe',
'BluetoothService.exe', 'BluetoothService', 'log.dll',
'ConsoleApplication2.exe', 's047t5g.exe', 'libtcc.dll',
'alien.dll', 'alien.ini', 'load', 'ProShow.exe'
)
# ============================================================================
# START CHECKS
# ============================================================================
Write-Host @"
ooooo ooo . oooooooooo. .o. oooooooooo.
`888b. `8' .o8 `888' `Y8b .888. `888' `Y8b
8 `88b. 8 .ooooo. .o888oo .ooooo. 888 888 .8"888. 888 888 88 88
8 `88b. 8 d88' `88b 888 d88' `88b 888oooo888' .8' `888. 888 888 88 88
8 `88b.8 888 888 888 888ooo888 888 `88b .88ooo8888. 888 888 8888888888 8888888888
8 `888 888 888 888 . 888 .o 888 .88P .8' `888. 888 d88' 88 88
o8o `8 `Y8bod8P' "888" `Y8bod8P' o888bood8P' o88o o8888o o888bood8P' 88 88
Notepad++ Supply Chain Attack IOC Scanner
Based on Kaspersky GReAT + Rapid7 Labs Research (Feb 2026)
"@ -ForegroundColor Magenta
Write-Info "Starting scan at $(Get-Date)"
Write-Info "Running as: $env:USERNAME on $env:COMPUTERNAME"
# ============================================================================
# QUICK TRIAGE: Am I likely affected?
# ============================================================================
Write-Section "QUICK TRIAGE: Risk Assessment"
Write-Info "Checking if Notepad++ is installed and gathering basic info..."
$nppInstalled = $false
$nppVersion = $null
$gupFound = $false
$nppLocations = @(
"$env:PROGRAMFILES\Notepad++",
"${env:PROGRAMFILES(x86)}\Notepad++",
"$env:LOCALAPPDATA\Programs\Notepad++"
)
foreach ($loc in $nppLocations) {
$nppExe = Join-Path $loc "notepad++.exe"
if (Test-Path $nppExe) {
$nppInstalled = $true
$nppVersion = (Get-Item $nppExe).VersionInfo.FileVersion
$nppModified = (Get-Item $nppExe).LastWriteTime
Write-Info "Notepad++ found: $loc"
Write-Info " Version: $nppVersion"
Write-Info " Last Modified: $nppModified"
$gupPath = Join-Path $loc "updater\GUP.exe"
if (Test-Path $gupPath) {
$gupFound = $true
$gupModified = (Get-Item $gupPath).LastWriteTime
Write-Info " GUP.exe (updater) present, modified: $gupModified"
}
break
}
}
if (-not $nppInstalled) {
Write-Clean "Notepad++ not found in standard locations - lower risk"
} else {
Write-Host ""
Write-Info "RISK ASSESSMENT FOR THIS ATTACK:"
Write-Host ""
Write-Info " HIGHER RISK if:"
Write-Info " - Used auto-update (GUP.exe) between June-December 2025"
Write-Info " - In targeted profile: govt/financial org in VN, PH, SV, AU"
Write-Info " - Saw N++ spawning cmd.exe, curl.exe, or AutoUpdater.exe"
Write-Host ""
Write-Info " LOWER RISK if:"
Write-Info " - Manual downloads from official notepad-plus-plus.org only"
Write-Info " - Updated after December 2025"
Write-Info " - Not in targeted sectors/regions"
Write-Info " - Using portable version (no updater)"
Write-Host ""
if ($gupFound) {
Write-Risk "GUP.exe (auto-updater) is present - full scan recommended" "LOW"
Write-Info " The attack exploited the auto-update mechanism"
} else {
Write-Clean "GUP.exe not found - lower risk (manual updates only)"
}
# Check version for immediate risk assessment
if ($nppVersion) {
# Sanitize version string (sometimes contains text like "8.6.2 (64-bit)")
$cleanVer = $nppVersion -replace '[^0-9\.]',''
try {
$vCurrent = [version]$cleanVer
$vSafe = [version]"8.8.9"
if ($vCurrent -lt $vSafe) {
Write-Risk "Version $nppVersion is BELOW 8.8.9 - UPDATE RECOMMENDED" "MEDIUM"
} else {
Write-Clean "Version $nppVersion is patched (8.8.9+)"
}
} catch {
Write-Info " Could not parse version automatically. Please verify manually."
}
}
}
# ============================================================================
# CHECK 0: CRITICAL IOC PATHS (Highest confidence indicators)
# ============================================================================
Write-Section "CHECK 0: Critical IOC Paths (Highest Confidence)"
Write-Info "Checking for Kaspersky's strongest file-based indicators..."
$criticalFound = $false
foreach ($critPath in $CriticalIOCPaths) {
if (Test-Path $critPath) {
$fileInfo = Get-Item $critPath -Force
Write-IOC "CRITICAL IOC FILE EXISTS: $critPath" "HIGH"
Write-Info " Size: $($fileInfo.Length) bytes"
Write-Info " Created: $($fileInfo.CreationTime)"
Write-Info " Modified: $($fileInfo.LastWriteTime)"
Add-Evidence -Category "CriticalIOC" -Severity "HIGH" `
-Description "Critical IOC file found" -Path $critPath `
-Timestamp $fileInfo.LastWriteTime
# Try to hash it
try {
$sha256 = (Get-FileHash $critPath -Algorithm SHA256 -ErrorAction Stop).Hash.ToLower()
Write-Info " SHA256: $sha256"
if ($SHA256HashSet.Contains($sha256)) {
Write-IOC "SHA256 MATCHES KNOWN MALICIOUS HASH" "HIGH"
}
} catch {}
$criticalFound = $true
}
}
if (-not $criticalFound) {
Write-Clean "No critical IOC files found (good sign)"
}
# ============================================================================
# CHECK 1: Suspicious Directories (INFO only - directories can exist legitimately)
# ============================================================================
Write-Section "CHECK 1: Suspicious Directories"
Write-Info "Note: These directories CAN exist legitimately. Only escalate if malicious files found."
foreach ($dir in $SuspiciousDirectories) {
if (Test-Path $dir) {
Write-Info "Directory exists: $dir"
$items = Get-ChildItem -Path $dir -Force -ErrorAction SilentlyContinue
if ($items) {
Write-Info " Contents ($($items.Count) items):"
foreach ($item in $items) {
$itemInfo = " - $($item.Name)"
if (-not $item.PSIsContainer) {
$itemInfo += " ($($item.Length) bytes)"
}
Write-Info $itemInfo
}
}
} else {
Write-Clean "Directory not found: $dir"
}
}
# ============================================================================
# CHECK 2: Suspicious Files (IOCs if specific malicious files found)
# ============================================================================
Write-Section "CHECK 2: Suspicious Files"
$suspiciousFileFound = $false
foreach ($file in $SuspiciousFiles) {
if (Test-Path $file) {
$fileInfo = Get-Item $file -Force
# Check if this is a critical IOC (already reported in CHECK 0)
$isCritical = $CriticalIOCPaths -contains $file
if (-not $isCritical) {
Write-IOC "Suspicious file EXISTS: $file" "MEDIUM"
Write-Info " Size: $($fileInfo.Length) bytes"
Write-Info " Created: $($fileInfo.CreationTime)"
Write-Info " Modified: $($fileInfo.LastWriteTime)"
Add-Evidence -Category "SuspiciousFile" -Severity "MEDIUM" `
-Description "Suspicious file found" -Path $file `
-Timestamp $fileInfo.LastWriteTime
}
$suspiciousFileFound = $true
}
}
if (-not $suspiciousFileFound) {
Write-Clean "No suspicious files found in expected IOC paths"
}
# Check for NSIS temp directories within attack window
$nsisTempDirs = Get-ChildItem -Path "$env:LOCALAPPDATA\Temp" -Directory -Filter "ns*.tmp" -ErrorAction SilentlyContinue
if ($nsisTempDirs) {
$attackWindowNsis = $nsisTempDirs | Where-Object {
$_.CreationTime -ge $AttackStart -and $_.CreationTime -le $AttackEnd
}
if ($attackWindowNsis) {
Write-IOC "NSIS temp directories from ATTACK WINDOW found:" "MEDIUM"
foreach ($nsisDir in $attackWindowNsis) {
Write-Info " - $($nsisDir.FullName) (Created: $($nsisDir.CreationTime))"
}
} else {
Write-Info "NSIS temp directories exist but outside attack window (likely benign)"
}
} else {
Write-Clean "No NSIS temp directories found"
}
# ============================================================================
# CHECK 3: Targeted Hash Verification (SHA-1 + SHA-256)
# ============================================================================
Write-Section "CHECK 3: Targeted Hash Verification"
Write-Info "Scanning specific IOC locations and filenames only (not entire Temp folder)..."
$filesToHash = @()
# 1. All files in suspicious directories
foreach ($dir in $SuspiciousDirectories) {
if (Test-Path $dir) {
$filesToHash += Get-ChildItem -Path $dir -File -Force -Recurse -ErrorAction SilentlyContinue
}
}
# 2. Specific IOC filenames in key locations (avoid recursive search on huge dirs)
$searchLocations = @(
"$env:APPDATA\Notepad++",
"$env:LOCALAPPDATA\Notepad++",
"$env:PROGRAMFILES\Notepad++",
"${env:PROGRAMFILES(x86)}\Notepad++",
"$env:USERPROFILE\Downloads"
)
foreach ($loc in $searchLocations) {
if (Test-Path $loc) {
foreach ($iocName in $IOCFilenames) {
$found = Get-ChildItem -Path $loc -Filter $iocName -File -Force -Recurse -ErrorAction SilentlyContinue
if ($found) { $filesToHash += $found }
}
}
}
# 3. USOShared - only check if files exist AND are in attack window AND unsigned
$usoPath = "C:\ProgramData\USOShared"
if (Test-Path $usoPath) {
$usoExes = Get-ChildItem -Path $usoPath -Filter "*.exe" -File -Force -ErrorAction SilentlyContinue
foreach ($exe in $usoExes) {
# Only flag if in attack window
if ($exe.CreationTime -ge $AttackStart -and $exe.CreationTime -le $AttackEnd) {
$sig = Get-AuthenticodeSignature -FilePath $exe.FullName -ErrorAction SilentlyContinue
if ($sig.Status -ne 'Valid') {
$filesToHash += $exe
Write-Info "USOShared exe in attack window (unsigned): $($exe.Name)"
}
}
}
}
# Deduplicate files
$filesToHash = $filesToHash | Sort-Object FullName -Unique
$sha1Matches = 0
$sha256Matches = 0
if ($filesToHash.Count -gt 0) {
Write-Info "Checking $($filesToHash.Count) targeted files against known hashes..."
foreach ($file in $filesToHash) {
try {
# Check SHA-1
$sha1 = (Get-FileHash -Path $file.FullName -Algorithm SHA1 -ErrorAction Stop).Hash.ToLower()
if ($SHA1HashSet.Contains($sha1)) {
Write-IOC "SHA-1 HASH MATCH: $($file.FullName)" "HIGH"
Write-Info " SHA-1: $sha1"
Add-Evidence -Category "HashMatch" -Severity "HIGH" `
-Description "SHA-1 matches known malicious hash" -Path $file.FullName -Hash $sha1
$sha1Matches++
}
# Check SHA-256
$sha256 = (Get-FileHash -Path $file.FullName -Algorithm SHA256 -ErrorAction Stop).Hash.ToLower()
if ($SHA256HashSet.Contains($sha256)) {
$matchInfo = $Rapid7FileIndicators | Where-Object { $_.Hash.ToLower() -eq $sha256 }
Write-IOC "SHA-256 HASH MATCH: $($file.FullName)" "HIGH"
Write-Info " SHA-256: $sha256"
Write-Info " Known As: $($matchInfo.Name) - $($matchInfo.Desc)"
Add-Evidence -Category "HashMatch" -Severity "HIGH" `
-Description "SHA-256 matches Rapid7 Chrysalis IOC: $($matchInfo.Name)" `
-Path $file.FullName -Hash $sha256
$sha256Matches++
}
} catch {
# Skip files we can't hash
}
}
if ($sha1Matches -eq 0 -and $sha256Matches -eq 0) {
Write-Clean "No known malicious hashes found ($($filesToHash.Count) files checked)"
} else {
Write-Info "Hash matches: $sha1Matches SHA-1, $sha256Matches SHA-256"
}
} else {
Write-Clean "No targeted files to hash (suspicious directories don't exist)"
}
# Deep scan option for broader coverage
if ($DeepHashScan) {
Write-Section "CHECK 3b: Extended Hash Scan (Deep Mode)"
Write-Info "Deep scan: checking additional locations..."
$deepPaths = @($env:TEMP, "$env:USERPROFILE\Downloads", "$env:ProgramData")
$deepFilesScanned = 0
$deepMatches = 0
foreach ($deepPath in $deepPaths) {
if (-not (Test-Path $deepPath)) { continue }
# Only scan IOC filenames, not all exes
foreach ($iocName in $IOCFilenames) {
$found = Get-ChildItem -Path $deepPath -Filter $iocName -File -Force -Recurse -ErrorAction SilentlyContinue
foreach ($file in $found) {
$deepFilesScanned++
try {
$sha256 = (Get-FileHash $file.FullName -Algorithm SHA256 -ErrorAction Stop).Hash.ToLower()
if ($SHA256HashSet.Contains($sha256)) {
$matchInfo = $Rapid7FileIndicators | Where-Object { $_.Hash.ToLower() -eq $sha256 }
Write-IOC "DEEP SCAN SHA-256 MATCH: $($file.FullName)" "HIGH"
Write-Info " Known As: $($matchInfo.Name)"
$deepMatches++
}
} catch {}
}
}
}
if ($deepMatches -eq 0) {
Write-Clean "Deep scan: no additional matches ($deepFilesScanned files checked)"
}
}
# ============================================================================
# CHECK 4: Registry Autorun Entries
# ============================================================================
Write-Section "CHECK 4: Registry Autorun Entries"
$autorunPaths = @(
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Run",
"HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce",
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Run",
"HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce"
)
$autorunFound = $false
foreach ($regPath in $autorunPaths) {
if (Test-Path $regPath) {
$entries = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue
$entries.PSObject.Properties | Where-Object { $_.Name -notmatch '^PS' } | ForEach-Object {
# Cast to string to handle non-string registry values
$value = [string]$_.Value
if ([string]::IsNullOrEmpty($value)) { return }
# Check for specific IOC patterns using -match (regex)
if ($value -match '(?i)\\appdata\\roaming\\(ProShow|Adobe\\Scripts|Bluetooth)\\') {
Write-IOC "Autorun points to IOC directory: $($_.Name)" "HIGH"
Write-Info " Path: $regPath"
Write-Info " Value: $value"
Add-Evidence -Category "Persistence" -Severity "HIGH" `
-Description "Registry autorun points to IOC directory" -Path $regPath `
-Extra @{ Name = $_.Name; Value = $value }
$autorunFound = $true
}
# Check for temp folder executables (suspicious pattern)
elseif ($value -match '(?i)\\temp\\.*(update|autoupdater|install)\.exe') {
Write-IOC "Autorun points to suspicious temp executable" "MEDIUM"
Write-Info " Path: $regPath"
Write-Info " Name: $($_.Name)"
Write-Info " Value: $value"
$autorunFound = $true
}
}
}
}
if (-not $autorunFound) {
Write-Clean "No suspicious autorun entries found"
}
# ============================================================================
# CHECK 4b: Malicious Services
# ============================================================================
Write-Section "CHECK 4b: Malicious Services"
Write-Info "Checking for suspicious Windows services..."
$suspiciousServiceFound = $false
try {
$services = Get-CimInstance -ClassName Win32_Service -ErrorAction SilentlyContinue
foreach ($svc in $services) {
$pathName = [string]$svc.PathName
$svcName = $svc.Name
if ([string]::IsNullOrEmpty($pathName)) { continue }
# BluetoothService running from AppData is a strong IOC
# (Legitimate Windows Bluetooth services run as svchost, not standalone exe)
if ($pathName -match '(?i)\\appdata\\.*bluetooth') {
Write-IOC "BluetoothService running from AppData (Chrysalis IOC)" "HIGH"
Write-Info " Service: $svcName"
Write-Info " Path: $pathName"
Write-Info " State: $($svc.State)"
Add-Evidence -Category "Persistence" -Severity "HIGH" `
-Description "Malicious BluetoothService" -Path $pathName
$suspiciousServiceFound = $true
}
# Check for other suspicious paths
elseif ($pathName -match '(?i)\\appdata\\roaming\\(ProShow|Adobe\\Scripts)\\') {
Write-IOC "Service running from IOC directory" "HIGH"
Write-Info " Service: $svcName"
Write-Info " Path: $pathName"
$suspiciousServiceFound = $true
}
# Any service in Temp folder is suspicious
elseif ($pathName -match '(?i)\\temp\\' -and $pathName -notmatch 'Windows\\Temp') {
Write-IOC "Service running from user Temp folder" "MEDIUM"
Write-Info " Service: $svcName"
Write-Info " Path: $pathName"
$suspiciousServiceFound = $true
}
}
if (-not $suspiciousServiceFound) {
Write-Clean "No suspicious services found"
}
} catch {
Write-Info "Could not enumerate services"
}
# ============================================================================
# CHECK 4c: Scheduled Tasks
# ============================================================================
Write-Section "CHECK 4c: Scheduled Tasks"
Write-Info "Checking for suspicious scheduled tasks..."
$suspiciousTaskFound = $false
try {
$tasks = Get-ScheduledTask -ErrorAction SilentlyContinue | Where-Object { $_.State -ne 'Disabled' }
foreach ($task in $tasks) {
foreach ($action in $task.Actions) {
$execPath = [string]$action.Execute
if ([string]::IsNullOrEmpty($execPath)) { continue }
if ($execPath -match '(?i)\\appdata\\roaming\\(ProShow|Adobe\\Scripts|Bluetooth)\\') {
Write-IOC "Scheduled task runs from IOC directory: $($task.TaskName)" "HIGH"
Write-Info " Path: $($task.TaskPath)"
Write-Info " Action: $execPath"
Write-Info " Arguments: $($action.Arguments)"
Add-Evidence -Category "Persistence" -Severity "HIGH" `
-Description "Scheduled task persistence" -Path $execPath
$suspiciousTaskFound = $true
}
elseif ($execPath -match '(?i)\\temp\\' -and $execPath -notmatch 'Windows\\Temp') {
Write-IOC "Scheduled task runs from user Temp" "MEDIUM"
Write-Info " Task: $($task.TaskName)"
Write-Info " Action: $execPath"
$suspiciousTaskFound = $true
}
}
}
if (-not $suspiciousTaskFound) {
Write-Clean "No suspicious scheduled tasks found"
}
} catch {
Write-Info "Could not enumerate scheduled tasks"
}
# ============================================================================
# CHECK 5: DNS Cache
# ============================================================================
Write-Section "CHECK 5: DNS Cache Analysis"
try {
$dnsCache = Get-DnsClientCache -ErrorAction SilentlyContinue
$maliciousDnsFound = $false
foreach ($entry in $dnsCache) {
foreach ($domain in $MaliciousDomains) {
if ($entry.Name -like "*$domain*") {
Write-IOC "MALICIOUS DOMAIN IN DNS CACHE: $($entry.Name)"
Write-Info " Data: $($entry.Data)"
Write-Info " TTL: $($entry.TimeToLive)"
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Malicious domain in DNS cache" -Extra @{ Domain = $entry.Name; Data = $entry.Data }
$maliciousDnsFound = $true
}
}
}
if (-not $maliciousDnsFound) {
Write-Clean "No malicious domains found in DNS cache"
}
} catch {
Write-Info "Could not retrieve DNS cache (may require elevated privileges)"
}
# ============================================================================
# CHECK 5b: Hosts File Analysis
# ============================================================================
Write-Section "CHECK 5b: Hosts File for C2 Domains"
$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
$C2Regex = ($MaliciousDomains | ForEach-Object { [regex]::Escape($_) }) -join '|'
if (Test-Path $hostsPath) {
$hostsHit = Select-String -Path $hostsPath -Pattern $C2Regex -ErrorAction SilentlyContinue
if ($hostsHit) {
foreach ($hit in $hostsHit) {
Write-IOC "MALICIOUS DOMAIN IN HOSTS FILE: $($hit.Line)"
Write-Info " Line number: $($hit.LineNumber)"
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Malicious domain in hosts file" -Path $hostsPath -Extra @{ Line = $hit.Line; LineNumber = $hit.LineNumber }
}
} else {
Write-Clean "No C2 domains found in hosts file"
}
} else {
Write-Info "Hosts file not found at expected location"
}
# ============================================================================
# CHECK 6: Active Network Connections
# ============================================================================
Write-Section "CHECK 6: Active Network Connections (TCP)"
try {
$connections = Get-NetTCPConnection -ErrorAction SilentlyContinue |
Where-Object { $_.State -eq 'Established' -or $_.State -eq 'SynSent' }
$maliciousConnFound = $false
foreach ($conn in $connections) {
$remoteIP = $conn.RemoteAddress
if ($MaliciousIPs -contains $remoteIP) {
Write-IOC "ACTIVE CONNECTION TO MALICIOUS IP: $remoteIP"
Write-Info " Local Port: $($conn.LocalPort)"
Write-Info " Remote Port: $($conn.RemotePort)"
Write-Info " State: $($conn.State)"
$procName = "Unknown"
try {
$process = Get-Process -Id $conn.OwningProcess -ErrorAction SilentlyContinue
$procName = $process.Name
Write-Info " Process: $procName (PID: $($conn.OwningProcess))"
} catch {}
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Active connection to malicious IP" -Extra @{
RemoteIP = $remoteIP; LocalPort = $conn.LocalPort;
RemotePort = $conn.RemotePort; Process = $procName; PID = $conn.OwningProcess
}
$maliciousConnFound = $true
}
}
if (-not $maliciousConnFound) {
Write-Clean "No active connections to known malicious IPs"
}
} catch {
Write-Info "Could not check network connections"
}
# ============================================================================
# CHECK 6b: Netstat Scan (All Protocols)
# ============================================================================
Write-Section "CHECK 6b: Netstat Scan for C2 IPs (All Protocols)"
$ipPattern = ($MaliciousIPs | ForEach-Object { [regex]::Escape($_) }) -join '|'
try {
$netstatOutput = netstat -an 2>$null | Select-String $ipPattern
if ($netstatOutput) {
foreach ($line in $netstatOutput) {
Write-IOC "MALICIOUS IP IN NETSTAT: $line"
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Malicious IP found in netstat output" -Extra @{ Entry = $line.ToString().Trim() }
}
} else {
Write-Clean "No connections to C2 IPs found in netstat"
}
} catch {
Write-Info "Could not run netstat scan"
}
# ============================================================================
# CHECK 7: DNS Client Event Logs
# ============================================================================
Write-Section "CHECK 7: DNS Client Event Logs"
try {
# Check if DNS Client logging is enabled and query logs
$dnsEvents = Get-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" -MaxEvents 1000 -ErrorAction SilentlyContinue
if ($dnsEvents) {
$maliciousDnsLogs = $false
foreach ($event in $dnsEvents) {
$message = $event.Message
foreach ($domain in $MaliciousDomains) {
if ($message -like "*$domain*") {
Write-IOC "MALICIOUS DOMAIN IN DNS LOGS: $domain"
Write-Info " Time: $($event.TimeCreated)"
Write-Info " Event ID: $($event.Id)"
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Malicious domain in DNS event logs" -Timestamp $event.TimeCreated `
-Extra @{ Domain = $domain; EventID = $event.Id }
$maliciousDnsLogs = $true
}
}
}
if (-not $maliciousDnsLogs) {
Write-Clean "No malicious domains found in DNS event logs"
}
} else {
Write-Info "DNS Client operational log is empty or not enabled"
Write-Info " To enable: wevtutil sl Microsoft-Windows-DNS-Client/Operational /e:true"
}
} catch {
Write-Info "Could not access DNS Client event logs (may not be enabled)"
}
# ============================================================================
# CHECK 8: Windows Firewall Logs (if available)
# ============================================================================
Write-Section "CHECK 8: Firewall Log Analysis"
$firewallLogPath = "$env:SystemRoot\System32\LogFiles\Firewall\pfirewall.log"
if (Test-Path $firewallLogPath) {
Write-Info "Checking Windows Firewall log for malicious IPs..."
try {
$logContent = Get-Content $firewallLogPath -Tail 5000 -ErrorAction SilentlyContinue
$maliciousFirewallHits = $false
foreach ($line in $logContent) {
foreach ($ip in $MaliciousIPs) {
$escapedIP = [regex]::Escape($ip)
if ($line -match $escapedIP) {
Write-IOC "MALICIOUS IP IN FIREWALL LOG: $ip"
Write-Info " Log entry: $line"
Add-Evidence -Category "Network" -Severity "HIGH" `
-Description "Malicious IP in firewall log" -Path $firewallLogPath `
-Extra @{ IP = $ip; LogEntry = $line.Trim() }
$maliciousFirewallHits = $true
}
}
}
if (-not $maliciousFirewallHits) {
Write-Clean "No malicious IPs found in firewall logs"
}
} catch {
Write-Info "Could not read firewall log"
}
} else {
Write-Info "Windows Firewall logging not enabled or log not found"
Write-Info " Path checked: $firewallLogPath"
}
# ============================================================================
# CHECK 9: Sysmon DNS Query Logs (if Sysmon is installed)