So I’ve been running the GAYINT aggregate IP blocklist in my homelab for a little bit now but I’ve found it a little bit too restrictive. I understand why cloudflare and other CDN’s are in there, but like I still need to browse the internet and download Steam games.
Yesterday I noticed that they released a per-category ASN list. And while this is super helpful, I still needed it in a IP address format.
So introducing Frisky Kitten and Silent Spider!
It’s a powershell script that pulls from pre-defined GAYINT ASN lists (you can change the URLs in the code if you want different ones), concatenates the AS numbers into a single CSV, and then queries the RIPE database to get the advertised prefixes for each one. Those prefixes are then written to a single txt file that you can load into your security appliance of choice.
I am a very amateur programmer and was unable to get it all to work in a single script, so instead it’s two separate scripts, but launching one auto launches the second. I’m sure all of the code is some hot garbage, but it does the job I need it to do and if anyone here wants to do a similar thing, then I hope it helps you out in some way.
Special thanks to Alex Fronteddu for his ASN2IP powershell script here: ASN-2-IP | Alex Fronteddu because I pretty much copy-pasted his Get-ASNPrefixes function for querying the RIPE database, and without that this project probably wouldn’t have happened.
Demo video:
Frisky Kitten source code:
Add-Content -Path .\gayintASN.csv -Value "ASN"
$gayint_bpf = "https://gayint.org/blocklists/numbers_bulletproof.txt"
$gayint_colo = "https://gayint.org/blocklists/numbers_colo.txt"
$gayint_mhost = "https://gayint.org/blocklists/numbers_managed_hosting.txt"
$gayint_weird = "https://gayint.org/blocklists/numbers_weirdos.txt"
Write-Host @"
______ _ _ _ __ _ _ _
| ____| (_) | | | |/ /(_)| | | |
| |__ _ __ _ ___ | | __ _ _ | ' / _ | |_ | |_ ___ _ __
| __|| '__|| |/ __|| |/ /| | | | | < | || __|| __|/ _ \| '_ \
| | | | | |\__ \| < | |_| | | . \ | || |_ | |_| __/| | | |
|_| |_| |_||___/|_|\_\ \__, | |_|\_\|_| \__| \__|\___||_| |_|
__/ |
|___/
~The quieter you boop, the more you meow~
"@
sleep 1
Write-Host "Trying to pull the latest list of scumbag IPs..."
sleep 1
Write-Host "Category: Bulletproof Hosting"
sleep 1
$badasn = Invoke-WebRequest -Uri $gayint_bpf -UseBasicParsing
$rawasn = $badasn.Content -split "`n"
foreach ($raw in $rawasn) {
$trimmed = $raw.Trim()
if ($trimmed -and -not $trimmed.StartsWith("#")) {
Add-Content -Path .\gayintASN.csv -Value $trimmed -Passthru
}
}
Write-Host "Category: Colocation"
sleep 1
$badasn2 = Invoke-WebRequest -Uri $gayint_colo -UseBasicParsing
$rawasn2 = $badasn2.Content -split "`n"
foreach ($raw2 in $rawasn2) {
$trimmed = $raw2.Trim()
if ($trimmed -and -not $trimmed.StartsWith("#")) {
Add-Content -Path .\gayintASN.csv -Value $trimmed -Passthru
}
}
Write-Host "Category: Managed Hosting"
sleep 1
$badasn3 = Invoke-WebRequest -Uri $gayint_mhost -UseBasicParsing
$rawasn3 = $badasn3.Content -split "`n"
foreach ($raw3 in $rawasn3) {
$trimmed = $raw3.Trim()
if ($trimmed -and -not $trimmed.StartsWith("#")) {
Add-Content -Path .\gayintASN.csv -Value $trimmed -Passthru
}
}
Write-Host "Category: Weird"
sleep 1
$badasn4 = Invoke-WebRequest -Uri $gayint_weird -UseBasicParsing
$rawasn4 = $badasn4.Content -split "`n"
foreach ($raw4 in $rawasn4) {
$trimmed = $raw4.Trim()
if ($trimmed -and -not $trimmed.StartsWith("#")) {
Add-Content -Path .\gayintASN.csv -Value $trimmed -Passthru
}
}
Read-Host -Prompt "All Done ^_^! Press Enter to run Silent Spider or Ctrl+C to quit" | .\silentspider.ps1
Silent Spider source code:
$asns = Import-Csv .\gayintASN.csv | Select-Object -ExpandProperty ASN
$url = "https://stat.ripe.net/data/announced-prefixes/data.json?resource=$asn"
$headers = @{
"Content-Type" = "application/json"
"User-Agent" = "mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/112.0.0.0 safari/537.36 edg/112.0.1722.48"
"sec-ch-ua" = '"microsoft edge";v="112", "not:a-brand";v="99"'
"sec-ch-ua-mobile" = "?0"
"sec-ch-ua-platform" = "windows"
"upgrade-insecure-requests" = "1"
}
Write-Host @"
_____ _ _ _ _____ _ _
/ ____|(_)| | | | / ____| (_) | |
| (___ _ | | ___ _ __ | |_ | (___ _ __ _ __| | ___ _ __
\___ \ | || | / _ \| '_ \ | __| \___ \ | '_ \ | | / _` | / _ \| '__|
____) || || || __/| | | || |_ ____) || |_) || || (_| || __/| |
|_____/ |_||_| \___||_| |_| \__| |_____/ | .__/ |_| \__,_| \___||_|
| |
|_|
"Why did you call it that?"
"Because it sounds scary"
"@
sleep 2
Write-Host "ASN's acquired. Let's make some IP's"
sleep 2
Write-Host "*Runs through the RIPE offices screaming 'EAT MY ASS PALO ALTO!'*"
sleep 3
foreach($asn in $asns){
$response = Invoke-WebRequest -Uri https://stat.ripe.net/data/announced-prefixes/data.json?resource=$asn -Method Get -Headers $headers | Select-Object -ExpandProperty Content
$asnPrefixInfo = $response | ConvertFrom-Json
if ($asnPrefixInfo.status -eq "ok") {
$prefixes = $asnPrefixInfo.data.prefixes
$prefixValues = @()
foreach ($prefix in $prefixes) { $prefixValues += $prefix.prefix }
}
$ASNFormatted = "{0,-8}" -f $ASN
$prefixCountFormatted = "{0,4}" -f $prefixValues.Count
Add-Content -Path .\AddIPblocklist.txt -Value $prefixValues -Passthru
}
Write-Host "Cleaning up..."
Remove-Item -Path .\gayintASN.csv