网址:https://captcha.luosimao.com/demo
啥价螺丝帽验证码???一开始我也不知道,看k哥发了个动态就学了一下。
个人总结:难点在图片还原。
要或者图片的坐标的话,最简单快速的方式:xyolo,3个分类,随便标注几十张图片多半就够了。
要放假了,坐不住了呀,哎。今天这个B班就上到这里吧。领导让玩深度学习,好想吐槽,我不想做这种。
看下效果图:
打工苦,打工累,打工还得教学费,咋办哟,不想打工了,国庆回来要好好考虑考虑了。
对了对了把代码给大家学习学习,仅供学习。
# -*- coding:utf-8 -*-
'''
author:qin
q:2695733665
v:15702312233
'''
import re
import requests,urllib3
import time,hashlib
from PIL import Image
from loguru import logger
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import base64,random
urllib3.disable_warnings()
from urllib.parse import urlencode
def AES_encrypt(key,iv,plaintext):
# 设置加密密钥和明文
key = key.encode() # 密钥长度必须为16、24或32字节
iv = iv.encode() # IV(初始化向量)
plaintext = plaintext.encode()
# 创建 AES 加密器对象
cipher = AES.new(key, AES.MODE_CBC, iv)
# 使用 ZeroPadding 进行填充
padded_plaintext = pad(plaintext, AES.block_size)
# 执行加密
ciphertext = cipher.encrypt(padded_plaintext)
# 将加密结果转换为 Base64 字符串
base64_ciphertext = base64.b64encode(ciphertext).decode()
# 输出加密结果
# logger.info(f"加密结果:{base64_ciphertext}")
# # 解密过程
# decipher = AES.new(key, AES.MODE_CBC, iv)
#
# # 将 Base64 字符串解码并解密密文
# decoded_ciphertext = base64.b64decode(base64_ciphertext)
# plain = unpad(decipher.decrypt(decoded_ciphertext), AES.block_size)
#
# # 输出解密结果
# print("解密结果:", plain.decode())
return base64_ciphertext
def randomcode():
random_num = random.random()
number=int(random_num * (36**9))
alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'
if number == 0:
return '0'
base36 = ''
while number != 0:
number, i = divmod(number, 36)
base36 = alphabet[i] + base36
return '_'+base36[:9]
def reloadImg(imgPath,section):
image = Image.open(imgPath)
new_img = Image.new("RGBA", (300, 160))
for index in range(len(section)):
x = int(section[index][0])
y = int(section[index][1])
slice_ = image.crop(box=(x, y, x + 20, y + 80))
new_img.paste(slice_, box=(index % 15 * 20, 80 if index > 14 else 0))
new_img.save("1.png")
def verify_code():
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Pragma": "no-cache",
"Referer": "https://spidertools.cn/",
"Host":"captcha.luosimao.com",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"sec-ch-ua": "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\""
}
session =requests.Session()
session.verify=False
resp_demo = session.get(url = "https://captcha.luosimao.com/demo/", headers=headers)
site_key=re.findall('data-site-key="(.*?)"',resp_demo.text)[0]
i='_amylgm0g8' or randomcode()
logger.info(f'site_key:{site_key},i:{i}')
params = {
"k": site_key,
"l": "zh-cn",
"s": "normal",
"i": i
}
widget_url="https://captcha.luosimao.com/api/widget?"+urlencode(params)
resp_widget = session.get(url = widget_url, headers=headers)
token=re.findall('data-token="(.*?)"',resp_widget.text)[0]
data_pass=re.findall('data-pass="(.*?)"',resp_widget.text)[0]
logger.info(f'token:{token},data_pass:{data_pass}')
bg_text=f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36||{token}||1920:1080||win32||webkit"
b_text=f"{random.randint(60,200)},{random.randint(0,3)}:{int(time.time()*1000)}||{random.randint(60,200)},{random.randint(10,20)}:{int(time.time()*1000)+random.randint(60,200)}"
headers = {
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-type": "application/x-www-form-urlencoded",
"Origin": "https://captcha.luosimao.com",
"Pragma": "no-cache",
"Referer": widget_url,
"Host": "captcha.luosimao.com",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
"sec-ch-ua": "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\""
}
params = {
"k": site_key,
"l": "zh-cn"
}
key = 'c28725d494c78ad782a6199c341630ee'
iv = '2801003954373300'
data = {
"bg": AES_encrypt(key,iv,bg_text),
"b": AES_encrypt(key,iv,b_text)
}
request_url="https://captcha.luosimao.com/api/request?"+urlencode(params)
request_resp = session.post(url = request_url, headers=headers, data=data).json()
w=re.findall('(.*?)',request_resp['w'])[0].split(',')
s=request_resp['s']
h=request_resp['h']
key=i=request_resp['i']
logger.info(f'w:{w},s:{s}')
logger.info(f'h:{h},key:{key}')
params = {
"s": s,
"i": i,
"l": "zh-cn"
}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'Referer': 'https://captcha.luosimao.com/demo/',
'Sec-Fetch-Dest': 'iframe',
"Host":"captcha.luosimao.com",
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
'sec-ch-ua': '"Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
frame_url="https://captcha.luosimao.com/api/frame?"+urlencode(params)
resp_frame = session.get(url=frame_url, headers=headers)
captchaImage=eval(str(re.findall('captchaImage =(.*?);',resp_frame.text)[0]).replace('p:','"p":').replace('l:','"l":'))
logger.info(captchaImage)
imgUrl=captchaImage['p'][0]
imgbytes=requests.get(url=imgUrl).content
imgPath="1.jpg"
with open(imgPath, "wb")as f:
f.write(imgbytes)
section=captchaImage['l']
reloadImg(imgPath,section)
headers = {
'Accept': '*/*',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-type': 'application/x-www-form-urlencoded',
"Referer": frame_url,
'Origin': 'https://captcha.luosimao.com',
'Pragma': 'no-cache',
"Host": "captcha.luosimao.com",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
'sec-ch-ua': '"Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
point_list=[]
for i in range(1,4):
logger.info(f'输入第{4-i}个{w[3-i]}图像的纵横坐标')
point = str(input())
point_list.append(point)
points='#'.join(point_list)
logger.info(f'points:{points}')
data = {
"h": h,
"v": AES_encrypt(key,iv,points).replace('+','-').replace('/','_').replace('=',''),
"s": hashlib.md5(points.encode()).hexdigest()
}
logger.info(data)
response = session.post(url = "https://captcha.luosimao.com/api/user_verify", headers=headers, data=data)
logger.debug(response.json())
if __name__ == '__main__':
verify_code()
好了好了就这样了,提前祝大家国庆-中秋快乐,出去玩的小伙伴也要注意安全。
完事儿了哦,大表哥们。有问题可以给我留言。
记得关注我们的作坊:图腾视觉开放平台-高速、稳定、易用的webapi接口调用 (现已合作大佬超乎你想象)图腾视觉-OCR识别平台
提示:有问题的小伙伴可以私信讨论。
重要的事儿说三遍 :若是侵权请联系作者删,若是侵权请联系作者删,若是侵权请联系作者删。