mercredi 27 janvier 2010

Comment sécuriser son linux ? Netstat et lsof

Netstat


"Netstat" est un outil que l'on va utiliser du coté du défenseur. Il indique l'état des connexions réseaux en cours

netstat -taupe | sort



# netstat -taupe | sort

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode
PID/Program name
tcp 0 0 192.168.0.12:36932 ey-in-f191.1e100.n:http ESTABLISHED toto 11436
4490/firefox-bin
tcp 0 0 192.168.0.1:netbios-ssn *:* LISTEN root 6851 3997/smbd
tcp 0 0 192.168.0.:microsoft-ds *:* LISTEN root 6850 3997/smbd
tcp 0 0 localhost:microsoft-ds *:* LISTEN root 6852 3997/smbd
tcp 0 0 localhost:netbios-ssn *:* LISTEN root 6853 3997/smbd
udp 0 0 *:bootpc *:* root 6576 3856/dhcpcd
udp 0 0 *:netbios-dgm *:* root 6875 4007/nmbd
udp 0 0 *:netbios-ns *:* root 6874 4007/nmbd
udp 0 0 192.168.0.12:netbios-ns *:* root 6878 4007/nmbd

udp 0 0 192.168.0.1:netbios-dgm *:* root 6879 4007/nmb



Dans mon cas, je me rends compte que j'ai firefox qui a une connexion sur un site, que j'ai samba qui tourne et dhcp qui tourne.
Etant donné que j'utilise rarement samba, je le desactive :


# rc-update del samba
* 'samba' removed from the following runlevels: default
# /etc/init.d/samba stop
* samba -> stop: smbd
...
[ ok ]
* samba -> stop: nmbd ...



Pour avoir un poste plus sécurisé, une bonne approche consiste à désactiver ce qui est peu ou pas utilisé.
En effet, un pirate va tout d'abord scanner votre ordinateur puis si il detecte des ports ouvert, il va tenter de les hacker.Si ils sont fermés, vous ne craignez rien.


lsof

Cet outil va vous premettre de vérifiez ce qui est ouvert (tout est un fichier sur linux) sur votre ordinateur.


emerge sys-process/lsof

lsof -Pi | sort




# lsof -Pi | sort
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dhcpcd 3856 root 7u IPv4 6576 0t0 UDP *:68

firefox-b 4490 toto 13u IPv4 11436 0t0 TCP 192.168.0.12:36932->ey-in-f191.1e100.net:80
(ESTABLISHED)

nmbd 4007 root 6u IPv4 6874 0t0 UDP *:137

nmbd 4007 root 7u IPv4 6875 0t0 UDP *:138

nmbd 4007 root 8u IPv4 6878 0t0 UDP 192.168.0.12:137

nmbd 4007 root 9u IPv4 6879 0t0 UDP 192.168.0.12:138

smbd 3997 root 19u IPv4 6850 0t0 TCP 192.168.0.12:445 (LISTEN)

smbd 3997 root 20u IPv4 6851 0t0 TCP 192.168.0.12:139 (LISTEN)

smbd 3997 root 21u IPv4 6852 0t0 TCP localhost:445 (LISTEN)

smbd 3997 root 22u IPv4 6853 0t0 TCP localhost:139 (LISTEN)


nestat_wikipedia
netstat command

Aucun commentaire:

Enregistrer un commentaire


PoweredByGento