Skip to content

Commit

Permalink
Update codereg.py
Browse files Browse the repository at this point in the history
  • Loading branch information
f0ng authored Jan 4, 2024
1 parent 89e86c0 commit 504f656
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions codereg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ddddocr # 导入 ddddocr
from aiohttp import web
import base64

print("欢迎使用captcha-killer-modified服务端脚本,项目地址:https://github.com/f0ng/captcha-killer-modified\n谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口:https://yescaptcha.com/i/bmHz3C\n\n")
parser = argparse.ArgumentParser()

parser.add_argument("-p", help="http port",default="8888")
Expand All @@ -14,21 +14,61 @@
port = args.p

auth_base64 = "f0ngauth" # 可自定义auth认证

async def handle_cb(request):
if request.headers.get('Authorization') != 'Basic ' + auth_base64: # 可自定义auth认证,不需要注释就好
# 识别常规验证码
async def handle_cb2(request):
if request.headers.get('Authorization') != 'Basic ' + auth_base64:
return web.Response(text='Forbidden', status='403')
print(await request.text())
# print(await request.text())
img_base64 = await request.text()
img_bytes = base64.b64decode(img_base64)
# return web.Response(text=ocr.classification(img_bytes)[0:4]) 验证码取前四位
# return web.Response(text=ocr.classification(img_bytes)[0:4].replace("0","o")) 验证码取前四位、验证码中的0替换为o
return web.Response(text=ocr.classification(img_bytes)[0:4])
res = ocr.classification(img_bytes)
print(res)

return web.Response(text=ocr.classification(img_bytes)[0:10])

# 识别算术验证码
async def handle_cb(request):
zhi = ""
if request.headers.get('Authorization') != 'Basic ' + auth_base64:
return web.Response(text='Forbidden', status='403')
# print(await request.text())
img_base64 = await request.text()
img_bytes = base64.b64decode(img_base64)
res = ocr.classification(img_bytes).replace("=","").replace("?","")
print(res)
if'+'in res:
zhi = int(res.split('+')[0])+int(res.split('+')[1][:-1])
print(zhi)
return web.Response(text=str(zhi))
elif'-'in res:
zhi = int(res.split('-')[0])-int(res.split('-')[1][:-1])
print(zhi)
return web.Response(text=str(zhi))
elif'*'in res:
zhi = int(res.split('*')[0])*int(res.split('*')[1][:-1])
print(zhi)
return web.Response(text=str(zhi))
elif 'x' in res:
zhi = int(res.split('x')[0])*int(res.split('x')[1][:-1])
print(zhi)
return web.Response(text=str(zhi))
elif '/'in res:
zhi = int(res.split('/')[0])/int(res.split('/')[1][:-1])
return web.Response(text=str(zhi))
else:
return web.Response(text=res)



app = web.Application()
app.add_routes([
web.post('/reg', handle_cb),
web.post('/reg2', handle_cb), # 识别算数验证码
web.post('/reg', handle_cb2), # 识别常规验证码
])

if __name__ == '__main__':

web.run_app(app, port=port)

0 comments on commit 504f656

Please sign in to comment.