目錄
一、目標(biāo)1:理清邏輯
二、目標(biāo)2:將每一步用代碼進(jìn)行表示
三、網(wǎng)絡(luò)安全O
一、目標(biāo)1:理清邏輯
模擬登錄的基本流程
1、進(jìn)入入口程序
2、讀取目標(biāo)URL
3、請(qǐng)求加上線程
4、確定請(qǐng)求數(shù)據(jù)包
5、請(qǐng)求格式的確認(rèn)
6、數(shù)據(jù)的處理與判斷
二、目標(biāo)2:將每一步用代碼進(jìn)行表示
(順序會(huì)進(jìn)行標(biāo)號(hào))
對(duì)于不同的站點(diǎn)的登錄
需要對(duì)數(shù)據(jù)包、請(qǐng)求格式、邏輯處理等進(jìn)行適當(dāng)?shù)男薷?/p>
admin_login.py
?import csv
import requests
import threading
def admin_login(urls):
#④確定請(qǐng)求數(shù)據(jù)包
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.79',
'Content-Type': 'application/json',
}
data = {
"accessKey": "admin",
"secretKey": "admin"
}
try:
#⑤請(qǐng)求格式的確認(rèn)
res = requests.post(url=urls, headers=headers, json=data, timeout=60)
#⑥數(shù)據(jù)的處理與判斷
if res.status_code == 204:
print(f"\033[32m[+]{urls} is 弱口令登錄!\033[0m")
with open('ip_login.csv', mode='a', encoding='utf-8', newline='') as f:
csv_w = csv.writer(f)
csv_w.writerow([urls])
else:
print(f"\033[34m[-]{urls} pass.\033[0m")
except Exception as e:
print("錯(cuò)誤為"+str(e))
#①進(jìn)入入口程序
if __name__ == '__main__':
threads = []
#②讀取目標(biāo)URL
with open("ips.csv", mode="r") as f:
for u in f:
url = u.replace("\n", "")
urls = url + "/api/v1/login"
#③函數(shù)請(qǐng)求加上線程
thread = threading.Thread(target=admin_login, args=(urls,))
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
?
三、網(wǎng)絡(luò)安全O
README.md · 書半生/網(wǎng)絡(luò)安全知識(shí)體系-實(shí)戰(zhàn)中心 - 碼云 - 開源中國(guó) (gitee.com)https://gitee.com/shubansheng/Treasure_knowledge/blob/master/README.md文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-609578.html
GitHub - BLACKxZONE/Treasure_knowledgehttps://github.com/BLACKxZONE/Treasure_knowledge文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-609578.html
到了這里,關(guān)于【網(wǎng)絡(luò)安全帶你練爬蟲-100練】第15練:模擬用戶登錄的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!