Salve a tutti,
ieri al incontro Chris mi ha mostrato un sistema molto bello per analizzare quali ports sono aperti sulla propria macchina. Datoche l'ho trovato molto utile, scrivo questa mail con un piccolo riassunto alla lista.
-------------------------------- -- Step by step description --------------------------------
Farsi dare una lista dei ports aperti e in ascolto:
[root@inspiron root]# nmap localhost -p 1-65535
Starting nmap V. 2.54BETA22 ( www.insecure.org/nmap/ ) Interesting ports on inspiron.prodata.it (127.0.0.1): (The 65522 ports scanned but not shown below are in state: closed) Port State Service 22/tcp open ssh 25/tcp open smtp 111/tcp open sunrpc 139/tcp open netbios-ssn 515/tcp open printer 3050/tcp open unknown 3060/tcp open unknown 5801/tcp open vnc 5901/tcp open vnc-1 6000/tcp open X11 6001/tcp open X11:1 32768/tcp open unknown 32771/tcp open sometimes-rpc5
Nmap run completed -- 1 IP address (1 host up) scanned in 3 seconds
E per vedere chi usa un certo port, si pu``o usare l'utility strautile lsof, che fa il listing dei files aperti nel sistema. Ad esempio, per vedere, chi usa il port 30768
[root@inspiron root]# lsof | grep 32768 rpc.statd 647 root 5u IPv4 915 UDP *:32768 rpc.statd 647 root 6u IPv4 918 TCP *:32768
E nel DB del RPM si puo´ poi leggere informazioni su rpc.statd:
[root@inspiron root]# rpm -qf `which rpc.statd` | xargs rpm -qi Name : nfs-utils Relocations: (not relocateable) Version : 0.3.1 Vendor: Red Hat, Inc. Release : 13.7.2.1 Build Date: Mit 17 Okt 2001 22:09:10 CEST Install date: Mit 27 Feb 2002 00:16:55 CET Build Host: stripples.devel.redh at.com Group : System Environment/Daemons Source RPM: nfs-utils-0.3.1-13.7.2.1 .src.rpm Size : 518474 License: GPL Packager : Red Hat, Inc. http://bugzilla.redhat.com/bugzilla Summary : NFS utilities and supporting daemons for the kernel NFS server. Description : The nfs-utils package provides a daemon for the kernel NFS server and related tools, providing a much higher level of performance than the traditional Linux NFS server used by most users.
This package also contains the showmount program. Showmount queries the mount daemon on a remote host for information about the NFS (Network File System) server on the remote host.
-------------------------------- -- WARNINGS --------------------------------
Esperimentando mi sono accorto, che per certi ports, ad esempio 6000 (X11) "lsof | grep 6000" non mi dava alcun risultato. Poi mi sono accorto che lsof visualizza i nomi per i ports, se questi sono nel /etc/services e percio´ si deve eseguire "lsof | grep -i x11". L'opzione -i (ignorecase) e´ sempre consigliabile ;)
-------------------------------- -- SUMMARY COMMANDS -------------------------------- nmap - Portscanner lsof - Mostra i files aperti nel sistema
In oltre Chris mi ha svelato l'opzione w per il commando ps. Probabilmente molti hanno notato che ps formatta l'output per un term con un massimo di 80 colonne. Cosa carina, ma anche molto noiosa se si cerca dei commandi. Coll'opzione w si disattiva questa formatizzazione.
ps auxw -> righe piu´ lunghe
o
ps auxww -> ancora piu´ lunghe
Grazie Chrism!!
Patrick
* Patrick Ohnewein (pohnewein@prodata.it) wrote: <snip>
o anche :
lsof -nPsli TCP
Saluti, Michele
Dal output di netstat pero´ non riesco a determinare l'origine. lsof invece mi da´ un output piu´ utile:
Come esempio il port per firebird (interbase):
[root@inspiron root]# lsof -nPsli TCP | grep 3050 ibserver 751 0 0u IPv4 989 TCP *:3050 (LISTEN) ibserver 752 0 0u IPv4 989 TCP *:3050 (LISTEN) ibserver 755 0 0u IPv4 989 TCP *:3050 (LISTEN) [root@inspiron root]# netstat -a | grep -i :3050 [root@inspiron root]# cat /etc/services | grep 3050 gds_db 3050/tcp # InterBase Database Remote Protocol [root@inspiron root]# netstat -a | grep -i :gds_db tcp 0 0 *:gds_db *:* LISTEN
lsof mi fa vedere il processo ibserver netstat non mi indica nulla in riguardo.
Hobs Sorry! RTFM 2 ME ;)
esiste l'opzione --program :
[root@inspiron root]# netstat -a --program | grep -i :gds_db tcp 0 0 *:gds_db *:* LISTEN 751/ibserver
ritiro tutto :)
byez Patrick
thomas.pircher@gmx.net wrote:
Michele Baldessari wrote:
o anche : lsof -nPsli TCP
oppure netstat
c'e' l'imbarazzo della scelta :-) saluti Thomas _______________________________________________ https://secure.pcnotruf.net/mailman/listinfo/lugbz-list LUGBZ is pcn.it-powered
To: lugbz-list@lugbz.org
* Patrick Ohnewein (pohnewein@prodata.it) wrote:
esiste l'opzione --program :
[root@inspiron root]# netstat -a --program | grep -i :gds_db tcp 0 0 *:gds_db *:* LISTEN 751/ibserver
ritiro tutto :)
netstat -taupen e' probabilmente quello che piu' ti puo' interessare.
Saluti, Michele
Optiondiscovery ;)
Ok netstat sembra avere +o- la stessa potenza di lsof. Se vogliamo trovare una distinzione,possiamo dire che lsof mostra informazioni su tutti i files del sistema. netstat invece e´ specializzato su connessioni di rete.
Grazie a tutti!
Patrick
baldessari@tiscalinet.it wrote:
- Patrick Ohnewein (pohnewein@prodata.it) wrote:
esiste l'opzione --program :
[root@inspiron root]# netstat -a --program | grep -i :gds_db tcp 0 0 *:gds_db *:* LISTEN 751/ibserver
ritiro tutto :)
netstat -taupen e' probabilmente quello che piu' ti puo' interessare.
Saluti, Michele _______________________________________________ https://secure.pcnotruf.net/mailman/listinfo/lugbz-list LUGBZ is pcn.it-powered
To: lugbz-list@lugbz.org