bp驗證碼爆破插件二改
這不315晚會burp都上了嘛,蹭蹭時事熱點。
0x01 背景
最近遇到了很多驗證碼登錄口,驗證碼識別項目github上找了幾個,但是不是裝不上就是準確率不高的問題,后續也是慢慢修改出來了還算滿意的識別驗證碼插件。
原插件項目地址為:
https://github.com/c0ny1/captcha-killer
修改后的項目地址為:
https://github.com/f0ng/captcha-killer-modified
已征得原作者同意進行二開
0x02插件二次修改
直接下載原項目的jar包,按照項目說明進行使用,發現intruder無法進行爆破,有些情況也滿足不了需求,后面優化了一下,總共修改了兩處地方
修改點1
發現使用過程中出現了報錯

后面查了一下,原因是sun.misc.BASE64Encoder類不在jdk8+支持了,因為都在用新版burp了,而新版burp啟動需要高版本的jdk,這里我是jdk10啟動的burp,所以沒有sun.misc.BASE64Encoder類
下載源碼,修改java.utils.Util里的源碼如下:
// FileName: Util.java
public static String base64Encode(byte[] byteArray){
byte[] res = Base64.getEncoder().encode(byteArray);
String res2 = new String(res);
res2 = res2.replace(System.lineSeparator(),"");
return res2;
}
public static String base64Encode(String str){
byte[] b = new byte[]{};
try {
b = str.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] res = Base64.getEncoder().encode(b);
String res2 = new String(res);
//去除base64結果中的換行符,java base64編碼默認會76個字母換行一次
res2 = res2.replace(System.lineSeparator(),"");
return res2;
}
public static byte[] base64Decode(String str){
byte[] byteRes = new byte[]{};
byteRes = Base64.getDecoder().decode(str);
return byteRes;
}
再導入依賴
import java.util.Base64;
修改點2
這里還有個不是很完美的地方,只能識別響應包為圖片的驗證碼,但是遇到的真實環境中,也有一種data:image這種格式的驗證碼,這個插件就無法識別了,如下:

這里我也進行了一點修改,主要是響應包圖片的提取,主要修改如下:
在java.utils.Util包中增加函數
public static byte[] dataimgToimg(String str_img) throws IOException {
String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str_img);
if (m.find( )) {
str_img = m.group(0).replace("\"","").replace("&","") ;
}
byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1));
InputStream buffin = new ByteArrayInputStream(img);
return img;
}
public static boolean isImage(String str_img) throws IOException {
String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str_img);
if (m.find( )) {
str_img = m.group(0).replace("\"","").replace("&","") ;
}
byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1));
boolean isImg = false;
InputStream buffin = new ByteArrayInputStream(img);
BufferedImage image = ImageIO.read(buffin);
if(image == null){
isImg = false;
}else {
isImg = true;
}
return isImg;
}
修改后對項目進行編譯:
$ mvn package
識別的效果如下:

0x03 插件驗證碼識別庫的選擇
這里的接口大部分都需要付費,如baidu的接口每天只有300次,還有其他平臺的,每天有限制次數,不利于咱們測試呀

于是在我的不懈努力下,找到了一個開源識別驗證碼的項目,項目地址為:
https://github.com/sml2h3/ddddocr
所需要的環境支持如下:
python <= 3.9
Windows/Linux/Macos..
暫時不支持Macbook M1(X),M1(X)用戶需要自己編譯onnxruntime才可以使用
0x04 實際效果
安裝好ocr庫以后直接運行代碼:
# -*- coding:utf-8 -*-
# author:f0ngf0ng
import argparse
import ddddocr # 導入 ddddocr
from aiohttp import web
parser = argparse.ArgumentParser()
parser.add_argument("-p", help="http port",default="8888")
args = parser.parse_args()
ocr = ddddocr.DdddOcr()
port = args.p
async def handle_cb(request):
return web.Response(text=ocr.classification(img_base64=await request.text()))
app = web.Application()
app.add_routes([
web.post('/reg', handle_cb),
])
if __name__ == '__main__':
web.run_app(app, port=port)
$ python3 codereg.py
運行代碼界面

識別模板如下:
POST /reg HTTP/1.1
Host: 127.0.0.1:8888
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>
記得設置接口地址為:http://127.0.0.1:8888
點擊識別

即可識別出來驗證碼,準確率還不錯,在85%以上,重要的是免費,無限使用


關于captcha-killer的用法可以參考c0ny1師傅的文章
注:
- intruder的cookie要和captcha-killer的cookie一致
- intruder的線程調為1,最好加時間延遲參數
0x05 總結
- 最近一直在寫、改一些插件,發現burp對jdk版本高低太敏感了,有些時候特定的jdk版本會造成插件之間的沖突
- 修改插件感覺就像是站在巨人的肩膀上,不得不說c0ny1師傅的這個插件GUI頁面用起來都很舒服
- 學會開發很重要,可以自己進行自定義修改,不做百分百的腳本小子
0x06 附錄
https://github.com/c0ny1/captcha-killer [插件源項目]
https://gv7.me/articles/2019/burp-captcha-killer-usage/ [插件用法]
https://github.com/sml2h3/ddddocr [驗證碼識別項目]
https://github.com/PoJun-Lab/blaster [驗證碼登錄爆破]
https://github.com/f0ng/captcha-killer-modified [修改后的burp驗證碼識別插件]

浙公網安備 33010602011771號