-1
我有一個關於下面的腳本的腳本檢查多個郵件服務器對RBL列表的問題,問題是,一些列表(如hostkarma.junkemailfilter.com)有一定的答案,並不意味着IP實際上被列入黑名單。添加一個例外到try catch
所以我想一個異常加入到try..catch
功能,如果hostkarma.junkemailfilter.com用127.0.2.1答案郵件服務器沒有進入$blacklistedOn
。
腳本:
Param([string]$IP)
$statusAlive = "ScriptRes:Host is alive:"
$statusDead = "ScriptRes:No answer:"
$statusUnknown = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"
$reversedIP = ($IP -split '\.')[3..0] -join '.'
$blacklistServers = @(
"dnsbl-3.uceprotect.net";
"dnsbl-2.uceprotect.net";
"dnsbl-1.uceprotect.net";
"ix.dnsbl.manitu.net";
"bl.spamcop.net";
"bl.spamcannibal.org";
"b.barracudacentral.org";
"ips.backscatterer.org";
"dnsbl.sorbs.net";
"cbl.abuseat.org";
"all.spamrats.com";
"black.uribl.com";
"multi.surbl.org";
"multi.uribl.com";
"truncate.gbudb.net";
"bl.blocklist.de";
"dnsbl.inps.de";
"bl.mailspike.net";
"bl.spameatingmonkey.net";
"db.wpbl.info";
"dnsbl.justspam.org";
"hostkarma.junkemailfilter.com";
"mail-abuse.blacklist.jippg.org";
"psbl.surriel.com";
"spam.dnsbl.anonmails.de";
"ubl.unsubscore.com";
"cblless.anti-spam.org.cn";
"cblplus.anti-spam.org.cn";
"spam.pedantic.org";
"dev.null.dk";
"blackholes.five-ten-sg.com";
"spamsources.fabel.dk";
"zen.spamhaus.org";
"spamguard.leadmon.net";
"dialups.visi.com";
"dnsbl.kempt.net";
"dnsbl.dronebl.org";
"no-more-funn.moensted.dk";
"relays.bl.kundenserver.de";
)
$blacklistedOn = @()
foreach ($server in $blacklistServers) {
$IPServer = "$reversedIP.$server"
try {
$null = [System.Net.Dns]::GetHostEntry($IPServer)
$blacklistedOn += $server
} catch { }
}
if ($blacklistedOn.Count -gt 0) {
# The IP was blacklisted on one or more servers; send your email here.
# $blacklistedOn is an array of the servers that returned positive results.
Write-Host "$statusAlive"$blacklistedOn
} else {
Write-Host "$statusDead"$blacklistedOn
}
什麼樣的JavaScript的是什麼? – CoderPi
這看起來像某種.NET語言 – birdoftheday
那是我的壞,它的Poweshell腳本,只是有一些JavaScript的麻煩,所以我仍然在我的腦海裏有JavaScritp。 –