25验证码无JS加密的滑块验证码
19
猿人学练习/25验证码无JS加密的滑块验证码/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 知识点: 2张图片对比,目标检测
|
||||||
|
|
||||||
|
## 解题思路一
|
||||||
|
|
||||||
|
比较两张图片是否相似,如果相似并返回缺口位置
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
对比
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
很容易就可以得到缺口坐标
|
||||||
|
|
||||||
|
## 解题思路二
|
||||||
|
|
||||||
|
目标检测yolov5框架
|
||||||
|
|
||||||
|
https://github.com/luzhisheng/js_reverse/tree/master/ayf_ocr/08%E6%95%B0%E6%8D%AE%E6%A0%87%E6%B3%A8-VOC%E6%95%B0%E6%8D%AE%E9%9B%86-%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8B%E6%A1%86%E6%9E%B6
|
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img/1.jpg
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img/2.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/1.jpg
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/10.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/11.jpg
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/12.jpg
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/2.jpg
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/3.jpg
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/4.jpg
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/5.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/6.jpg
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/7.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/8.jpg
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
猿人学练习/25验证码无JS加密的滑块验证码/img_yuan/9.jpg
Normal file
After Width: | Height: | Size: 6.1 KiB |
@ -1,82 +1,82 @@
|
|||||||
from 滑动验证码 import disparity
|
|
||||||
import requests
|
import requests
|
||||||
import base64
|
import base64
|
||||||
|
from PIL import Image
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"accept": "application/json, text/javascript, */*; q=0.01",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
|
" Chrome/94.0.4606.71 Safari/537.36",
|
||||||
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"origin": "https://www.python-spider.com",
|
||||||
|
"referer": "https://www.python-spider.com/api/challenge25",
|
||||||
|
"x-requested-with": "XMLHttpRequest",
|
||||||
|
"cookie": "sessionid=dxebgqqn0x78r21nk6w19umv3je6pb0n;"
|
||||||
|
}
|
||||||
|
ses = requests.session()
|
||||||
|
|
||||||
|
|
||||||
def challenge25_check_verify(distant):
|
def get_slider_offset_method(ori_path, cut_pic_path):
|
||||||
url = "https://www.python-spider.com/api/challenge25CheckVerify"
|
"""比较两张图片是否相似,如果相似并返回缺口位置"""
|
||||||
payload = f"distant={distant}"
|
pic_img = Image.open(ori_path)
|
||||||
headers = {
|
cut_img = Image.open(cut_pic_path)
|
||||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
array1 = np.array(pic_img)
|
||||||
'cookie': 'sessionid=y3o4ap05sxbaa9oujc6yr63wsgydyd7x'
|
array2 = np.array(cut_img)
|
||||||
}
|
height, width, _ = array1.shape
|
||||||
response = requests.request("POST", url, headers=headers, data=payload)
|
threshold = 40
|
||||||
return response.json()
|
if np.sum(array1 == array2) > 80000: # 判断两张图片相似
|
||||||
|
for x in range(10, width - 10): # 从左往右
|
||||||
|
for y in range(5, height - 10): # 从上往下
|
||||||
|
pixel1 = pic_img.load()[x, y]
|
||||||
|
pixel2 = cut_img.load()[x, y]
|
||||||
|
if abs(pixel1[0] - pixel2[0]) < threshold and abs(pixel1[1] - pixel2[1]) < threshold and abs(
|
||||||
|
pixel1[2] - pixel2[2]) < threshold:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
def code_value():
|
def request_img():
|
||||||
url = "https://www.python-spider.com/api/challenge25verify"
|
url = f"https://www.python-spider.com/api/challenge25verify"
|
||||||
payload = {}
|
res = ses.get(url, headers=headers, timeout=10)
|
||||||
headers = {
|
with open(r"./img1.jpg", "wb") as f:
|
||||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,'
|
f.write(base64.b64decode(res.json()["img1"]))
|
||||||
'*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
for item in os.listdir("./img_yuan"):
|
||||||
'cookie': 'sessionid=y3o4ap05sxbaa9oujc6yr63wsgydyd7x;',
|
ori_path = os.path.join(os.path.abspath("./img_yuan"), item)
|
||||||
'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
|
offset = get_slider_offset_method(ori_path, "./img1.jpg")
|
||||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
|
if offset:
|
||||||
' Chrome/112.0.0.0 Safari/537.36'
|
form_data = {"distant": offset}
|
||||||
}
|
res = ses.post("https://www.python-spider.com/api/challenge25CheckVerify", data=form_data, headers=headers,
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
timeout=10)
|
||||||
img1 = response.json().get('img1')
|
print("滑块识别率:", offset, res.text)
|
||||||
img2 = response.json().get('img2')
|
if res.json()["success"]:
|
||||||
img1 = base64.urlsafe_b64decode(img1)
|
return True
|
||||||
img2 = base64.urlsafe_b64decode(img2)
|
|
||||||
with open('img/background.png', 'wb') as f:
|
|
||||||
f.write(img1)
|
|
||||||
with open('img/target.png', 'wb') as f:
|
|
||||||
f.write(img2)
|
|
||||||
coordinate = disparity()
|
|
||||||
distant = coordinate.get('target')[0]
|
|
||||||
res = challenge25_check_verify(distant)
|
|
||||||
print(res)
|
|
||||||
rate = res.get('rate')
|
|
||||||
return rate
|
|
||||||
|
|
||||||
|
|
||||||
def challenge25(page):
|
def loop_page(page):
|
||||||
if page != 1:
|
count = 0
|
||||||
rate = code_value()
|
if page > 1:
|
||||||
if rate != '100.00%':
|
if not request_img():
|
||||||
return False
|
return
|
||||||
|
form_data = {"page": str(page)}
|
||||||
url = "https://www.python-spider.com/api/challenge25"
|
res = ses.post("https://www.python-spider.com/api/challenge25", data=form_data, headers=headers, timeout=10)
|
||||||
payload = f"page={page}"
|
print(res.status_code, res.text)
|
||||||
headers = {
|
for row in res.json()['data']:
|
||||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
count += int(row['value'].strip())
|
||||||
'cookie': 'sessionid=y3o4ap05sxbaa9oujc6yr63wsgydyd7x;'
|
return count
|
||||||
}
|
|
||||||
response = requests.request("POST", url, headers=headers, data=payload)
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
data_num = 0
|
s = 0
|
||||||
page = 1
|
for page in range(1, 101):
|
||||||
while True:
|
s_p = loop_page(page)
|
||||||
res_dict = challenge25(page)
|
if not isinstance(s_p, int):
|
||||||
if not res_dict:
|
|
||||||
print(f"验证码没有通过-{page}")
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
print(f"验证码通过{res_dict}-{page}")
|
|
||||||
data_list = res_dict.get('data')
|
|
||||||
for data in data_list:
|
|
||||||
data_num += int(data.get('value'))
|
|
||||||
print(data_num)
|
|
||||||
page += 1
|
|
||||||
|
|
||||||
if page == 101:
|
|
||||||
break
|
break
|
||||||
|
s += s_p
|
||||||
|
print(s)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run()
|
run()
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import ddddocr
|
|
||||||
|
|
||||||
|
|
||||||
def disparity():
|
|
||||||
slide = ddddocr.DdddOcr(det=False, ocr=False)
|
|
||||||
with open('./img/target.png', 'rb') as f:
|
|
||||||
target_bytes = f.read()
|
|
||||||
with open('./img/background.png', 'rb') as f:
|
|
||||||
background_bytes = f.read()
|
|
||||||
coordinate = slide.slide_match(target_bytes, background_bytes, simple_target=True)
|
|
||||||
return coordinate
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print(disparity())
|
|