Created
November 24, 2024 20:59
-
-
Save tmap/717d8fc96bcaae3d5fd872ff85741501 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$folderPath = "C:\gg" | |
if (-Not (Test-Path -Path $folderPath)) { | |
New-Item -ItemType Directory -Path $folderPath | |
} | |
$topExtensions = @( | |
".txt", ".log", ".json", ".xml", ".csv", ".html", ".htm", ".php", ".js", ".css", | |
".py", ".java", ".c", ".cpp", ".cs", ".rb", ".swift", ".go", ".sh", ".bat", | |
".exe", ".dll", ".bin", ".iso", ".img", ".zip", ".rar", ".7z", ".tar", ".gz", | |
".png", ".jpg", ".jpeg", ".bmp", ".gif", ".tiff", ".ico", ".mp3", ".wav", ".flac", | |
".mp4", ".mkv", ".avi", ".mov", ".wmv", ".flv", ".pdf", ".doc", ".docx", ".xls", | |
".xlsx", ".ppt", ".pptx", ".odt", ".ods", ".odp", ".rtf", ".md", ".yml", ".yaml", | |
".ini", ".config", ".dat", ".db", ".sql", ".bak", ".tmp", ".old", ".sys", ".dll", | |
".log1", ".log2", ".dmp", ".out", ".pem", ".crt", ".key", ".cer", ".vbs", ".ps1", | |
".bash", ".zsh", ".csh", ".awk", ".pl", ".lua", ".kt", ".ts", ".tsx", ".jsx", | |
".scss", ".less", ".svg", ".ttf", ".woff", ".eot", ".otf", ".ai", ".psd", ".eps", | |
".apk", ".ipa", ".jar", ".war", ".ear", ".exe1", ".bat1", ".sh1", ".cgi", ".asp", | |
".aspx", ".jsp", ".cfm", ".lua1", ".cgi1", ".env", ".tf", ".tfstate", ".lock", | |
".xsd", ".xsl", ".xslt", ".psd1", ".psm1", ".dsc", ".dsc1", ".module", ".plist", | |
".yaml1", ".toml", ".env1", ".config1", ".config2", ".bson", ".json1", ".json5", | |
".avro", ".parquet", ".orc", ".rst", ".mdown", ".markdown", ".adoc", ".rst1", | |
".m", ".mm", ".qml", ".qrc", ".ui", ".odf", ".odp1", ".kdbx", ".gpg", ".pgp", | |
".asc", ".sig", ".public", ".private", ".dat1", ".bak1", ".bak2", ".tmp1", ".tmp2", | |
".session", ".log3", ".log4", ".pfx", ".p12", ".pkcs12", ".pem1", ".key1", ".crt1", | |
".csr", ".spc", ".p7b", ".p7c", ".ppk", ".ppx", ".json2", ".schema", ".json3", | |
".fasta", ".fastq", ".vcf", ".tsv", ".ini1", ".cnf", ".conf", ".config3", ".xml1", | |
".toml1", ".yaml2", ".csproj", ".sln", ".vbproj", ".resx", ".dll1", ".dll2", | |
".dll3", ".dylib", ".lib", ".so", ".a", ".o", ".obj", ".obj1", ".sym", ".idb", | |
".ipdb", ".pdb", ".hex", ".hex1", ".bin1", ".iso1", ".img1", ".vhd", ".vhdx", | |
".qcow2", ".raw", ".vdi", ".ova", ".ovf", ".vagrantfile", ".terraform", ".packer", | |
".chef", ".ansible", ".puppet", ".vcl", ".cl", ".gpu", ".cpu", ".minidump", ".core", | |
".segfault", ".trace", ".lock1", ".lock2", ".db1", ".db2", ".sqlite", ".sqlite3", | |
".sql1", ".sql2", ".db3", ".fdb", ".mdb", ".accdb", ".idb1", ".idb2", ".ibd", | |
".idb3", ".frm", ".myi", ".myd", ".index", ".index1", ".fla", ".swf", ".flv1", | |
".anim", ".animation", ".blend", ".3ds", ".obj2", ".fbx", ".step", ".iges", ".stp", | |
".stl", ".vrml", ".3mf", ".amf", ".gltf", ".glb", ".ply", ".x3d", ".x3db", ".dae", | |
".max", ".maya", ".mb", ".ma", ".usd", ".usdz", ".scene", ".unitypackage" | |
) | |
foreach ($ext in $topExtensions) { | |
$filePath = Join-Path -Path $folderPath -ChildPath ("EmptyFile" + $ext) | |
if (-Not (Test-Path -Path $filePath)) { | |
New-Item -ItemType File -Path $filePath | Out-Null | |
} | |
} | |
Write-Output "Created empty files with top 1000 extensions in $folderPath." | |
$mpCmdRunPath = "C:\Program Files\Windows Defender\MpCmdRun.exe" | |
$files = Get-ChildItem -Path $folderPath -File -ErrorAction SilentlyContinue | |
$loggedExtensions = @{} | |
foreach ($file in $files) { | |
$filePath = $file.FullName | |
$extension = $file.Extension | |
if ($loggedExtensions.ContainsKey($extension)) { | |
continue | |
} | |
try { | |
$output = & $mpCmdRunPath -Scan -ScanType 3 -File "$filePath" 2>$null | |
if ($output -match "Scanning .* was skipped") { | |
Write-Output "eXCLUDED: $extension" | |
$loggedExtensions[$extension] = $true | |
} | |
} catch { | |
# Suppress any other errors | |
continue | |
} | |
} | |
Write-Output "Cleaning up created files..." | |
Get-ChildItem -Path $folderPath -File | Remove-Item -Force | |
Write-Output "Cleanup complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment