Whackermelon
notes / elevation-de-privileges / enumeration-commandes-variantes

Énumération — commandes & variantes

sommaire

Variantes utiles (ss, find, grep, systemctl, /proc, /dev/tcp)

ss / netstat (sockets)

ss -tlnp          # TCP en ecoute + process
ss -ulnp          # UDP en ecoute
ss -xlp           # sockets Unix en ecoute
ss -tnp           # connexions TCP etablies
ss -tlnp | grep 9100    # un port precis
# equivalent : netstat -tlnp / -xlp

find

find / -type s 2>/dev/null              # sockets Unix
find / -perm -4000 -type f 2>/dev/null  # binaires SUID
find / -perm -2000 -type f 2>/dev/null  # SGID
find / -writable -type d 2>/dev/null    # dossiers inscriptibles
find / -iname '*api*' 2>/dev/null    # par nom (insensible casse)
find / -newermt '2024-01-01' 2>/dev/null # modifies apres une date
find / -name '*.py' -exec grep -l MOT {} \; 2>/dev/null

grep

grep -rIl 'motif' /chemin 2>/dev/null   # -r recursif, -I ignore binaires, -l liste fichiers
grep -riE 'password|secret|api[_-]?key' /var/www 2>/dev/null  # -i insensible, -E regex etendue
grep -oE 'motif' fichier      # -o : seulement la correspondance
grep -v motif                 # inverser (exclure)
grep -A3 -B2 -C2 motif        # contexte apres / avant / autour

services / processus / /proc

systemctl status 'nom*'                 # etat + PID + ExecStart
systemctl cat nom.service               # le unit complet
systemctl list-units --type=service --state=running
ps aux | grep -i nom
pgrep -af nom                           # PID + ligne de commande
ls -l /proc/<PID>/cwd /proc/<PID>/exe   # repertoire de travail + binaire
tr '\0' ' ' < /proc/<PID>/cmdline; echo # arguments exacts
cat /proc/<PID>/environ | tr '\0' '\n'  # variables d'env (si accessible)

Se connecter SANS netcat (bash /dev/tcp)

# envoi simple :
{ printf 'DONNEES'; } > /dev/tcp/127.0.0.1/9100
# envoi + lecture de la reponse :
exec 3<>/dev/tcp/127.0.0.1/9100
printf 'REQUETE\r\n' >&3
timeout 2 cat <&3
exec 3>&-

Analyse de source & exploitation binaire

bandit fichier.py            # SAST Python (shell=True, injections...)
semgrep --config auto .      # SAST multi-langages
pwn checksec ./bin           # protections ELF
pwn cyclic 200               # motif pour offset de buffer overflow
pwn template ./bin           # squelette d'exploit pwntools