Last active
August 26, 2025 15:17
-
-
Save supermarsx/4c6cf0c48af3558e8ac2d47c3729499c to your computer and use it in GitHub Desktop.
Exchange filter, Block Suspicious TLDs
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
| # ========================================================= | |
| # π¨ Block Suspicious TLDs β Transport Rule Manager π¨ | |
| # ========================================================= | |
| $blacklist = @( | |
| "@*\.accountant$","@*\.accountants$","@*\.adult$","@*\.am$","@*\.asia$","@*\.autos$", | |
| "@*\.bar$","@*\.bd$","@*\.best$","@*\.bet$","@*\.bid$","@*\.bio$","@*\.blue$","@*\.buzz$", | |
| "@*\.cam$","@*\.casa$","@*\.casino$","@*\.cc$","@*\.cd$","@*\.cf$","@*\.cfd$","@*\.charity$", | |
| "@*\.click$","@*\.club$","@*\.cm$","@*\.cn$","@*\.com.na$","@*\.country$","@*\.cricket$", | |
| "@*\.cyou$","@*\.dad$","@*\.date$","@*\.degree$","@*\.download$","@*\.earth$","@*\.email$", | |
| "@*\.faith$","@*\.fit$","@*\.fund$","@*\.futbol$","@*\.fyi$","@*\.ga$","@*\.gdn$","@*\.ge$", | |
| "@*\.gives$","@*\.gold$","@*\.gq$","@*\.guru$","@*\.haus$","@*\.help$","@*\.homes$", | |
| "@*\.host$","@*\.icu$","@*\.id$","@*\.il$","@*\.in$","@*\.info$","@*\.ink$","@*\.jetzt$", | |
| "@*\.ke$","@*\.kim$","@*\.lat$","@*\.lease$","@*\.life$","@*\.link$","@*\.live$","@*\.lk$", | |
| "@*\.loan$","@*\.lol$","@*\.ltd$","@*\.makeup$","@*\.me$","@*\.men$","@*\.ml$","@*\.mom$", | |
| "@*\.monster$","@*\.mov$","@*\.ng$","@*\.ninja$","@*\.online$","@*\.party$","@*\.pics$", | |
| "@*\.pk$","@*\.plus$","@*\.poker$","@*\.porn$","@*\.pro$","@*\.pub$","@*\.pw$","@*\.py$", | |
| "@*\.quest$","@*\.racing$","@*\.realtor$","@*\.ren$","@*\.rest$","@*\.review$","@*\.rip$", | |
| "@*\.rocks$","@*\.rodeo$","@*\.ru$","@*\.run$","@*\.sa$","@*\.sbs$","@*\.science$","@*\.sex$", | |
| "@*\.sexy$","@*\.shop$","@*\.site$","@*\.skin$","@*\.space$","@*\.stream$","@*\.su$", | |
| "@*\.support$","@*\.th$","@*\.tk$","@*\.tn$","@*\.today$","@*\.tokyo$","@*\.top$","@*\.trade$", | |
| "@*\.tube$","@*\.uno$","@*\.vip$","@*\.wang$","@*\.webcam$","@*\.wiki$","@*\.win$","@*\.work$", | |
| "@*\.world$","@*\.ws$","@*\.wtf$","@*\.xin$","@*\.xn--2scrj9c$","@*\.xn--5tzm5g$", | |
| "@*\.xn--6frz82g$","@*\.xn--czrs0t$","@*\.xn--fjq720a$","@*\.xn--s9brj9c$","@*\.xn--unup4y$", | |
| "@*\.xn--vhquv$","@*\.xn--xhq521b$","@*\.xxx$","@*\.xyz$","@*\.za.com$","@*\.zip$", | |
| "@*\.zone$","@*\.zw$" | |
| ) | |
| $ruleName = "Block Suspicious TLDs" | |
| Write-Host "`n===============================" -ForegroundColor DarkCyan | |
| Write-Host " Transport Rule Blacklist Log" -ForegroundColor Cyan | |
| Write-Host "===============================`n" -ForegroundColor DarkCyan | |
| Write-Host ("{0,-20} {1}" -f "Rule Name:", $ruleName) -ForegroundColor White | |
| Write-Host ("{0,-20} {1}" -f "Blacklist Count:", $blacklist.Count) -ForegroundColor White | |
| Write-Host "" | |
| $existingRule = Get-TransportRule -Identity $ruleName -ErrorAction SilentlyContinue | |
| if ($existingRule) { | |
| Write-Host ("{0,-20} {1}" -f "Status:", "Updating existing rule") -ForegroundColor Yellow | |
| Set-TransportRule -Identity $ruleName -FromAddressMatchesPatterns $blacklist -DeleteMessage $true | |
| Write-Host ("{0,-20} {1}" -f "Result:", "β Rule updated successfully") -ForegroundColor Green | |
| } else { | |
| Write-Host ("{0,-20} {1}" -f "Status:", "Creating new rule") -ForegroundColor Magenta | |
| New-TransportRule -Name $ruleName -FromAddressMatchesPatterns $blacklist -DeleteMessage $true | |
| Write-Host ("{0,-20} {1}" -f "Result:", "β Rule created successfully") -ForegroundColor Green | |
| } | |
| Write-Host "`nDetailed Summary:" -ForegroundColor Cyan | |
| $summary = [PSCustomObject]@{ | |
| "Rule Name" = $ruleName | |
| "TLDs Blocked" = $blacklist.Count | |
| "Action" = "DeleteMessage" | |
| "Timestamp" = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") | |
| } | |
| $summary | Format-Table -AutoSize | Out-String | Write-Host -ForegroundColor White | |
| Write-Host "`nπ― Operation complete: Suspicious TLD blacklist applied.`n" -ForegroundColor Cyan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment