Compare commits

..

3 Commits

20 changed files with 94813 additions and 923 deletions
-2
View File
@@ -1,2 +0,0 @@
__pycache__/
unloading/
-9
View File
@@ -1,9 +0,0 @@
MIT License
Copyright (c) 2025 alan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-136
View File
@@ -1,136 +0,0 @@
# bird_list_ip
Это скрипт написанный на Python3 для выгрузки пулов ip адресов, для bird2.
# Установка (Debian)
-- устанавливаем пакеты
> sudo apt install -y git bird2 m4
-- добавляем поддержку brotli и requests в python3
> apt -y install python3-pip\
> pip install brotli requests 2> /dev/null || pip install brotli requests --break-system-packages
-- клонируем репозиторий
> git clone https://git.alanbox.ru/alan/bird_list_ip.git /opt/bird_list_ip && chmod +x /opt/bird_list_ip/download.py
-- правим Unit Systemd bird2 для работы с m4
> nano /usr/lib/systemd/system/bird.service
> [Unit]\
> Description=BIRD Internet Routing Daemon\
> After=network.target\
>\
> [Service]\
> EnvironmentFile=/etc/bird/envvars\
> ExecStartPre=/bin/sh -c "/usr/bin/m4 /opt/bird > /etc/bird/bird.conf"\
> ExecStartPre=-/usr/lib/bird/prepare-environment\
> ExecStartPre=-/usr/sbin/bird -p\
> ExecReload=/bin/sh -c "/usr/bin/m4 /opt/bird > /etc/bird/bird.conf"\
> ExecReload=-/usr/sbin/birdc configure\
> ExecStart=/usr/sbin/bird -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP $BIRD_ARGS\
> Restart=on-abort\
>\
> [Install]\
> WantedBy=multi-user.target\
-- пример конфигурации bird2 на m4, для работы со списками
> nano /opt/bird
> log syslog {error, fatal};\
> router id ~~**1.1.1.1**~~;\
>\
> protocol device {\
> }\
>\
> protocol direct {\
>     ipv4; # Connect to default IPv4 table\
>     #ipv6; # ... and to default IPv6 table\
> }\
>\
> protocol kernel {\
>     learn;\
>     merge paths on;\
>     ipv4 { # Connect protocol to IPv4 table by channel\
>         import none; # Import to table, default is import all\
>         export filter { if (net.len > 0 && source=RTS_BGP) then { accept; } reject; }; # Export to protocol. default is export none\
>     };\
> }\
>\
> \# SUB m4\
> define(\`LOCATION', \`~~**741**~~')\
> include(\`/opt/bird_list_ip/unloading/bird2_v4.m4')\
>\
> filter border_in {\
>     if (net ~ 0.0.0.0/32) then { reject; }\
>     if (net ~ 127.0.0.0/8) then { reject; }\
>     if (net ~ 169.254.0.0/16) then { reject; }\
>     if (net ~ 224.0.0.0/4) then { reject; }\
>     if (net ~ 240.0.0.0/4) then { reject; }\
>     if (net.len > 0) then { accept; }\
>     reject;\
> }\
>\
> filter border_out {\
>     if (net ~ 0.0.0.0/32) then { reject; }\
>     if (net ~ 127.0.0.0/8) then { reject; }\
>     if (net ~ 10.0.0.0/8) then { reject; }\
>     if (net ~ 172.16.0.0/12) then { reject; }\
>     if (net ~ 192.168.0.0/16) then { reject; }\
>     if (net ~ 169.254.0.0/16) then { reject; }\
>     if (net ~ 224.0.0.0/4) then { reject; }\
>     if (net ~ 240.0.0.0/4) then { reject; }\
>     accept;\
> }\
>\
> define(\`BGP_BORDER', \`\
> protocol bgp $1 {\
>     ipv4 {\
>         import filter border_in;\
>         export filter border_out;\
>         next hop self;\
>     };\
>     router id $2;\
>     source address $2;\
>     local $2 as ~~**65431**~~;\
>     neighbor $3 as ~~**65949**~~;\
>     hold time 90;\
>     keepalive time 60;\
>     passive off;\
>     multihop;\
>     bfd no;\
> }\
> ')\
>\
> BGP_BORDER(\`CLIENT1', \`~~**10.8.1.1**~~', \`~~**10.8.1.2**~~')\
> BGP_BORDER(\`CLIENT1', \`~~**10.8.2.1**~~', \`~~**10.8.2.2**~~')\
> ...\
> BGP_BORDER(\`CLIENT99', \`~~**10.8.99.1**~~', \`~~**10.8.99.2**~~')
~~**Тык**~~ - это требует вашего внимания, для вашей конфигурации bird2
-- добавляем задачу в cron, обновление раз в неделю в среду в 5 утра
> crontab -e
> 0 5 * * 3 /usr/bin/python3 /opt/bird_list_ip/download.py > /dev/null 2>&1 # обновление списков ip адресов
-- моя рекомендация cron, если у вас идет выгрузка по спискам RKN
> crontab -e
> 0 5 * * * /usr/bin/python3 /opt/bird_list_ip/download.py RKN > /dev/null 2>&1 # обновление списков ip адресов RKN\
> 5 5 10 * * /usr/bin/python3 /opt/bird_list_ip/download.py -RKN > /dev/null 2>&1 # обновление списков ip адресов
-- запуск загрузки в ручную
> python3 /opt/bird_list_ip/download.py # выгружаем все списки\
> python3 /opt/bird_list_ip/download.py RU # выгружаем конкретный список\
> python3 /opt/bird_list_ip/download.py RU JAPAN KOREA # выгружаем перечисленные списки\
> python3 /opt/bird_list_ip/download.py -RU # выгружаем все списки, кроме RU\
> python3 /opt/bird_list_ip/download.py -RU JAPAN KOREA # выгрузит списки JAPAN KOREA, -RU будет проигнорирован\
> python3 /opt/bird_list_ip/download.py -RU jaPAn korea # допускается указывать ключ в любом регистре
-- добавляем bird2 в автозагрузку и запускаем
> systemctl daemon-reload && systemctl enable bird.service && systemctl start bird.service
**#####################################################################**\
    Пример конфигурация списка выгрузки можно посмотреть в файле list в репозитории,\
    так же допускается указывать url ссылку на конфигурацию первой строкой в файле list
Binary file not shown.
Binary file not shown.
+282 -321
View File
@@ -3,396 +3,357 @@
import re
import os
import sys
import ast
import net_tree
import requests
import ipaddress
from include import net_tree
from collections import defaultdict
from time import sleep as time_sleep
from shutil import get_terminal_size
from include.http_header import get_headers
# массив выгружаемых списков
ip_list = {
'RU': [
# Большая часть RU сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=RU'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://ipv4.fetus.jp/ru.txt'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/ru/aggregated.json'], 'ipv4': True, 'ipv6': False },
# HLL LLC
{ 'url': ['https://bgp.he.net/AS51115#_prefixes', 'https://ipinfo.io/widget/demo/AS51115?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS51115'], 'ipv4': True, 'ipv6': False },
# STATIC
{ 'static4': '188.130.255.0/24', 'ipv4': True, 'ipv6': False },
],
'MTS': [
# AS8359
{ 'url': ['https://bgp.he.net/AS13055#_prefixes', 'https://ipinfo.io/widget/demo/AS13055?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS13055'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS13155#_prefixes', 'https://ipinfo.io/widget/demo/AS13155?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS13155'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS13174#_prefixes', 'https://ipinfo.io/widget/demo/AS13174?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS13174'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS15640#_prefixes', 'https://ipinfo.io/widget/demo/AS15640?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS15640'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS16012#_prefixes', 'https://ipinfo.io/widget/demo/AS16012?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS16012'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS16256#_prefixes', 'https://ipinfo.io/widget/demo/AS16256?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS16256'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS197023#_prefixes', 'https://ipinfo.io/widget/demo/AS197023?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS197023'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS209024#_prefixes', 'https://ipinfo.io/widget/demo/AS209024?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS209024'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS21103#_prefixes', 'https://ipinfo.io/widget/demo/AS21103?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS21103'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS21365#_prefixes', 'https://ipinfo.io/widget/demo/AS21365?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS21365'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS28884#_prefixes', 'https://ipinfo.io/widget/demo/AS28884?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS28884'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS29190#_prefixes', 'https://ipinfo.io/widget/demo/AS29190?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS29190'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS29194#_prefixes', 'https://ipinfo.io/widget/demo/AS29194?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS29194'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS29209#_prefixes', 'https://ipinfo.io/widget/demo/AS29209?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS29209'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS29497#_prefixes', 'https://ipinfo.io/widget/demo/AS29497?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS29497'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS30881#_prefixes', 'https://ipinfo.io/widget/demo/AS30881?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS30881'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS30922#_prefixes', 'https://ipinfo.io/widget/demo/AS30922?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS30922'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS31558#_prefixes', 'https://ipinfo.io/widget/demo/AS31558?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS31558'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS33894#_prefixes', 'https://ipinfo.io/widget/demo/AS33894?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS33894'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS34351#_prefixes', 'https://ipinfo.io/widget/demo/AS34351?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS34351'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS35473#_prefixes', 'https://ipinfo.io/widget/demo/AS35473?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS35473'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS35728#_prefixes', 'https://ipinfo.io/widget/demo/AS35728?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS35728'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS39001#_prefixes', 'https://ipinfo.io/widget/demo/AS39001?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS39001'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS39811#_prefixes', 'https://ipinfo.io/widget/demo/AS39811?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS39811'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS39858#_prefixes', 'https://ipinfo.io/widget/demo/AS39858?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS39858'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS40993#_prefixes', 'https://ipinfo.io/widget/demo/AS40993?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS40993'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS41209#_prefixes', 'https://ipinfo.io/widget/demo/AS41209?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS41209'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS41822#_prefixes', 'https://ipinfo.io/widget/demo/AS41822?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS41822'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42087#_prefixes', 'https://ipinfo.io/widget/demo/AS42087?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42087'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42115#_prefixes', 'https://ipinfo.io/widget/demo/AS42115?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42115'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42322#_prefixes', 'https://ipinfo.io/widget/demo/AS42322?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42322'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43038#_prefixes', 'https://ipinfo.io/widget/demo/AS43038?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43038'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43148#_prefixes', 'https://ipinfo.io/widget/demo/AS43148?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43148'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS44257#_prefixes', 'https://ipinfo.io/widget/demo/AS44257?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS44257'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS44579#_prefixes', 'https://ipinfo.io/widget/demo/AS44579?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS44579'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS44677#_prefixes', 'https://ipinfo.io/widget/demo/AS44677?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS44677'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS44736#_prefixes', 'https://ipinfo.io/widget/demo/AS44736?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS44736'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS44895#_prefixes', 'https://ipinfo.io/widget/demo/AS44895?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS44895'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS47899#_prefixes', 'https://ipinfo.io/widget/demo/AS47899?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS47899'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48000#_prefixes', 'https://ipinfo.io/widget/demo/AS48000?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48000'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48123#_prefixes', 'https://ipinfo.io/widget/demo/AS48123?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48123'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48124#_prefixes', 'https://ipinfo.io/widget/demo/AS48124?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48124'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48212#_prefixes', 'https://ipinfo.io/widget/demo/AS48212?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48212'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48322#_prefixes', 'https://ipinfo.io/widget/demo/AS48322?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48322'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48400#_prefixes', 'https://ipinfo.io/widget/demo/AS48400?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48400'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48541#_prefixes', 'https://ipinfo.io/widget/demo/AS48541?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48541'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48612#_prefixes', 'https://ipinfo.io/widget/demo/AS48612?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48612'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS48796#_prefixes', 'https://ipinfo.io/widget/demo/AS48796?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS48796'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS49350#_prefixes', 'https://ipinfo.io/widget/demo/AS49350?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS49350'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS49665#_prefixes', 'https://ipinfo.io/widget/demo/AS49665?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS49665'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS49816#_prefixes', 'https://ipinfo.io/widget/demo/AS49816?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS49816'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS50071#_prefixes', 'https://ipinfo.io/widget/demo/AS50071?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS50071'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS50240#_prefixes', 'https://ipinfo.io/widget/demo/AS50240?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS50240'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS50406#_prefixes', 'https://ipinfo.io/widget/demo/AS50406?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS50406'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS60490#_prefixes', 'https://ipinfo.io/widget/demo/AS60490?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS60490'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS60891#_prefixes', 'https://ipinfo.io/widget/demo/AS60891?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS60891'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS6731#_prefixes', 'https://ipinfo.io/widget/demo/AS6731?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS6731'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8359#_prefixes', 'https://ipinfo.io/widget/demo/AS8359?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8359'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8580#_prefixes', 'https://ipinfo.io/widget/demo/AS8580?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8580'], 'ipv4': True, 'ipv6': False },
],
'VIMPELCOM': [
# AS3216
{ 'url': ['https://bgp.he.net/AS12543#_prefixes', 'https://ipinfo.io/widget/demo/AS12543?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS12543'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS13257#_prefixes', 'https://ipinfo.io/widget/demo/AS13257?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS13257'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS16043#_prefixes', 'https://ipinfo.io/widget/demo/AS16043?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS16043'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS16345#_prefixes', 'https://ipinfo.io/widget/demo/AS16345?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS16345'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS20533#_prefixes', 'https://ipinfo.io/widget/demo/AS20533?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS20533'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS20597#_prefixes', 'https://ipinfo.io/widget/demo/AS20597?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS20597'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS21332#_prefixes', 'https://ipinfo.io/widget/demo/AS21332?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS21332'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS21480#_prefixes', 'https://ipinfo.io/widget/demo/AS21480?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS21480'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS21483#_prefixes', 'https://ipinfo.io/widget/demo/AS21483?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS21483'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS2599#_prefixes', 'https://ipinfo.io/widget/demo/AS2599?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS2599'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS2766#_prefixes', 'https://ipinfo.io/widget/demo/AS2766?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS2766'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS28703#_prefixes', 'https://ipinfo.io/widget/demo/AS28703?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS28703'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS29125#_prefixes', 'https://ipinfo.io/widget/demo/AS29125?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS29125'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS31359#_prefixes', 'https://ipinfo.io/widget/demo/AS31359?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS31359'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS31425#_prefixes', 'https://ipinfo.io/widget/demo/AS31425?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS31425'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS3216#_prefixes', 'https://ipinfo.io/widget/demo/AS3216?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS3216'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS3235#_prefixes', 'https://ipinfo.io/widget/demo/AS3235?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS3235'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS3253#_prefixes', 'https://ipinfo.io/widget/demo/AS3253?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS3253'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS34038#_prefixes', 'https://ipinfo.io/widget/demo/AS34038?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS34038'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS34644#_prefixes', 'https://ipinfo.io/widget/demo/AS34644?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS34644'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS34747#_prefixes', 'https://ipinfo.io/widget/demo/AS34747?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS34747'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS34894#_prefixes', 'https://ipinfo.io/widget/demo/AS34894?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS34894'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42110#_prefixes', 'https://ipinfo.io/widget/demo/AS42110?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42110'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42245#_prefixes', 'https://ipinfo.io/widget/demo/AS42245?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42245'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS42842#_prefixes', 'https://ipinfo.io/widget/demo/AS42842?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS42842'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43275#_prefixes', 'https://ipinfo.io/widget/demo/AS43275?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43275'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43687#_prefixes', 'https://ipinfo.io/widget/demo/AS43687?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43687'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43970#_prefixes', 'https://ipinfo.io/widget/demo/AS43970?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43970'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS49144#_prefixes', 'https://ipinfo.io/widget/demo/AS49144?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS49144'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8350#_prefixes', 'https://ipinfo.io/widget/demo/AS8350?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8350'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8371#_prefixes', 'https://ipinfo.io/widget/demo/AS8371?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8371'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8402#_prefixes', 'https://ipinfo.io/widget/demo/AS8402?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8402'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8755#_prefixes', 'https://ipinfo.io/widget/demo/AS8755?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8755'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS8773#_prefixes', 'https://ipinfo.io/widget/demo/AS8773?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8773'], 'ipv4': True, 'ipv6': False },
],
'CHINA': [
# Большая часть CH сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=CN'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://ipv4.fetus.jp/cn.txt'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/cn/aggregated.json'], 'ipv4': True, 'ipv6': False },
# Hong Kong
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=HK'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://ipv4.fetus.jp/hk.txt'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/hk/aggregated.json'], 'ipv4': True, 'ipv6': False },
# Alibaba (US) Technology Co., Ltd.
{ 'url': ['https://bgp.he.net/AS45102#_prefixes', 'https://ipinfo.io/widget/demo/AS45102?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS45102'], 'ipv4': True, 'ipv6': False },
],
'JAPAN': [
# Большая часть KR сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=JP'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://ipv4.fetus.jp/jp.txt'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/jp/aggregated.json'], 'ipv4': True, 'ipv6': False },
],
'KOREA': [
# Большая часть KR сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=KR'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://ipv4.fetus.jp/kr.txt'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/kr/aggregated.json'], 'ipv4': True, 'ipv6': False },
# LG DACOM Corporation
{ 'url': ['https://bgp.he.net/AS3786#_prefixes', 'https://ipinfo.io/widget/demo/AS3786?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS3786'], 'ipv4': True, 'ipv6': False },
],
'GOOGLE': [
# Google LLC
{ 'url': ['https://bgp.he.net/AS11344#_prefixes', 'https://ipinfo.io/widget/demo/AS11344?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS11344'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS13949#_prefixes', 'https://ipinfo.io/widget/demo/AS13949?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS13949'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS15169#_prefixes', 'https://ipinfo.io/widget/demo/AS15169?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS15169'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS15276#_prefixes', 'https://ipinfo.io/widget/demo/AS15276?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS15276'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS19425#_prefixes', 'https://ipinfo.io/widget/demo/AS19425?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS19425'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS22577#_prefixes', 'https://ipinfo.io/widget/demo/AS22577?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS22577'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS26910#_prefixes', 'https://ipinfo.io/widget/demo/AS26910?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS26910'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36040#_prefixes', 'https://ipinfo.io/widget/demo/AS36040?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36040'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36492#_prefixes', 'https://ipinfo.io/widget/demo/AS36492?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36492'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36561#_prefixes', 'https://ipinfo.io/widget/demo/AS36561?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36561'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS394725#_prefixes', 'https://ipinfo.io/widget/demo/AS394725?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS394725'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS40873#_prefixes', 'https://ipinfo.io/widget/demo/AS40873?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS40873'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS43515#_prefixes', 'https://ipinfo.io/widget/demo/AS43515?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS43515'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS55023#_prefixes', 'https://ipinfo.io/widget/demo/AS55023?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS55023'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS6432#_prefixes', 'https://ipinfo.io/widget/demo/AS6432?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS6432'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS19527#_prefixes', 'https://ipinfo.io/widget/demo/AS19527?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS19527'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS26684#_prefixes', 'https://ipinfo.io/widget/demo/AS26684?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS26684'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS395973#_prefixes', 'https://ipinfo.io/widget/demo/AS395973?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS395973'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36039#_prefixes', 'https://ipinfo.io/widget/demo/AS36039?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36039'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS24424#_prefixes', 'https://ipinfo.io/widget/demo/AS24424?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS24424'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS396982#_prefixes', 'https://ipinfo.io/widget/demo/AS396982?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS396982'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS139070#_prefixes', 'https://ipinfo.io/widget/demo/AS139070?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS139070'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS139190#_prefixes', 'https://ipinfo.io/widget/demo/AS139190?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS139190'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS394699#_prefixes', 'https://ipinfo.io/widget/demo/AS394699?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS394699'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS32381#_prefixes', 'https://ipinfo.io/widget/demo/AS32381?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS32381'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36383#_prefixes', 'https://ipinfo.io/widget/demo/AS36383?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36383'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36411#_prefixes', 'https://ipinfo.io/widget/demo/AS36411?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36411'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36520#_prefixes', 'https://ipinfo.io/widget/demo/AS36520?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36520'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS394089#_prefixes', 'https://ipinfo.io/widget/demo/AS394089?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS394089'], 'ipv4': True, 'ipv6': False },
# Google IT
{ 'url': ['https://bgp.he.net/AS36384#_prefixes', 'https://ipinfo.io/widget/demo/AS36384?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36384'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS36385#_prefixes', 'https://ipinfo.io/widget/demo/AS36385?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS36385'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS41264#_prefixes', 'https://ipinfo.io/widget/demo/AS41264?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS41264'], 'ipv4': True, 'ipv6': False },
{ 'url': ['https://bgp.he.net/AS45566#_prefixes', 'https://ipinfo.io/widget/demo/AS45566?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS45566'], 'ipv4': True, 'ipv6': False },
# Skyonline Technosystem Private Limited
{ 'url': ['https://bgp.he.net/AS137154#_prefixes', 'https://ipinfo.io/widget/demo/AS137154?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS137154'], 'ipv4': True, 'ipv6': False },
# Ramyaa Network Communication
{ 'url': ['https://bgp.he.net/AS138756#_prefixes', 'https://ipinfo.io/widget/demo/AS138756?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS138756'], 'ipv4': True, 'ipv6': False },
# Haash Media
{ 'url': ['https://bgp.he.net/AS141480#_prefixes', 'https://ipinfo.io/widget/demo/AS141480?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS141480'], 'ipv4': True, 'ipv6': False },
# FAB FIVE NETWORK PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151690#_prefixes', 'https://ipinfo.io/widget/demo/AS151690?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151690'], 'ipv4': True, 'ipv6': False },
# AMITEL INDIA PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151691#_prefixes', 'https://ipinfo.io/widget/demo/AS151691?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151691'], 'ipv4': True, 'ipv6': False },
# SMALL INDUSTRIES DEVELOPMENT BANK OF INDIA
{ 'url': ['https://bgp.he.net/AS151692#_prefixes', 'https://ipinfo.io/widget/demo/AS151692?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151692'], 'ipv4': True, 'ipv6': False },
# WIRED2COMMUNICATION PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151693#_prefixes', 'https://ipinfo.io/widget/demo/AS151693?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151693'], 'ipv4': True, 'ipv6': False },
# SWS NETWORK PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151694#_prefixes', 'https://ipinfo.io/widget/demo/AS151694?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151694'], 'ipv4': True, 'ipv6': False },
# KARNET COMMUNICATIONS LIMITED
{ 'url': ['https://bgp.he.net/AS151695#_prefixes', 'https://ipinfo.io/widget/demo/AS151695?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151695'], 'ipv4': True, 'ipv6': False },
# GREEN WEB SOFTWARE DEVELOPMENT PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151698#_prefixes', 'https://ipinfo.io/widget/demo/AS151698?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151698'], 'ipv4': True, 'ipv6': False },
# FASTTECH NET PRIVATE LIMITED
{ 'url': ['https://bgp.he.net/AS151699#_prefixes', 'https://ipinfo.io/widget/demo/AS151699?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS151699'], 'ipv4': True, 'ipv6': False },
# Digivision Entertainment Private Limited
{ 'url': ['https://bgp.he.net/AS45148#_prefixes', 'https://ipinfo.io/widget/demo/AS45148?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS45148'], 'ipv4': True, 'ipv6': False },
# MTS, TTK, Megafon
{ 'static4': '212.188.0.0/17,188.43.0.0/16,178.176.0.0/14', 'ipv4': True, 'ipv6': False },
],
'RKN': [
{ 'url': ['https://reestr.rublacklist.net/api/v3/ips/', 'https://antifilter.network/download/ip.lst'], 'ipv4': 32, 'ipv6': False },
],
'MSFT': [
{ 'url': ['https://bgp.he.net/AS8075#_prefixes', 'https://ipinfo.io/widget/demo/AS8075?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS8075'], 'ipv4': True, 'ipv6': False },
],
'VALVE': [
{ 'url': ['https://bgp.he.net/AS32590#_prefixes', 'https://ipinfo.io/widget/demo/AS32590?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS32590'], 'ipv4': True, 'ipv6': False },
],
'AMAZONE': [
{ 'url': ['https://bgp.he.net/AS16509#_prefixes', 'https://ipinfo.io/widget/demo/AS16509?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS16509'], 'ipv4': True, 'ipv6': False },
]
}
# компилируем регулярку поиска ipv4 адреса
ipv4_find_str=re.compile(r"(?<![0-9.])(?!10\.|172\.(?:1[6-9]|2[0-9]|3[01])\.|192\.168\.)((?:25[0-5]|2[0-4][0-9]|1?[0-9][0-9]|[1-9])\.(?:25[0-5]|2[0-4][0-9]|1?[0-9][0-9]|[0-9])\.(?:25[0-5]|2[0-4][0-9]|1?[0-9][0-9]|[0-9])\.(?:25[0-5]|2[0-4][0-9]|1?[0-9][0-9]|[0-9]))(?:/(3[0-2]|[12][0-9]|[1-9]))?(?![0-9.])")
# компилируем регулярку поиска ipv6 адреса
ipv6_find_str=re.compile(r'(?<![0-9A-Fa-f:])([23][0-9A-Fa-f]{3}(?:(?::[0-9A-Fa-f]{1,4}){0,6}|(?:::[0-9A-Fa-f]{0,4})?)(?::[0-9A-Fa-f]{0,4})*)(?:/([1-9][0-9]?|1[01][0-9]|12[0-8]))?(?![0-9A-Fa-f:])')
ipv4_find_str=re.compile(r"[^0-9.]?(25[0-5]|2[0-4][0-9]|[1-9][0-9][0-9]?|[1-9])\.(25[0-5]|2[0-4][0-9]|[1-9][0-9][0-9]?|[0-9])\.(25[0-5]|2[0-4][0-9]|[1-9][0-9][0-9]?|[0-9])\.(25[0-5]|2[0-4][0-9]|[1-9][0-9][0-9]?|[0-9])(/([0-9]{1}[0-9]*))?[^0-9.]?")
# метод вывода прогресса на экран
def progres_print(lstr:list, mtype:int=0, ss:float=0.3):
"""
Метод вывода на экран прогресса выполнения
"""
term_width = get_terminal_size().columns
mtype: str = '33' if mtype == 1 else '31' if mtype == 2 else '32'
cstr: str = f"\033[{mtype}m | \033[0m".join(lstr)[:term_width]
print(f"\r{' ' * term_width}\r\033[{mtype}m>>>\033[0m {cstr}", end='', flush=True)
time_sleep(ss)
# метод сбора set адресов ipv4 из текста
# метод сбора словаря ip адресов ipv4 из текста
def ipv4_find(strip:str, size:int):
"""
Метод сбора set адресов ipv4 из текста
возвращает set ip
Метод сбора словаря ip адресов ipv4 из текста
возвращает словарь ip
где:
ключ - имя сети
значение - [адрес в int формате, размер сети]
"""
ips=set()
listip=dict()
for c in ipv4_find_str.finditer(strip):
ip_str = c.group(1)
prefix_str = c.group(2)
# определяем префикс
if (prefix:=int(prefix_str) if prefix_str else 32) > size: continue
# проверка корректности IPv4
try:
ips.add((int(ipaddress.IPv4Address(ip_str)), prefix))
except (ValueError, ipaddress.AddressValueError):
continue
return ips
ip:int=0
key:str=""
# 4 элемента кортежа, содержащие актеты адреса
for i in range(1, 5):
key+=str(c.group(i))+"."
ip = ip * 256 + int(c.group(i))
# элемент кортежа, содержащий размер сети
if c.group(6) and int(c.group(6))<=size:
listip[key[:-1]+"/"+str(c.group(6))]=[ip,int(c.group(6))]
# элемент кортежа, с размером сети, отсутствует
elif size==32:
listip[f"{key[:-1]}/32"]=[ip,32]
return listip
# метод сбора set адресов ipv6 из текста
# метод сбора словаря ip адресов ipv4 из текста
def ipv6_find(strip:str, size:int):
"""
Метод сбора set адресов ipv6 из текста
возвращает set ip
Метод сбора словаря ip адресов ipv4 из текста
возвращает словарь ip
где:
ключ - имя сети
значение - [адрес в int формате, размер сети]
"""
ips=set()
for c in ipv6_find_str.finditer(strip):
ip_str = c.group(1)
prefix_str = c.group(2)
# определяем префикс
if (prefix:=int(prefix_str) if prefix_str else 128) > size: continue
# проверка корректности IPv6
try:
ips.add((int(ipaddress.IPv6Address(ip_str)), prefix))
except (ValueError, ipaddress.AddressValueError):
continue
return ips
# метод группировки словаря
def get_dict_groups(input:dict):
"""
Метод получения сгрупированных данных
community и ip адресов
возвращает словарь сгрупированных данных
данные встречающиеся один раз, не попадают в вывод
"""
# если словарь короче 2х
if len(input) < 2: return {}
# строим битовые маски
name_to_bit = {name: 1 << i for i, name in enumerate(input.keys())}
line_communities = defaultdict(set)
line_mask = defaultdict(int)
# походим по строкам и назначаем маску
for name, (communities, lines) in input.items():
bit = name_to_bit[name]
for line in lines:
line_mask[line] |= bit
# добавляем комьюнити этого списка к конкретной строке
line_communities[line].update(communities)
# группируем строки по маске
groups = defaultdict(list)
groups_communities = defaultdict(set)
for line, mask in line_mask.items():
groups[mask].append(line)
groups_communities[mask].update(line_communities[line])
# конвертируем маску в имена
bit_to_names = {}
for mask in groups.keys():
names = [name for name, bit in name_to_bit.items() if mask & bit]
list_name = "__".join(names)
bit_to_names[mask] = list_name
# возвращаем словарь сгрупированных данных
return { bit_to_names[mask]: [ groups_communities[mask], set(groups[mask]) ] for mask in groups if "__" in bit_to_names[mask] and groups_communities[mask] and groups[mask] }
return dict()
# метод получения списка ip адресов
def list_ip(c_list: list = []):
def list_ip(c_dict: dict = []):
"""
Метод получения списка ip адресов
возвращает кортеж из 2-х списков: ipv4 и ipv6
"""
try:
ipv4_list=set()
ipv6_list=set()
# определяем, будем сжимать или нет
compress=c_list[0].get('compress', True)
# какие типы обрабытываем, от какого размера
# по умолчанию:
# ipv4 обрабатываем (<=24)
# ipv6 игнорируем (<=64)
# какие типы обрабытываем, от какого размера
ipv4 = False if not (ipv4:=c_list[0].get('ipv4', True)) else (ipv4 if type(ipv4) is int else 24)
ipv6 = False if not (ipv6:=c_list[0].get('ipv6', False)) else (ipv6 if type(ipv6) is int else 64)
c_list_len=len(c_list)
ipv4_list=dict()
ipv6_list=dict()
# пробегаем словарь выгрузки
for i, c_dict in enumerate(c_list, start=1):
# прогрес %
percent = int(i / c_list_len * 100)
for c_list in c_dict:
# какие типы обрабытываем, от какого размера
ipv4 = False if 'ipv4' not in list(c_list) or not c_list['ipv4'] else (c_list['ipv4'] if type(c_list['ipv4']) is int else 24)
ipv6 = False if 'ipv6' not in list(c_list) or not c_list['ipv6'] else (c_list['ipv6'] if type(c_list['ipv6']) is int else 32)
# если есть источник ссылка
if 'url' in list(c_dict):
if 'url' in list(c_list):
# бежим весь список ссылок пока не код 200
for c_url in c_dict['url']:
progres_print([c_url, f"{percent}%"])
try:
session = requests.Session()
session.headers.update(get_headers())
if (result:=session.get(c_url, timeout=(5, 60), stream=True)) and result.status_code == 200 and result.text:
for c_url in c_list['url']:
if (result:=requests.get(c_url)) and result.status_code == 200 and result.text:
print(f"URL: {c_url}")
# пополняем словарь ipv4_list
if ipv4: ipv4_list.update(ipv4_find(result.text,ipv4))
# пополняем словарь ipv6_list
if ipv6: ipv6_list.update(ipv6_find(result.text,ipv6))
break
except requests.exceptions.RequestException: pass
progres_print([c_url, f"{percent}%"],1,1)
print("Ошибка соединения")
# если есть статичные записи ipv4
if ipv4 and 'static4' in list(c_dict):
progres_print(["StaticIPv4", f"{percent}%"])
if ipv4 and 'static4' in list(c_list):
print(f"STATIC: IPv4")
# пополняем словарь ipv4_list
ipv4_list.update(ipv4_find(str(c_dict['static4']),ipv4))
ipv4_list.update(ipv4_find(str(c_list['static4']),ipv4))
# если есть статичные записи ipv6
if ipv6 and 'static6' in list(c_dict):
progres_print(["StaticIPv6", f"{percent}%"])
if ipv6 and 'static6' in list(c_list):
print(f"STATIC: IPv6")
# пополняем словарь ipv6_list
ipv6_list.update(ipv6_find(str(c_dict['static6']),ipv6))
ipv6_list.update(ipv6_find(str(c_list['static6']),ipv6))
# сжимаем подсети ipv4
if ipv4_list:
# создаем дерево
Root = net_tree.Node(net_tree.Net(0, 0, 4))
# добавляем IPv4 подсети
for ip_int, mask in sorted(ipv4_list, key=lambda x: x[0]):
Root.insert(net_tree.Net(ip_int, mask, 4))
# сжатие по CIDR, если ключ сжимать, иначе убираем только родителей, покрываемых детьми
ipv4_list = Root.export_compress('route {addr}/{masklen} blackhole;') if compress else Root.export('route {addr}/{masklen} blackhole;')
# строим дерево
Root = net_tree.Node(net_tree.Net(0,0), 0)
# пробегаем в цикле
for c in ipv4_list.values():
# добавляем запись в дерево
Root.addSubnet(net_tree.Node(net_tree.Net(c[0], c[1]), 1))
Root.finishTreeFirst()
# жесткое сжатие в размер 30000 записей
#Root.collapseRoot(Root.real_ip_records_count - 30000)
# более мягкое сжатие
Root.collapse(1,Root.real_ip_records_count)
# возвращаем результат
ipv4_list:str=Root.returnCollapsedTree('route {addr}/{masklen} blackhole;')
else:
ipv4_list:bool=False
# сжимаем подсети ipv6
if ipv6_list:
# строим дерево
Root = net_tree.Node(net_tree.Net(1 << 127, 0, 6))
# добавляем IPv6 подсети
for ip_int, mask in sorted(ipv6_list, key=lambda x: x[0]):
Root.insert(net_tree.Net(ip_int, mask, 6))
# сжатие по CIDR, если ключ сжимать, иначе убираем только родителей, покрываемых детьми
ipv6_list = Root.export_compress('route {addr}/{masklen} blackhole;') if compress else Root.export('route {addr}/{masklen} blackhole;')
None
else:
ipv6_list:bool=False
# возвращаем 2 списка маршрутов
return ipv4_list, ipv6_list
except Exception as e:
# исключение
print(f"\nОшибка: {e}")
print(f"Ошибка: {e}")
return False, False
# метод анализа элементов списка (аргументов)
def right_list(ip_list: list, args_list: list=[]):
"""
Метод анализа элементов списка выгрузок, возвращает актульный список выгрузок,
основываясь на списке аргументов, переданных вторым параметром
"""
# собираем словарь аргументов
# элементы списка начинающиеся с "-"
# попадают в off, остальные в on
c_dict = defaultdict(list)
for c in args_list:
key = "off" if c[0] == "-" else "on"
value = c[1:].upper() if c[0] == "-" else c.upper()
c_dict[key].append(value)
c_dict = dict(c_dict)
# если словарь аргументов не пустой
if c_dict:
# пробегаем список выгрузок
for c in ip_list[:]:
# пропускаем
if len(c_dict) == 2 and c in c_dict["on"] and not c in c_dict["off"]: continue
if len(c_dict) == 1 and (("on" in c_dict and c in c_dict["on"]) or ("off" in c_dict and not c in c_dict["off"])): continue
# удаляем элемент из списка
ip_list = list(filter(lambda x: x != c, ip_list))
return ip_list
# главная фукция
if __name__ == "__main__":
# словарь выгружаемых списков
ip_list = dict()
try:
# если файл list содержет json структуру, парсим его
with open(list_file:=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'list'), "r") as file:
ip_list = ast.literal_eval(file.read())
print(f"Список выгрузки (файл): {list_file}")
except (ValueError, SyntaxError):
try:
# если файл list ссылка, загружаем и парсим его
with open(list_file, "r") as file:
session = requests.Session()
session.headers.update(get_headers())
if (result:=session.get(url_list_file:=file.readline().strip(), timeout=(5, 5))) and result.status_code == 200 and result.text:
ip_list = ast.literal_eval(result.text)
print(f"Список выгрузки (url): {url_list_file}")
except requests.exceptions.RequestException:
print(f"Невалидный URL/ошибка выгрузки", file=sys.stderr)
sys.exit(1)
except (ValueError, SyntaxError):
print(f"Ошибочная структура json", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"Ошибка: {e}", file=sys.stderr)
sys.exit(1)
except FileNotFoundError:
print(f"Файл со списками не найден", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"Ошибка: {e}", file=sys.stderr)
sys.exit(1)
# проверяем на пустой список выгрузки
if (not ip_list):
print(f"Список выгрузки пустой", file=sys.stderr)
sys.exit(1)
# cловари для группировки
ipv4_dict=dict()
ipv6_dict=dict()
# список того, что будем выгружать/обновлять
download_ip_list=right_list(list(ip_list.keys()), sys.argv[1:])
# создаем дерриктори. для сохранения
outdir=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'unloading')
if not os.path.exists(outdir):
os.makedirs(outdir,exist_ok=True)
# создаём временный файл экспортируемой конфигурации, перед выгрузкой
open(ipv4_bird2_m4 := f"{outdir}/bird2_v4.m4.tmp", "w").close()
open(ipv6_bird2_m4 := f"{outdir}/bird2_v6.m4.tmp", "w").close()
# удаляем старые файлы группировок
[os.remove(path) for f in os.listdir(outdir) if "__" in f and os.path.isfile(path := os.path.join(outdir, f))]
# обходим массив списков для выгрузки
for clist, value in ip_list.items():
# обходим массив списков для выкрузки
for clist in ip_list:
# имена выходых файлов
ipv4_out_file=f"{outdir}/{clist.lower()}_v4.txt"
ipv6_out_file=f"{outdir}/{clist.lower()}_v6.txt"
# извлекаем community
community=[c for c in value[0].get('community', "").split(",") if c]
# обновляем только указанные списки
if clist in download_ip_list:
print("")
# вычисляем кол-во записей прошлой выгрузки
ipv4_count_old = sum(1 for line in open(ipv4_out_file)) if os.path.isfile(ipv4_out_file) else 0
ipv6_count_old = sum(1 for line in open(ipv6_out_file)) if os.path.isfile(ipv6_out_file) else 0
# выполняем выгрузку
print(f"Выгрузка списка IP: {clist}")
ipv4_list, ipv6_list=list_ip(value)
print(f"Выгружаю список IP: {clist}")
ipv4_list, ipv6_list=list_ip(ip_list[clist])
# сохраняем ipv4
if ipv4_list and len(ipv4_list.splitlines()) >= ipv4_count_old * 0.5:
if ipv4_list and len(ipv4_list.splitlines()) >= ipv4_count_old * 0.7:
# сохраняем в файл
with open(ipv4_out_file, "w") as file:
file.write(ipv4_list)
progres_print([f"Файл {ipv4_out_file}", "сохранён"])
print(f"Файл {ipv4_out_file} сохранён")
# сохраняем ipv6
if ipv6_list and len(ipv6_list.splitlines()) >= ipv6_count_old * 0.5:
if ipv6_list and len(ipv6_list.splitlines()) >= ipv6_count_old * 0.7:
# сохраняем в файл
with open(ipv6_out_file, "w") as file:
file.write(ipv6_list)
progres_print([f"Файл {ipv6_out_file}", "сохранён"])
# открываем файл выгрузки и пополняем словарь для группировки ipv4
if os.path.exists(ipv4_out_file):
with open(ipv4_out_file, "r") as file:
ipv4_dict[clist] = [community,list(file.readlines())]
# открываем файл выгрузки и пополняем словарь для группировки ipv6
if os.path.exists(ipv6_out_file):
with open(ipv6_out_file, "r") as file:
ipv6_dict[clist] = [community,list(file.readlines())]
print("\n\nКонфигурация Bird2:")
# обновляем временный файл конфигурации ipv4
# из группировок
if ipv4_dict:
for k,v in get_dict_groups(ipv4_dict).items():
# имена выходых файлов
ipv4_out_file=f"{outdir}/{k.lower()}_v4.txt"
# сохраняем в файл
with open(ipv4_out_file, "w") as file:
file.write("".join(v[1]))
progres_print([f"Группировка {ipv4_out_file}", "сохранена"])
# список комьюнити маршрутов
bgp_community=" ".join([f"bgp_community.add(({str(c).replace(':',',')}));" for c in sorted(v[0])])
with open(ipv4_bird2_m4, "a") as file:
file.write(f"protocol static static_{k.lower()}_v4 {{\n\tipv4 {{ import filter {{ {bgp_community} preference=400; accept; }}; }};\n\tinclude \"{ipv4_out_file}\";\n}}\n")
progres_print([f"В {ipv4_bird2_m4}", f"добавлен {k}"])
# обновляем временный файл конфигурации ipv6
# из группировок
if ipv6_dict:
for k,v in get_dict_groups(ipv6_dict).items():
# имена выходых файлов
ipv6_out_file=f"{outdir}/{k.lower()}_v6.txt"
# сохраняем в файл
with open(ipv6_out_file, "w") as file:
file.write("".join(v[1]))
progres_print([f"Группировка {ipv6_out_file}", "сохранена"])
# список комьюнити маршрутов
bgp_community=" ".join([f"bgp_community.add(({str(c).replace(':',',')}));" for c in sorted(v[0])])
with open(ipv6_bird2_m4, "a") as file:
file.write(f"protocol static static_{k.lower()}_v6 {{\n\tipv6 {{ import filter {{ {bgp_community} preference=400; accept; }}; }};\n\tinclude \"{ipv6_out_file}\";\n}}\n")
progres_print([f"В {ipv6_bird2_m4}", f"добавлен {k}"])
# дополняем временный файл конфигурации всей выгрузкой ipv4 и ipv6
for clist, value in ip_list.items():
# имена выходых файлов
ipv4_out_file=f"{outdir}/{clist.lower()}_v4.txt"
ipv6_out_file=f"{outdir}/{clist.lower()}_v6.txt"
# список комьюнити маршрутов
bgp_community=" ".join([f"bgp_community.add(({str(c).replace(':',',')}));" for c in sorted([c for c in value[0].get('community', "").split(",") if c])])
if os.path.exists(ipv4_out_file):
# фильтер маршрутов ipv4, если список ignore существует в конфигурации
ip_addresses_filter=set()
if (ignore:=value[0].get('ignore', [])):
ignore.append(f"-{clist}") # защита от фильтрации собственных маршрутов
for c in right_list(list(ip_list.keys()), ignore):
if os.path.exists(f_open:=f"{outdir}/{c.lower()}_v4.txt"):
with open(f_open, "r") as file:
ip_addresses_filter.update([line.strip().split()[1]+"+" for line in file])
with open(ipv4_bird2_m4, "a") as file:
bgp_filter=f"if net ~ [{','.join(ip_addresses_filter)}] then reject; " if ip_addresses_filter else ''
file.write(f"protocol static static_{clist.lower()}_v4 {{\n\tipv4 {{ import filter {{ {bgp_filter}{bgp_community} accept; }}; }};\n\tinclude \"{ipv4_out_file}\";\n}}\n")
progres_print([f"В {ipv4_bird2_m4}", f"добавлен {clist}"])
if os.path.exists(ipv6_out_file):
# фильтер маршрутов ipv6, если список ignore существует в конфигурации
ip_addresses_filter=set()
if (ignore:=value[0].get('ignore', [])):
ignore.append(f"-{clist}") # защита от фильтрации собственных маршрутов
for c in right_list(list(ip_list.keys()), ignore):
if os.path.exists(f_open:=f"{outdir}/{c.lower()}_v6.txt"):
with open(f_open, "r") as file:
ip_addresses_filter.update([line.strip().split()[1]+"+" for line in file])
with open(ipv6_bird2_m4, "a") as file:
bgp_filter=f"if net ~ [{','.join(ip_addresses_filter)}] then reject; " if ip_addresses_filter else ''
file.write(f"protocol static static_{clist.lower()}_v6 {{\n\tipv6 {{ import filter {{ {bgp_filter}{bgp_community} accept; }}; }};\n\tinclude \"{ipv6_out_file}\";\n}}\n")
progres_print([f"В {ipv6_bird2_m4}", f"добавлен {clist}"])
# проверяем, что временный файл конфигурации ipv6 не пустой, сохраняем в постоянный
if os.path.exists(ipv6_bird2_m4) and os.path.getsize(ipv6_bird2_m4) != 0:
os.replace(ipv6_bird2_m4, config_ipv6:=ipv6_bird2_m4.removesuffix(".tmp"))
progres_print([f"Конфиг {ipv6_bird2_m4}", f"перемещён в {os.path.basename(config_ipv6)}"])
else:
progres_print([f"Конфиг {ipv6_bird2_m4}", f"отсутствует/пуст"], 1)
# проверяем, что временный файл конфигурации ipv4 не пустой, сохраняем в постоянный
if os.path.exists(ipv4_bird2_m4) and os.path.getsize(ipv4_bird2_m4) != 0:
os.replace(ipv4_bird2_m4, config_ipv4:=ipv4_bird2_m4.removesuffix(".tmp"))
progres_print([f"Конфиг {ipv4_bird2_m4}", f"перемещён в {os.path.basename(config_ipv4)}"])
else:
progres_print([f"Конфиг {ipv4_bird2_m4}", f"отсутствует/пуст"], 1)
print("\n")
# реконфигурирование Bird2
os.system("systemctl reload bird.service >/dev/null 2>&1 || \
systemctl restart bird.service >/dev/null 2>&1 && \
echo '\\e[32mНовый конфиг Bird2 применён\\e[0m' || echo '\\e[31mBird2 error...\\e[0m'")
print(f"Файл {ipv6_out_file} сохранён")
print("")
-96
View File
@@ -1,96 +0,0 @@
import random
def get_headers():
# ОС Chrome/Firefox
platforms = [
'Windows NT 10.0; Win64; x64',
'Windows NT 10.0; WOW64',
'Macintosh; Intel Mac OS X 10_15_7',
'X11; Linux x86_64',
]
# Chrome версии
chrome_major = random.randint(120, 128)
chrome_build = random.randint(6000, 9999)
chrome_patch = random.randint(10, 200)
chrome_ua = (
f"Mozilla/5.0 ({random.choice(platforms)}) "
f"AppleWebKit/537.36 (KHTML, like Gecko) "
f"Chrome/{chrome_major}.0.{chrome_build}.{chrome_patch} Safari/537.36"
)
# Firefox версии
ff_ver = random.randint(110, 125)
firefox_ua = (
f"Mozilla/5.0 ({random.choice(platforms)}; rv:{ff_ver}.0) "
f"Gecko/20100101 Firefox/{ff_ver}.0"
)
# Выбираем браузер
user_agent = random.choice([chrome_ua, firefox_ua])
# sec-ch-ua зависит только от Chrome
if "Chrome" in user_agent:
sec_ch_ua = f'"Not_A Brand";v="8", "Chromium";v="{chrome_major}", "Google Chrome";v="{chrome_major}"'
sec_ch_mob = "?0"
sec_platform = '"Windows"' if "Windows" in user_agent else '"macOS"' if "Macintosh" in user_agent else '"Linux"'
else:
# Firefox их не отправляет
sec_ch_ua = None
sec_ch_mob = None
sec_platform = None
# Accept-Language
accept_lang = random.choice([
"ru-RU,ru;q=0.9,en-US;q=0.8",
"ru-RU,ru;q=0.8,en-US;q=0.7",
"ru-RU;q=0.9,ru;q=0.8,en-US;q=0.7",
"ru-RU;q=0.8,ru;q=0.7,en-US;q=0.9",
"ru;q=0.9,en;q=0.8",
"ru;q=0.8,en;q=0.7",
"ru;q=0.7,en;q=0.9",
"en-US,en;q=0.9,ru-RU,ru;q=0.8",
"en-US,en;q=0.8,ru-RU,ru;q=0.9",
"en-US;q=0.9,ru-RU,ru;q=0.7",
"en-US;q=0.8,ru-RU,ru;q=0.9",
"en-US;q=0.7,ru-RU,ru;q=0.8",
"en;q=0.9,ru;q=0.8",
"en;q=0.8,ru;q=0.9",
"en;q=0.7,ru;q=0.7",
])
# Реалистичные fetch-заголовки Chrome
sec_fetch_site = random.choice(["none", "same-site", "same-origin", "cross-site"])
sec_fetch_mode = "navigate"
sec_fetch_user = "?1"
sec_fetch_dest = "document"
# Заголовки в случайном порядке как в браузере
headers_list = [
("User-Agent", user_agent),
("Accept", "text/html,application/json,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"),
("Accept-Language", accept_lang),
("Accept-Encoding", "gzip, deflate, br, zstd"),
("Connection", "keep-alive"),
("Upgrade-Insecure-Requests", "1"),
]
if sec_ch_ua:
headers_list.extend([
("sec-ch-ua", sec_ch_ua),
("sec-ch-ua-mobile", sec_ch_mob),
("sec-ch-ua-platform", sec_platform),
("Sec-Fetch-Site", sec_fetch_site),
("Sec-Fetch-Mode", sec_fetch_mode),
("Sec-Fetch-User", sec_fetch_user),
("Sec-Fetch-Dest", sec_fetch_dest),
])
# Перемешиваем порядок (!) — браузеры могут менять порядок
random.shuffle(headers_list)
# Превращаем в dict
headers = {k: v for k, v in headers_list}
return headers
-291
View File
@@ -1,291 +0,0 @@
#
# CIDR AGGREGATOR (IPv4 + IPv6)
#
def mask_to_int(mask_size, total_bits):
return ((1 << total_bits) - 1) ^ ((1 << (total_bits - mask_size)) - 1)
def ip_volume(mask_size, total_bits):
return 1 << (total_bits - mask_size)
class Net:
__slots__ = ["version","bits","mask_size","net","mask","volume"]
def __init__(self, net: int, mask_size: int, version: int=4):
self.version, self.bits = (4, 32) if version==4 else (6, 128)
self.mask_size = mask_size
self.mask = mask_to_int(mask_size, self.bits)
self.net = net & self.mask
self.volume = ip_volume(mask_size, self.bits)
#
# --- IP CONVERSION ---
#
def __int_to_ipv4(self, n):
return ".".join(str((n >> (24 - 8*i)) & 0xFF) for i in range(4))
def __int_to_ipv6(self, n):
blocks = [(n >> (112 - 16*i)) & 0xFFFF for i in range(8)]
best_start = -1
best_len = 0
cur_start = -1
cur_len = 0
for i in range(8):
if blocks[i] == 0:
if cur_start < 0:
cur_start = i
cur_len = 1
else:
cur_len += 1
else:
if cur_len > best_len:
best_len = cur_len
best_start = cur_start
cur_start = -1
cur_len = 0
if cur_len > best_len:
best_len = cur_len
best_start = cur_start
if best_len > 1:
new = []
i = 0
while i < 8:
if i == best_start:
new.append('')
i += best_len
else:
new.append(format(blocks[i], 'x'))
i += 1
res = ":".join(new)
while ":::" in res:
res = res.replace(":::", "::")
return res
return ":".join(format(b, 'x') for b in blocks)
def __int_to_ip(self, n):
return self.__int_to_ipv4(n) if self.version == 4 else self.__int_to_ipv6(n)
#
# --- PUBLIC API ---
#
def getAsString(self, fmt='{addr}/{masklen}'):
return fmt.format(
addr=self.__int_to_ip(self.net),
masklen=self.mask_size
)
def is_adjacent(self, other):
if self.version != other.version: return False
if self.mask_size != other.mask_size: return False
step = 1 << (self.bits - self.mask_size)
return self.net + step == other.net or other.net + step == self.net
def supernet(self):
if self.mask_size == 0:
return self
new_mask = self.mask_size - 1
new_mask_int = mask_to_int(new_mask, self.bits)
new_net = self.net & new_mask_int
return Net(new_net, new_mask, self.version)
class Node:
__slots__ = [
"net", "child0", "child1",
"is_real",
"real_volume", "real_count",
"fake_volume", "weight", "max_child_weight"
]
def __init__(self, net: Net):
self.net = net
self.child0 = None
self.child1 = None
self.is_real = False
self.real_volume = 0
self.real_count = 0
self.fake_volume = 0
self.weight = 0
self.max_child_weight = 0
#
# INSERT NETWORK INTO TRIE
#
def insert(self, new_net: Net):
return self.__insert(new_net, level=0)
def __insert(self, new_net: Net, level):
# если дошли до маски сети — это лист
if level == new_net.mask_size:
if not self.is_real:
self.is_real = True
self.child0 = None
self.child1 = None
return
# разбираем бит адреса
bit_pos = self.net.bits - 1 - level
direction = (new_net.net >> bit_pos) & 1
if direction == 0:
if not self.child0:
child_net = Net(new_net.net & mask_to_int(level+1, self.net.bits), level+1, self.net.version)
self.child0 = Node(child_net)
self.child0.__insert(new_net, level+1)
else:
if not self.child1:
child_net = Net(new_net.net & mask_to_int(level+1, self.net.bits), level+1, self.net.version)
self.child1 = Node(child_net)
self.child1.__insert(new_net, level+1)
#
# CALCULATE WEIGHTS
#
def finalize(self):
if self.is_real:
self.real_volume = self.net.volume
self.real_count = 1
self.fake_volume = 0
self.weight = 0
self.max_child_weight = 0
return
self.real_volume = 0
self.real_count = 0
self.fake_volume = 0
self.max_child_weight = 0
for ch in (self.child0, self.child1):
if ch:
ch.finalize()
self.real_volume += ch.real_volume
self.real_count += ch.real_count
self.fake_volume += ch.fake_volume
self.max_child_weight = max(self.max_child_weight, ch.weight, ch.max_child_weight)
self.__recalc()
def __recalc(self):
missing = self.net.volume - self.real_volume - self.fake_volume
if missing > 0:
self.weight = (self.real_count - 1) / (missing ** 0.5)
else:
self.weight = float('inf')
#
# COLLAPSE / AGGREGATE
#
def collapse(self, min_weight=0, max_delta=float('inf')):
if self.is_real:
return 0,0
delta = 0
fake = 0
# сворачиваем детей
for ch in (self.child0, self.child1):
if ch:
d, f = ch.collapse(min_weight, max_delta - delta)
delta += d
fake += f
# попытаемся объединить
if self.child0 and self.child1:
c0 = self.child0
c1 = self.child1
if (c0.is_real and c1.is_real and
c0.net.is_adjacent(c1.net)):
super_net = c0.net.supernet()
# превращаем текущий узел в супернет
self.net = super_net
self.is_real = True
self.child0 = None
self.child1 = None
self.real_volume = c0.real_volume + c1.real_volume
self.fake_volume = super_net.volume - self.real_volume
self.real_count = 1
self.weight = 0
self.max_child_weight = 0
return delta + 2, fake + self.fake_volume
# пересчитываем статистику
if not self.is_real:
self.real_volume = 0
self.real_count = 0
self.fake_volume = 0
self.max_child_weight = 0
for ch in (self.child0, self.child1):
if ch:
self.real_volume += ch.real_volume
self.real_count += ch.real_count
self.fake_volume += ch.fake_volume
self.max_child_weight = max(self.max_child_weight, ch.weight, ch.max_child_weight)
self.__recalc()
return delta, fake
def export_compress(self, fmt='{addr}/{masklen}'):
# считаем статистику
self.finalize()
# сжимаем
self.collapse()
result = []
def walk(node):
if node is None:
return
# если суперсеть реальная –> дети не нужны
if node.is_real:
result.append(node.net.getAsString(fmt))
return
walk(node.child0)
walk(node.child1)
walk(self)
return "\n".join(result)
def export(self, fmt='{addr}/{masklen}'):
# считаем статистику
self.finalize()
result = []
def walk(node):
if node is None:
return
if node.is_real:
# дети полностью покрывают диапазон родителя?
child_real_vol = 0
for ch in (node.child0, node.child1):
if ch:
child_real_vol += ch.real_volume
# если дети полностью покрывают родителя -> родители не нужны
if child_real_vol >= node.net.volume:
walk(node.child0)
walk(node.child1)
return
# иначе выводим родителя и детей
result.append(node.net.getAsString(fmt))
walk(node.child0)
walk(node.child1)
walk(self)
return "\n".join(result)
-55
View File
@@ -1,55 +0,0 @@
{
'RU': [
# параметры конфигурации должны быть в самом верху списка
{
'ipv4': True, # не обязательный аргумент, по умолчанию True (24)
'ipv6': True, # не обязательный аргумент, по умолчанию False (64)
'ignore': ['CHINA', 'JAPAN'], # игнорируем маршруты, которые входят в перечисленный список выгрузок (работает кроме: -CHINA)
'compress': False, # не обязательный аргумент, по умолчанию True
'community': '65432:LOCATION,65432:200' # не обязательный аргумент, по умолчанию пусто
},
# Большая часть RU сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=RU'] },
{ 'url': ['https://ipv4.fetus.jp/ru.txt'] },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/ru/aggregated.json'] },
# HLL LLC
{ 'url': ['https://bgp.he.net/AS51115#_prefixes', 'https://ipinfo.io/widget/demo/AS51115?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS51115'] },
# STATIC
{ 'static4': '188.130.255.0/24' },
],
'CHINA': [
{
# пример без community
'ipv4': True,
'ipv6': False,
'compress': True,
#'community': '65432:LOCATION,65432:201'
},
# Большая часть CH сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=CN'] },
{ 'url': ['https://ipv4.fetus.jp/cn.txt'] },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/cn/aggregated.json'] },
],
'JAPAN': [
{
'ipv6': True,
'community': '65432:LOCATION,65432:202',
},
# Большая часть KR сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=JP'] },
{ 'url': ['https://ipv4.fetus.jp/jp.txt'] },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/jp/aggregated.json'] },
],
'KOREA': [
{
'ipv6': True,
'community': '65432:LOCATION,65432:203'
},
# Большая часть KR сегмента
{ 'url': ['https://stat.ripe.net/data/country-resource-list/data.json?resource=KR'] },
{ 'url': ['https://ipv4.fetus.jp/kr.txt'] },
{ 'url': ['https://github.com/ipverse/rir-ip/blob/master/country/kr/aggregated.json'] },
# LG DACOM Corporation
{ 'url': ['https://bgp.he.net/AS3786#_prefixes', 'https://ipinfo.io/widget/demo/AS3786?dataset=asn', 'https://api.hackertarget.com/aslookup/?q=AS3786'] },
],
}
+213
View File
@@ -0,0 +1,213 @@
BIG_MASK = (1 << 32) - 1
def getMaskByMaskSize(mask_size):
return BIG_MASK ^ ((1 << (32 - mask_size)) - 1)
def getIpVolumeByMaskSize(mask_size):
return 1 << (32 - mask_size)
class Net:
__slots__ = ['mask_size', 'net', 'mask', 'ip_volume']
def __init__(self, net: int, mask_size: int):
self.mask_size = mask_size
self.net = net & getMaskByMaskSize(mask_size)
self.mask = getMaskByMaskSize(self.mask_size)
self.ip_volume = getIpVolumeByMaskSize(mask_size)
def hasSubnet(self, Net: 'Net'):
if Net.mask_size <= self.mask_size: return 0
return self.net == Net.net & self.mask
def isSameNet(self, Net: 'Net'):
return (Net.mask_size == self.mask_size) and (Net.net == self.net)
def getCommonNet(self, OtherNet: 'Net', min_mask_size: int):
if self.mask_size <= min_mask_size: return 0
if OtherNet.mask_size <= min_mask_size: return 0
for mask_size in range(min(self.mask_size, OtherNet.mask_size) - 1, min_mask_size - 1, -1):
mask = getMaskByMaskSize(mask_size)
if (self.net & mask) == (OtherNet.net & mask):
return Net(self.net, mask_size)
return 0
def getAsString(self, fmt='{addr}/{masklen}'):
net = self.net
mask = self.mask
addrbytes = []
maskbytes = []
for i in range(4):
addrbytes.append(str(net % 256))
maskbytes.append(str(mask % 256))
net = net >> 8
mask = mask >> 8
return fmt.format(addr='.'.join(reversed(addrbytes)), mask='.'.join(reversed(maskbytes)), masklen=self.mask_size)
class Node:
__slots__ = ['net', 'child1', 'child2', 'is_real_net', 'real_ip_volume', 'real_ip_records_count', 'weight', 'max_child_weight', 'added_fake_ip_volume']
def __init__(self, net: Net, is_real_net: int):
self.net = net
self.child1 = None
self.child2 = None
self.is_real_net = is_real_net
self.real_ip_volume = 0
self.real_ip_records_count = 0
self.weight = 0.0
self.max_child_weight = 0.0
self.added_fake_ip_volume = 0
def getNet(self):
return self.net
def addSubnet(self, NewNode: 'Node'):
if self.net.isSameNet(NewNode.net):
if not self.is_real_net and NewNode.is_real_net:
self.is_real_net = 1
self.child1 = None
self.child2 = None
return 1
if self.is_real_net and self.net.hasSubnet(NewNode.net):
return 1
if not self.net.hasSubnet(NewNode.net):
return 0
for Child in (self.child1, self.child2):
if Child and Child.addSubnet(NewNode):
return 1
if self.child1:
CommonNet = self.child1.net.getCommonNet(NewNode.net, self.net.mask_size + 1)
if CommonNet:
CommonNode = Node(CommonNet, 0)
CommonNode.addSubnet(NewNode)
CommonNode.addSubnet(self.child1)
self.child1 = CommonNode
return 1
if self.child2:
CommonNet = self.child2.net.getCommonNet(NewNode.net, self.net.mask_size + 1)
if CommonNet:
CommonNode = Node(CommonNet, 0)
CommonNode.addSubnet(NewNode)
CommonNode.addSubnet(self.child2)
self.child2 = CommonNode
return 1
if not self.child1:
self.child1 = NewNode
else:
self.child2 = NewNode
return 1
def printTree(self, level):
prefix = ''
for i in range(level):
prefix = prefix + ' '
if self.is_real_net: sign = '*'
elif self.weight == 0: sign = '.'
else: sign = ''
print(prefix + self.net.getAsString() + ' ' + str(self.real_ip_records_count))
if self.child1:
self.child1.printTree(level + 1)
if self.child2:
self.child2.printTree(level + 1)
def finishTreeFirst(self):
if self.is_real_net:
self.real_ip_volume = self.net.ip_volume
self.real_ip_records_count = 1
self.weight = 0
self.max_child_weight = 0
else:
self.real_ip_volume = 0
self.real_ip_records_count = 0
self.max_child_weight = 0
for Child in (self.child1, self.child2):
if Child:
Child.finishTreeFirst()
self.real_ip_volume += Child.real_ip_volume
self.real_ip_records_count += Child.real_ip_records_count
self.max_child_weight = max(self.max_child_weight, Child.weight, Child.max_child_weight)
self.recalcWeight()
def collapse(self, min_weight, max_net_delta):
# trying to collapse self
if self.weight >= min_weight:
self.weight = 0
self.max_child_weight = 0
delta = (self.net.ip_volume - self.real_ip_volume) - self.added_fake_ip_volume
self.added_fake_ip_volume = self.net.ip_volume - self.real_ip_volume
return self.real_ip_records_count - 1, delta
net_delta = 0
fake_ip_delta = 0
self.max_child_weight = 0
for Child in (self.child1, self.child2):
if Child:
if net_delta < max_net_delta and min_weight <= max(Child.weight, Child.max_child_weight):
child_net_delta, child_fake_ip_count = Child.collapse(min_weight, max_net_delta - net_delta)
net_delta += child_net_delta
fake_ip_delta += child_fake_ip_count
self.max_child_weight = max(self.max_child_weight, Child.weight, Child.max_child_weight)
if net_delta > 0:
self.added_fake_ip_volume += fake_ip_delta
self.real_ip_records_count -= net_delta
self.recalcWeight()
# trying to collapse self
if self.weight >= min_weight:
self.weight = 0
self.max_child_weight = 0
delta = (self.net.ip_volume - self.real_ip_volume) - (self.added_fake_ip_volume - fake_ip_delta)
self.added_fake_ip_volume = self.net.ip_volume - self.real_ip_volume
return self.real_ip_records_count - 1, delta
else:
return net_delta, fake_ip_delta
def collapseRoot(self, required_net_delta):
while required_net_delta > 0:
delta, fake_ip_volume = self.collapse(self.max_child_weight, required_net_delta)
required_net_delta -= delta
def printCollapsedTree(self, fmt='{addr}/{masklen}'):
if self.is_real_net or self.weight == 0:
print(self.net.getAsString(fmt))
else:
for Child in (self.child1, self.child2):
if Child:
Child.printCollapsedTree(fmt)
def returnCollapsedTree(self, fmt='{addr}/{masklen}'):
if self.is_real_net or self.weight == 0:
return self.net.getAsString(fmt) + "\n"
else:
res = ""
for Child in (self.child1, self.child2):
if Child:
res += Child.returnCollapsedTree(fmt)
return res
def recalcWeight(self):
fake_ip_delta = self.net.ip_volume - self.real_ip_volume - self.added_fake_ip_volume
if fake_ip_delta:
self.weight = (self.real_ip_records_count - 1) / fake_ip_delta
else:
self.weight = float('Inf')
def getNotRealIpCount(self):
if self.is_real_net: return 0
if self.weight == 0: return self.net.ip_volume - self.real_ip_volume
res = 0
for Child in (self.child1, self.child2):
if Child:
res = res + Child.getNotRealIpCount()
return res
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+115
View File
@@ -0,0 +1,115 @@
route 108.177.0.0/17 blackhole;
route 108.170.192.0/18 blackhole;
route 108.59.80.0/20 blackhole;
route 107.178.192.0/18 blackhole;
route 107.167.160.0/19 blackhole;
route 104.196.0.0/14 blackhole;
route 104.154.0.0/15 blackhole;
route 74.125.0.0/16 blackhole;
route 72.14.192.0/18 blackhole;
route 70.32.128.0/19 blackhole;
route 66.249.64.0/19 blackhole;
route 66.102.0.0/20 blackhole;
route 66.22.228.0/23 blackhole;
route 64.233.160.0/19 blackhole;
route 57.140.244.0/24 blackhole;
route 57.140.240.0/22 blackhole;
route 57.140.228.0/24 blackhole;
route 57.140.224.0/22 blackhole;
route 57.140.215.0/24 blackhole;
route 57.140.212.0/24 blackhole;
route 57.140.208.0/22 blackhole;
route 57.140.196.0/23 blackhole;
route 57.140.192.0/22 blackhole;
route 35.240.0.0/13 blackhole;
route 35.224.0.0/12 blackhole;
route 35.220.0.0/14 blackhole;
route 35.219.224.0/19 blackhole;
route 35.219.194.0/24 blackhole;
route 35.219.193.0/24 blackhole;
route 35.219.128.0/18 blackhole;
route 35.219.0.0/17 blackhole;
route 35.216.0.0/15 blackhole;
route 35.208.0.0/13 blackhole;
route 35.207.0.0/16 blackhole;
route 35.206.128.0/17 blackhole;
route 35.206.64.0/18 blackhole;
route 35.206.32.0/19 blackhole;
route 35.206.10.0/23 blackhole;
route 35.206.9.0/24 blackhole;
route 35.206.0.0/21 blackhole;
route 35.204.0.0/15 blackhole;
route 35.203.224.0/23 blackhole;
route 35.199.128.0/18 blackhole;
route 35.199.0.0/17 blackhole;
route 35.198.0.0/16 blackhole;
route 35.196.0.0/15 blackhole;
route 35.192.0.0/14 blackhole;
route 35.184.0.0/13 blackhole;
route 34.184.0.0/14 blackhole;
route 34.176.0.0/13 blackhole;
route 34.160.0.0/12 blackhole;
route 34.128.0.0/11 blackhole;
route 34.4.4.0/24 blackhole;
route 34.3.3.0/24 blackhole;
route 34.1.192.0/18 blackhole;
route 34.1.160.0/19 blackhole;
route 34.1.128.0/20 blackhole;
route 34.1.96.0/21 blackhole;
route 34.1.88.0/21 blackhole;
route 34.1.84.0/22 blackhole;
route 34.1.83.0/24 blackhole;
route 34.1.80.0/23 blackhole;
route 34.1.64.0/20 blackhole;
route 34.1.0.0/18 blackhole;
route 34.0.240.0/20 blackhole;
route 34.0.234.0/23 blackhole;
route 34.0.233.0/24 blackhole;
route 34.0.224.0/22 blackhole;
route 34.0.192.0/19 blackhole;
route 34.0.128.0/18 blackhole;
route 34.0.96.0/19 blackhole;
route 34.0.0.0/18 blackhole;
route 23.251.128.0/19 blackhole;
route 23.236.48.0/20 blackhole;
route 8.35.192.0/20 blackhole;
route 8.34.208.0/20 blackhole;
route 8.8.8.0/24 blackhole;
route 8.8.4.0/24 blackhole;
route 216.239.32.0/19 blackhole;
route 216.73.80.0/20 blackhole;
route 216.58.192.0/19 blackhole;
route 212.188.0.0/17 blackhole;
route 209.85.128.0/17 blackhole;
route 208.68.108.0/22 blackhole;
route 207.223.160.0/20 blackhole;
route 199.223.232.0/21 blackhole;
route 199.192.112.0/22 blackhole;
route 199.36.156.0/24 blackhole;
route 199.36.154.0/23 blackhole;
route 193.186.4.0/24 blackhole;
route 192.178.0.0/15 blackhole;
route 192.158.28.0/22 blackhole;
route 178.176.0.0/14 blackhole;
route 188.43.0.0/16 blackhole;
route 173.255.112.0/20 blackhole;
route 173.194.0.0/16 blackhole;
route 172.253.0.0/16 blackhole;
route 172.217.0.0/16 blackhole;
route 172.110.32.0/21 blackhole;
route 162.222.176.0/21 blackhole;
route 162.216.148.0/22 blackhole;
route 162.120.128.0/17 blackhole;
route 152.65.224.0/19 blackhole;
route 152.65.222.0/23 blackhole;
route 152.65.218.0/24 blackhole;
route 152.65.214.0/24 blackhole;
route 152.65.210.0/23 blackhole;
route 152.65.209.0/24 blackhole;
route 146.148.0.0/17 blackhole;
route 142.250.0.0/15 blackhole;
route 136.22.186.0/24 blackhole;
route 136.22.184.0/23 blackhole;
route 136.22.176.0/21 blackhole;
route 136.22.160.0/20 blackhole;
route 130.211.0.0/16 blackhole;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+565
View File
@@ -0,0 +1,565 @@
route 124.252.0.0/16 blackhole;
route 122.149.0.0/16 blackhole;
route 113.197.64.0/22 blackhole;
route 111.221.64.0/18 blackhole;
route 111.221.30.0/23 blackhole;
route 111.221.29.0/24 blackhole;
route 111.221.24.0/22 blackhole;
route 111.221.16.0/21 blackhole;
route 109.246.0.0/16 blackhole;
route 108.161.110.0/24 blackhole;
route 108.140.0.0/14 blackhole;
route 104.237.40.0/24 blackhole;
route 104.208.0.0/13 blackhole;
route 104.146.128.0/17 blackhole;
route 104.40.0.0/13 blackhole;
route 103.249.62.0/23 blackhole;
route 103.180.108.0/24 blackhole;
route 103.166.60.0/24 blackhole;
route 103.164.237.0/24 blackhole;
route 103.158.243.0/24 blackhole;
route 103.155.245.0/24 blackhole;
route 103.131.148.0/23 blackhole;
route 103.58.119.0/24 blackhole;
route 103.8.80.0/24 blackhole;
route 102.211.187.0/24 blackhole;
route 102.133.0.0/16 blackhole;
route 102.37.0.0/16 blackhole;
route 98.70.0.0/15 blackhole;
route 98.64.0.0/14 blackhole;
route 95.128.193.0/24 blackhole;
route 94.245.64.0/18 blackhole;
route 94.241.160.0/23 blackhole;
route 94.143.108.0/24 blackhole;
route 94.143.106.0/23 blackhole;
route 94.143.105.0/24 blackhole;
route 92.118.22.0/23 blackhole;
route 91.245.215.0/24 blackhole;
route 91.242.222.0/24 blackhole;
route 91.233.67.0/24 blackhole;
route 91.216.184.0/24 blackhole;
route 91.203.230.0/24 blackhole;
route 91.186.216.0/23 blackhole;
route 86.91.0.0/16 blackhole;
route 85.212.0.0/16 blackhole;
route 85.210.0.0/15 blackhole;
route 84.222.0.0/15 blackhole;
route 84.81.0.0/16 blackhole;
route 82.171.0.0/16 blackhole;
route 82.87.0.0/16 blackhole;
route 81.22.128.0/24 blackhole;
route 74.248.0.0/15 blackhole;
route 74.240.0.0/14 blackhole;
route 74.234.0.0/15 blackhole;
route 74.224.0.0/14 blackhole;
route 74.200.130.0/24 blackhole;
route 74.176.0.0/14 blackhole;
route 74.160.0.0/14 blackhole;
route 74.144.0.0/12 blackhole;
route 74.116.254.0/24 blackhole;
route 74.80.229.0/24 blackhole;
route 74.7.0.0/16 blackhole;
route 72.152.0.0/14 blackhole;
route 72.144.0.0/14 blackhole;
route 72.54.0.0/16 blackhole;
route 72.18.78.0/24 blackhole;
route 72.16.128.0/17 blackhole;
route 70.156.0.0/15 blackhole;
route 70.152.0.0/15 blackhole;
route 70.37.128.0/18 blackhole;
route 70.37.0.0/17 blackhole;
route 69.84.180.0/23 blackhole;
route 69.59.17.0/24 blackhole;
route 69.52.204.0/24 blackhole;
route 69.52.198.0/23 blackhole;
route 69.52.192.0/23 blackhole;
route 69.15.0.0/16 blackhole;
route 68.220.0.0/15 blackhole;
route 68.218.0.0/15 blackhole;
route 68.210.0.0/15 blackhole;
route 68.154.0.0/15 blackhole;
route 67.210.128.0/23 blackhole;
route 66.178.148.0/23 blackhole;
route 66.132.204.0/22 blackhole;
route 66.119.144.0/20 blackhole;
route 65.52.0.0/14 blackhole;
route 64.236.0.0/16 blackhole;
route 64.112.188.0/24 blackhole;
route 64.72.206.0/24 blackhole;
route 64.15.25.0/24 blackhole;
route 64.15.23.0/24 blackhole;
route 64.13.130.0/24 blackhole;
route 64.4.0.0/18 blackhole;
route 63.116.158.0/24 blackhole;
route 62.132.26.0/23 blackhole;
route 62.97.228.0/24 blackhole;
route 62.12.60.0/23 blackhole;
route 62.12.56.0/22 blackhole;
route 57.160.0.0/12 blackhole;
route 57.152.0.0/13 blackhole;
route 57.150.0.0/15 blackhole;
route 52.224.0.0/11 blackhole;
route 52.160.0.0/11 blackhole;
route 52.152.0.0/13 blackhole;
route 52.148.0.0/14 blackhole;
route 52.146.0.0/15 blackhole;
route 52.136.0.0/13 blackhole;
route 52.125.0.0/16 blackhole;
route 52.120.0.0/14 blackhole;
route 52.112.0.0/14 blackhole;
route 52.96.0.0/12 blackhole;
route 51.144.0.0/15 blackhole;
route 51.140.0.0/14 blackhole;
route 51.138.0.0/16 blackhole;
route 51.136.0.0/15 blackhole;
route 51.132.0.0/16 blackhole;
route 51.126.0.0/16 blackhole;
route 51.124.0.0/16 blackhole;
route 51.120.0.0/16 blackhole;
route 51.116.0.0/16 blackhole;
route 51.111.0.0/16 blackhole;
route 51.109.0.0/16 blackhole;
route 51.107.0.0/16 blackhole;
route 51.104.0.0/15 blackhole;
route 51.103.0.0/16 blackhole;
route 51.56.0.0/14 blackhole;
route 51.54.0.0/15 blackhole;
route 51.53.0.0/16 blackhole;
route 51.51.0.0/16 blackhole;
route 51.42.0.0/16 blackhole;
route 51.12.0.0/15 blackhole;
route 51.10.0.0/15 blackhole;
route 51.8.0.0/16 blackhole;
route 51.4.0.0/15 blackhole;
route 51.1.0.0/16 blackhole;
route 50.85.0.0/16 blackhole;
route 48.192.0.0/11 blackhole;
route 46.29.242.0/24 blackhole;
route 45.156.164.0/23 blackhole;
route 45.146.100.0/22 blackhole;
route 45.143.224.0/23 blackhole;
route 45.82.119.0/24 blackhole;
route 45.66.80.0/24 blackhole;
route 45.8.43.0/24 blackhole;
route 41.223.11.0/24 blackhole;
route 40.253.0.0/16 blackhole;
route 40.212.0.0/16 blackhole;
route 40.170.0.0/15 blackhole;
route 40.169.0.0/16 blackhole;
route 40.159.0.0/16 blackhole;
route 40.155.0.0/16 blackhole;
route 40.148.0.0/16 blackhole;
route 40.146.0.0/16 blackhole;
route 40.127.0.0/16 blackhole;
route 40.126.128.0/17 blackhole;
route 40.126.0.0/18 blackhole;
route 40.125.0.0/17 blackhole;
route 40.124.0.0/16 blackhole;
route 40.120.0.0/14 blackhole;
route 40.112.0.0/13 blackhole;
route 40.110.0.0/15 blackhole;
route 40.108.128.0/17 blackhole;
route 40.104.0.0/14 blackhole;
route 40.96.0.0/13 blackhole;
route 40.80.0.0/12 blackhole;
route 40.76.0.0/14 blackhole;
route 40.74.0.0/15 blackhole;
route 40.68.0.0/14 blackhole;
route 40.67.0.0/16 blackhole;
route 40.66.166.0/24 blackhole;
route 40.66.0.0/17 blackhole;
route 40.64.0.0/15 blackhole;
route 40.47.0.0/16 blackhole;
route 23.148.120.0/24 blackhole;
route 23.103.128.0/17 blackhole;
route 23.103.64.0/18 blackhole;
route 23.102.0.0/16 blackhole;
route 23.100.0.0/15 blackhole;
route 23.96.0.0/14 blackhole;
route 20.192.0.0/10 blackhole;
route 20.184.0.0/13 blackhole;
route 20.160.0.0/12 blackhole;
route 20.157.0.0/16 blackhole;
route 20.152.0.0/15 blackhole;
route 20.150.0.0/15 blackhole;
route 20.143.0.0/16 blackhole;
route 20.136.0.0/17 blackhole;
route 20.135.0.0/16 blackhole;
route 20.64.0.0/10 blackhole;
route 20.48.0.0/12 blackhole;
route 20.40.0.0/13 blackhole;
route 20.36.0.0/14 blackhole;
route 20.33.0.0/16 blackhole;
route 20.0.0.0/11 blackhole;
route 13.104.0.0/14 blackhole;
route 13.64.0.0/11 blackhole;
route 9.234.0.0/15 blackhole;
route 9.223.0.0/16 blackhole;
route 9.205.0.0/16 blackhole;
route 9.169.0.0/16 blackhole;
route 9.163.0.0/16 blackhole;
route 9.160.0.0/16 blackhole;
route 9.146.0.0/16 blackhole;
route 9.145.0.0/16 blackhole;
route 9.141.0.0/16 blackhole;
route 5.23.34.0/24 blackhole;
route 4.192.0.0/10 blackhole;
route 4.160.0.0/11 blackhole;
route 4.144.0.0/12 blackhole;
route 2.58.103.0/24 blackhole;
route 1.186.0.0/16 blackhole;
route 217.176.0.0/16 blackhole;
route 217.169.202.0/24 blackhole;
route 217.11.173.0/24 blackhole;
route 216.220.208.0/20 blackhole;
route 216.220.204.0/24 blackhole;
route 216.220.203.0/24 blackhole;
route 216.183.110.0/23 blackhole;
route 216.126.214.0/24 blackhole;
route 216.99.143.0/24 blackhole;
route 216.73.183.0/24 blackhole;
route 216.32.180.0/22 blackhole;
route 213.218.48.0/22 blackhole;
route 213.218.36.0/23 blackhole;
route 213.199.128.0/18 blackhole;
route 213.156.248.0/23 blackhole;
route 213.54.0.0/16 blackhole;
route 212.207.0.0/16 blackhole;
route 212.46.57.0/24 blackhole;
route 212.1.222.0/23 blackhole;
route 212.1.218.0/23 blackhole;
route 209.251.248.0/24 blackhole;
route 209.240.192.0/19 blackhole;
route 209.199.0.0/16 blackhole;
route 209.143.212.0/23 blackhole;
route 209.51.100.0/24 blackhole;
route 208.103.174.0/24 blackhole;
route 208.90.118.0/24 blackhole;
route 208.84.0.0/21 blackhole;
route 208.80.20.0/23 blackhole;
route 208.76.46.0/24 blackhole;
route 208.76.45.0/24 blackhole;
route 208.68.136.0/21 blackhole;
route 208.66.228.0/24 blackhole;
route 207.174.51.0/24 blackhole;
route 207.103.0.0/16 blackhole;
route 207.68.128.0/18 blackhole;
route 207.46.128.0/17 blackhole;
route 207.46.64.0/18 blackhole;
route 207.46.48.0/20 blackhole;
route 207.46.40.0/21 blackhole;
route 207.46.36.0/22 blackhole;
route 207.46.0.0/19 blackhole;
route 206.209.107.0/24 blackhole;
route 206.191.224.0/19 blackhole;
route 206.138.168.0/21 blackhole;
route 205.143.44.0/23 blackhole;
route 205.135.212.0/24 blackhole;
route 205.135.211.0/24 blackhole;
route 204.239.54.0/24 blackhole;
route 204.209.219.0/24 blackhole;
route 204.152.140.0/23 blackhole;
route 204.152.95.0/24 blackhole;
route 204.95.96.0/20 blackhole;
route 204.79.252.0/24 blackhole;
route 204.79.195.0/24 blackhole;
route 204.79.179.0/24 blackhole;
route 204.79.135.0/24 blackhole;
route 204.14.180.0/22 blackhole;
route 203.84.134.0/23 blackhole;
route 203.32.10.0/23 blackhole;
route 203.32.8.0/24 blackhole;
route 203.21.152.0/23 blackhole;
route 203.12.31.0/24 blackhole;
route 202.130.203.0/24 blackhole;
route 202.89.224.0/21 blackhole;
route 202.22.173.0/24 blackhole;
route 202.14.81.0/24 blackhole;
route 202.12.70.0/24 blackhole;
route 199.255.253.0/24 blackhole;
route 199.242.48.0/21 blackhole;
route 199.242.32.0/20 blackhole;
route 199.233.162.0/24 blackhole;
route 199.189.38.0/24 blackhole;
route 199.189.36.0/23 blackhole;
route 199.118.0.0/16 blackhole;
route 199.103.122.0/24 blackhole;
route 199.103.90.0/23 blackhole;
route 199.65.251.0/24 blackhole;
route 199.65.247.0/24 blackhole;
route 199.65.243.0/24 blackhole;
route 199.65.40.0/24 blackhole;
route 199.65.30.0/23 blackhole;
route 199.65.29.0/24 blackhole;
route 199.65.27.0/24 blackhole;
route 199.60.28.0/24 blackhole;
route 199.50.0.0/16 blackhole;
route 199.38.175.0/24 blackhole;
route 199.30.16.0/20 blackhole;
route 199.26.109.0/24 blackhole;
route 199.21.128.0/24 blackhole;
route 199.0.184.0/23 blackhole;
route 198.252.211.0/24 blackhole;
route 198.245.174.0/24 blackhole;
route 198.206.164.0/24 blackhole;
route 198.200.130.0/24 blackhole;
route 198.185.5.0/24 blackhole;
route 198.180.97.0/24 blackhole;
route 198.180.95.0/24 blackhole;
route 198.91.39.0/24 blackhole;
route 198.52.0.0/24 blackhole;
route 198.51.0.0/24 blackhole;
route 198.49.8.0/24 blackhole;
route 198.47.13.0/24 blackhole;
route 198.22.19.0/24 blackhole;
route 198.8.73.0/24 blackhole;
route 195.114.140.0/24 blackhole;
route 195.105.26.0/24 blackhole;
route 195.85.113.0/24 blackhole;
route 195.8.43.0/24 blackhole;
route 194.180.131.0/24 blackhole;
route 194.150.192.0/24 blackhole;
route 194.110.197.0/24 blackhole;
route 194.50.21.0/24 blackhole;
route 194.49.206.0/24 blackhole;
route 194.45.24.0/23 blackhole;
route 194.44.235.0/24 blackhole;
route 194.41.22.0/24 blackhole;
route 193.221.113.0/24 blackhole;
route 193.189.114.0/23 blackhole;
route 193.149.64.0/19 blackhole;
route 193.135.41.0/24 blackhole;
route 193.134.96.0/24 blackhole;
route 193.53.155.0/24 blackhole;
route 193.17.104.0/23 blackhole;
route 193.8.43.0/24 blackhole;
route 192.243.86.0/23 blackhole;
route 192.197.157.0/24 blackhole;
route 192.195.98.0/24 blackhole;
route 192.160.194.0/24 blackhole;
route 192.131.254.0/24 blackhole;
route 192.102.165.0/24 blackhole;
route 192.100.128.0/22 blackhole;
route 192.100.112.0/20 blackhole;
route 192.100.104.0/21 blackhole;
route 192.94.1.0/24 blackhole;
route 192.84.160.0/23 blackhole;
route 192.71.41.0/24 blackhole;
route 192.64.201.0/24 blackhole;
route 192.48.225.0/24 blackhole;
route 192.40.76.0/22 blackhole;
route 192.28.24.0/23 blackhole;
route 192.12.20.0/24 blackhole;
route 192.0.58.0/23 blackhole;
route 191.232.0.0/13 blackhole;
route 188.94.190.0/24 blackhole;
route 185.242.139.0/24 blackhole;
route 185.242.137.0/24 blackhole;
route 185.236.221.0/24 blackhole;
route 185.222.140.0/22 blackhole;
route 185.211.208.0/24 blackhole;
route 185.209.208.0/23 blackhole;
route 185.195.244.0/23 blackhole;
route 185.187.123.0/24 blackhole;
route 185.187.104.0/23 blackhole;
route 185.154.80.0/22 blackhole;
route 185.149.54.0/24 blackhole;
route 185.135.57.0/24 blackhole;
route 185.117.230.0/24 blackhole;
route 185.117.183.0/24 blackhole;
route 185.117.95.0/24 blackhole;
route 185.116.168.0/23 blackhole;
route 185.115.155.0/24 blackhole;
route 185.113.189.0/24 blackhole;
route 185.90.154.0/24 blackhole;
route 185.76.37.0/24 blackhole;
route 185.52.203.0/24 blackhole;
route 185.36.58.0/24 blackhole;
route 185.34.250.0/24 blackhole;
route 185.12.10.0/24 blackhole;
route 178.255.242.0/24 blackhole;
route 178.251.21.0/24 blackhole;
route 176.116.123.0/24 blackhole;
route 173.241.37.0/24 blackhole;
route 173.200.0.0/16 blackhole;
route 172.208.0.0/13 blackhole;
route 172.192.0.0/12 blackhole;
route 172.128.0.0/10 blackhole;
route 170.176.205.0/24 blackhole;
route 170.165.0.0/16 blackhole;
route 170.114.56.0/23 blackhole;
route 170.114.47.0/24 blackhole;
route 170.114.39.0/24 blackhole;
route 170.88.84.0/23 blackhole;
route 170.88.82.0/23 blackhole;
route 170.62.37.0/24 blackhole;
route 170.22.156.0/23 blackhole;
route 170.22.154.0/23 blackhole;
route 169.138.0.0/16 blackhole;
route 168.137.64.0/21 blackhole;
route 168.62.0.0/15 blackhole;
route 168.61.0.0/16 blackhole;
route 167.253.12.0/22 blackhole;
route 167.231.0.0/16 blackhole;
route 167.186.0.0/16 blackhole;
route 167.162.0.0/16 blackhole;
route 167.105.0.0/16 blackhole;
route 167.92.212.0/24 blackhole;
route 167.92.211.0/24 blackhole;
route 167.21.152.0/21 blackhole;
route 167.21.32.0/21 blackhole;
route 166.98.6.0/23 blackhole;
route 165.17.0.0/16 blackhole;
route 165.15.0.0/16 blackhole;
route 164.75.132.0/23 blackhole;
route 164.75.128.0/22 blackhole;
route 163.199.84.0/23 blackhole;
route 163.57.0.0/16 blackhole;
route 162.254.247.0/24 blackhole;
route 162.254.245.0/24 blackhole;
route 161.221.4.0/24 blackhole;
route 161.221.0.0/22 blackhole;
route 161.220.0.0/16 blackhole;
route 161.195.155.0/24 blackhole;
route 161.195.152.0/24 blackhole;
route 161.195.96.0/21 blackhole;
route 161.157.0.0/16 blackhole;
route 161.131.217.0/24 blackhole;
route 160.234.0.0/16 blackhole;
route 160.207.0.0/16 blackhole;
route 160.4.0.0/16 blackhole;
route 159.128.0.0/16 blackhole;
route 159.105.18.0/24 blackhole;
route 158.158.0.0/16 blackhole;
route 158.86.95.0/24 blackhole;
route 158.86.31.0/24 blackhole;
route 158.53.0.0/16 blackhole;
route 158.24.0.0/16 blackhole;
route 158.23.0.0/16 blackhole;
route 157.252.0.0/16 blackhole;
route 157.176.0.0/16 blackhole;
route 157.172.0.0/16 blackhole;
route 157.95.0.0/16 blackhole;
route 157.81.0.0/16 blackhole;
route 157.56.0.0/16 blackhole;
route 157.55.0.0/16 blackhole;
route 157.31.0.0/16 blackhole;
route 156.23.0.0/16 blackhole;
route 156.20.22.0/23 blackhole;
route 155.231.208.0/23 blackhole;
route 155.62.0.0/16 blackhole;
route 155.60.240.0/23 blackhole;
route 155.60.232.0/23 blackhole;
route 155.60.224.0/23 blackhole;
route 152.138.0.0/16 blackhole;
route 152.38.156.0/24 blackhole;
route 151.206.0.0/16 blackhole;
route 151.129.0.0/16 blackhole;
route 150.212.0.0/16 blackhole;
route 150.171.0.0/16 blackhole;
route 149.204.0.0/16 blackhole;
route 149.198.0.0/16 blackhole;
route 149.175.0.0/16 blackhole;
route 149.1.0.0/16 blackhole;
route 148.53.0.0/16 blackhole;
route 148.7.0.0/16 blackhole;
route 147.243.0.0/16 blackhole;
route 147.214.0.0/16 blackhole;
route 147.145.0.0/16 blackhole;
route 147.140.72.0/23 blackhole;
route 145.219.24.0/21 blackhole;
route 145.219.20.0/22 blackhole;
route 145.219.18.0/23 blackhole;
route 145.190.0.0/15 blackhole;
route 145.132.0.0/15 blackhole;
route 145.130.0.0/16 blackhole;
route 145.129.0.0/16 blackhole;
route 145.83.4.0/22 blackhole;
route 145.46.160.0/23 blackhole;
route 144.203.156.0/24 blackhole;
route 144.203.152.0/23 blackhole;
route 143.241.0.0/16 blackhole;
route 143.226.0.0/16 blackhole;
route 143.209.0.0/16 blackhole;
route 142.147.61.0/24 blackhole;
route 142.147.54.0/24 blackhole;
route 142.0.188.0/23 blackhole;
route 141.193.248.0/24 blackhole;
route 139.188.0.0/16 blackhole;
route 138.239.0.0/16 blackhole;
route 138.213.0.0/16 blackhole;
route 138.128.250.0/23 blackhole;
route 138.105.0.0/16 blackhole;
route 138.91.0.0/16 blackhole;
route 138.32.110.0/24 blackhole;
route 138.32.108.0/23 blackhole;
route 137.162.0.0/16 blackhole;
route 137.135.0.0/16 blackhole;
route 137.116.0.0/15 blackhole;
route 137.70.154.0/24 blackhole;
route 137.70.152.0/24 blackhole;
route 135.254.0.0/15 blackhole;
route 135.246.0.0/15 blackhole;
route 135.244.0.0/16 blackhole;
route 135.240.0.0/15 blackhole;
route 135.236.0.0/15 blackhole;
route 135.232.0.0/14 blackhole;
route 135.230.0.0/16 blackhole;
route 135.228.0.0/15 blackhole;
route 135.226.0.0/16 blackhole;
route 135.224.0.0/15 blackhole;
route 135.222.0.0/16 blackhole;
route 135.220.0.0/15 blackhole;
route 135.185.0.0/16 blackhole;
route 135.183.0.0/16 blackhole;
route 135.171.0.0/16 blackhole;
route 135.149.0.0/16 blackhole;
route 135.130.0.0/16 blackhole;
route 135.119.0.0/16 blackhole;
route 135.116.0.0/16 blackhole;
route 135.93.0.0/16 blackhole;
route 135.88.0.0/16 blackhole;
route 135.86.0.0/16 blackhole;
route 135.85.0.0/16 blackhole;
route 135.56.6.0/24 blackhole;
route 135.56.4.0/24 blackhole;
route 135.56.2.0/24 blackhole;
route 135.56.0.0/24 blackhole;
route 135.18.0.0/16 blackhole;
route 135.13.0.0/16 blackhole;
route 135.6.0.0/15 blackhole;
route 135.4.0.0/16 blackhole;
route 134.170.0.0/16 blackhole;
route 134.149.0.0/16 blackhole;
route 134.138.0.0/16 blackhole;
route 134.112.0.0/16 blackhole;
route 134.33.0.0/16 blackhole;
route 132.245.0.0/16 blackhole;
route 132.220.0.0/16 blackhole;
route 132.196.0.0/16 blackhole;
route 132.164.0.0/16 blackhole;
route 131.253.128.0/17 blackhole;
route 131.253.62.0/23 blackhole;
route 131.253.61.0/24 blackhole;
route 131.253.32.0/20 blackhole;
route 131.253.24.0/21 blackhole;
route 131.253.12.0/22 blackhole;
route 131.253.8.0/24 blackhole;
route 131.253.6.0/24 blackhole;
route 131.253.5.0/24 blackhole;
route 131.253.1.0/24 blackhole;
route 131.189.0.0/16 blackhole;
route 131.163.0.0/16 blackhole;
route 131.145.0.0/16 blackhole;
route 130.213.0.0/16 blackhole;
route 130.131.0.0/16 blackhole;
route 130.115.248.0/21 blackhole;
route 130.107.0.0/16 blackhole;
route 130.33.0.0/16 blackhole;
route 129.135.0.0/16 blackhole;
route 129.35.19.0/24 blackhole;
route 128.251.0.0/16 blackhole;
route 128.203.0.0/16 blackhole;
route 128.94.0.0/16 blackhole;
route 128.85.0.0/16 blackhole;
route 128.24.0.0/16 blackhole;
+69281
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
route 103.246.200.0/22 blackhole;
route 74.82.64.0/19 blackhole;
route 68.171.224.0/19 blackhole;
route 203.104.152.0/22 blackhole;
route 203.104.144.0/21 blackhole;
route 203.104.128.0/20 blackhole;
route 193.105.213.36/30 blackhole;
route 185.104.45.0/24 blackhole;
route 178.239.88.0/21 blackhole;
+8343
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
route 103.28.54.0/24 blackhole;
route 103.10.124.0/23 blackhole;
route 45.121.184.0/24 blackhole;
route 208.78.164.0/22 blackhole;
route 208.64.200.0/22 blackhole;
route 205.196.6.0/24 blackhole;
route 192.69.96.0/22 blackhole;
route 185.25.182.0/23 blackhole;
route 162.254.196.0/22 blackhole;
route 162.254.195.0/24 blackhole;
route 162.254.192.0/23 blackhole;
route 155.133.248.0/21 blackhole;
route 155.133.246.0/24 blackhole;
route 155.133.244.0/24 blackhole;
route 155.133.240.0/23 blackhole;
route 155.133.238.0/24 blackhole;
route 155.133.236.0/23 blackhole;
route 155.133.232.0/24 blackhole;
route 155.133.230.0/24 blackhole;
route 155.133.228.0/24 blackhole;
route 155.133.224.0/22 blackhole;
route 146.66.155.0/24 blackhole;
route 146.66.152.0/24 blackhole;