#!/usr/bin/python
import urllib
import re
IPT = "/sbin/iptables"
ippattern = re.compile(r'\d+\.\d+\.\d+\.\d+')
sock = urllib.urlopen("")
htmlsource = sock.read()
list = re.findall(ippattern,htmlsource)
sock.close()
outfile = open('freeip','w')
outfile.write(IPT + '-F free\n')
len = len(list)/3
for i in range(len):
outfile.write(IPT + '-A free -d ')
outfile.write(list[3*i] + '/' + list[3*i+2] + ' -j ACCEPT\n')
outfile.close()
08-05-25:
今天测试的时候,发现那个页面的格式已经发生了变化,所以只好修改一下这个脚本:
import urllib
import re
IPT = "/sbin/iptables"
sock = urllib.urlopen("")
htmlsource = sock.read()
format = re.compile(r'')
html = format.sub('',htmlsource)
ippattern = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
list = re.findall(ippattern,html)
sock.close()
outfile = open('freeip','w')
outfile.write(IPT + '-F free\n')
len = len(list)/3
for i in range(len):
outfile.write(IPT + '-A free -d ')
outfile.write(list[3*i] + '/' + list[3*i+2] + ' -j ACCEPT\n')
outfile.close()
阅读(2344) | 评论(0) | 转发(0) |