验证码拦截绕过
前言
介绍了验证码自动识别项目及burpsuite插件对接项目的方法。
通用验证码识别
验证码识别项目使用ddddocr项目,项目地址https://github.com/sml2h3/ddddocr。装好需要的包后验证是否正常工作。
import ddddocr
ocr = ddddocr.DdddOcr(beta=True)
with open("test.png", 'rb') as f:
image = f.read()
res = ocr.classification(image)
print(res)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114141823786-3.png?raw=true)
验证码识别项目对接burpsuite
给burpsuite安装插件对接验证码识别接口。项目地址https://github.com/f0ng/captcha-killer-modified。此项目提供的codereg.py在我环境上无法正常工作,可能是python版本问题(我的机器是python3.8)或者是包版本问题。修改了一下代码。运行代码后在burpsuite中抓包使用插件即可,看图。
from aiohttp import web
import base64
import ddddocr
ocr = ddddocr.DdddOcr()
#如果需要使用装饰器来路由uri的话,需要创建RouteTableDef类的对象来获取一个装饰器
routes = web.RouteTableDef()
@routes.get("/get")
async def get_req(request):
print("this is get req")
return web.Response(text="Hello World")
@routes.post("/reg")
async def post_req(request):
print(await request.text())
img_base64 = await request.text()
img_bytes = base64.b64decode(img_base64)
return web.Response(text=ocr.classification(img_bytes))
@routes.route("*", "/all")#支持GET/POST/PUT/DELETE
async def all_handler(request):
print(request.method)
print(type(request))
print("handle all request")
return web.Response(text="All")
def main():
pass
if __name__ == '__main__':
app = web.Application()
#如果不使用装饰器的话, 添加如下代码
# app.add_routes([web.get("/get", get_req),
# web.post("/post",post_req)])
#如果使用装饰器,则添加如下一行
app.add_routes(routes)
web.run_app(app, port=8900)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114144650636-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114142538121-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114142718525-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114142905907-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114143246183-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114143352399-3.png?raw=true)
POST /reg HTTP/1.1
Host: 192.168.31.210:8900
Connection: close
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: none
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Content-Type: application/x-www-form-urlencoded
Content-Length: 55
<@BASE64><@IMG_RAW></@IMG_RAW></@BASE64>
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114143636296-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114143833939-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114143953727-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114144036141-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114144212976-3.png?raw=true)
![](https://github.com/kouyou-momiji/easyimage-image/blob/master/image-20221114144443887-3.png?raw=true)