暴力破解之验证码识别

发布时间 2023-07-18 10:01:04作者: Xuno

背景

渗透测试过程中,现在验证码越来越多,这对测试的时候遇到的阻力不小,一位大佬给我安利了一个burp插件,Captcha-killer,可以自动对验证码进行识别,从而进行暴力破解

【文章中放置所有工具和脚本】

操作步骤

1、安装python模块

验证码识别是使用了python的开源验证码识别接口ddddocr模块

pip3 install ddddocr

还需要安装 aiohttp模块

pip3 install aiohttp

运行脚本

# -*- coding:utf-8 -*-
# author:f0ngf0ng
# @Date: 2022/3/11 下午1:44
import argparse
import ddddocr                       # 导入 ddddocr
from aiohttp import web
import base64

parser = argparse.ArgumentParser()

parser.add_argument("-p", help="http port",default="88")
args = parser.parse_args()
ocr = ddddocr.DdddOcr()
port = args.p

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

async def handle_cb(request):
    if request.headers.get('Authorization') != 'Basic ' + auth_base64:  # 可自定义auth认证,不需要注释就好
        return web.Response(text='Forbidden', status='403')
    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])

app = web.Application()
app.add_routes([
    web.post('/reg', handle_cb),
])

if __name__ == '__main__':
    web.run_app(app, port=port)

本地尝试一下运行脚本,出现下面信息,代表运行成功
在这里插入图片描述

2、安装Captcha-killer模块

下载好Captcha-Killer模块,

【下载不了的,我把安装包放到文末】

下载地址: https://github.com/f0ng/captcha-killer-modified
https://github.com/sml2h3/ddddocr

在这里插入图片描述安装插件
在这里插入图片描述

3、尝试进行验证码识别

打开一个存在验证码的网站
在这里插入图片描述
使用burp抓包,把验证码的包发到Captcha-killer模块在这里插入图片描述回到插件,点击获取验证码
在这里插入图片描述然后下面配置本地接口
在这里插入图片描述最后点击识别,出现结果

在这里插入图片描述
将需要爆破的数据包回到Intruder模块
在这里插入图片描述
选择通过扩展生成在这里插入图片描述选择生成器,这样就可以进行暴力破解啦
在这里插入图片描述