Created
March 11, 2015 15:03
-
-
Save kanazux/8d0259d8e8acb06b5487 to your computer and use it in GitHub Desktop.
get the country cidrs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# -*- coding: UTF-8 -*- | |
# | |
# Autor: Silvio Giunge a.k.a kanazuchi | |
# <[email protected]> | |
# | |
import bs4 | |
import requests | |
URL='http://www.iwik.org/ipcountry/' | |
read_cidr = bs4.BeautifulSoup(requests.get(URL).content) | |
for pais in [ x['href'] for x in read_cidr.findAll('a') if "cidr" in x['href'] and not 'http' in x['href'] ]: | |
cidrs = filter(None, requests.get("{}/{}".format(URL,pais)).content).split('\n') | |
for net in cidrs: | |
if "#" not in net and net != '': | |
print >> open("{}_cidrs_chains.txt".format(pais.split('.')[0]),"a"), \ | |
"add chain=input action=drop src-address-list={}".format(net) | |
print >> open("{}_cidrs_list.txt".format(pais.split('.')[0]),"a"), net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment