Viva Facebook! (ovvero storia di una serata milanese di 10 anni fa).

Thursday, 23 October 08

Il Seclab

Qualche giorno fa su Facebook ho ritrovato un mio vecchio caro amico con cui ho condiviso una delle fasi più significative del mio rapporto con i computer e con l'hacking. Il teatro dei fatti è Milano, città dove ho vissuto alcuni mesi tra il 1998 e il '99. Ero li per lavorare nella divisione "SECLAB" di una azienda che si chiamava Intesis allora, non so neppure se esiste ancora.

Il SECLAB era un posto con un bel pò di persone che capivano abbastanza seriamente di sicurezza informatica, era un posto stimolante dove lavorare e il capo e il suo vice erano due hacker brillanti ognuno a modo suo: un programmatore ed un sistemista.

Gigi Sullivan!

Anche Lorenzo Cavallaro era al SECLAB in quel periodo. Anche lui si interessava di programmazione, di sicurezza e delle vulnerabilità del TCP/IP. Mi ricordo che qualche giorno prima che io rilasciassi la prima versione di hping (un programma di sicurezza che poi ho sviluppato per diversi anni) stava giocando con le raw socket, ho imparato da lui come si spediva un pacchetto raw. Il suo alter ego era Gigi Sullivan :) e ora è diventato ricercatore da qualche parte in California!

Idle Scan

In quel periodo continuavo a leggere dei libri sul protocollo TCP/IP e fare esperimenti con le prime versioni di Hping. Avevo scoperto delle proprietà del protocollo IP che si potevano usare a scopo di attacco. Queste proprietà combinate con alcune proprietà note del protocollo TCP portavano alla possibilità di un attacco abbastanza complicato ma che per la prima volta permetteva di eseguire degli attacchi su una macchina mascherando il proprio IP.

L' "IP Spoofing" era una cosa mitica per tutti gli addetti ai lavori. Era un attacco vecchio e famoso inventato da alcuni russi, ma non funzionava più da tempo, da quando i numeri di sequenza del TCP erano stati resi non banalmente predicibili. Grazie all'attacco che avevo teorizzato una nuova forma di IP spoofing era finalmente possibile, e ciò era molto interessante per noi. Non permetteva come il vecchio di eseguire connessioni TCP utilizzando un IP diverso, ma quanto meno di vedere se una data porta era aperta o no. In pratica l'Idle scan è una forma di port scanning con IP spoofed.

L'attacco mi frullava in testa da un pò di giorni, non ero sicuro che nella realtà potesse funzionare, e ne parlavo con Lorenzo Cavallaro e Giorgio Basanisi, eppure facevamo i conti a mente e sembrava funzionare davvero. E infatti da li a poco ho modificato hping in modo da rendere possibile l'attacco e ho provato nella pratica la teoria: funzionava tutto davvero!

BAGTRAQ

Se esisteva una cosa mitica e immensa nell'immaginario del ricercatore di sicurezza informatica di quel periodo al pari del pianeta Trantor al centro della Galassia così ben descritto da Asimov era la mailing list BUGTRAQ. Un posto in cui tutti gli hacker postavano e discutevano dei nuovi attacchi, in cui vedevi passare i nomi dei mostri sacri di tutto il mondo, frammenti di codice che permettevano root exploit remoti, discussioni con una quantità e qualità di informazioni che valevano come o più di tanti paper di ricerca.

Qualche giorno dopo che avevo verificato l'attacco nella pratica Lorenzo e altri miei colleghi erano venuti a mangiare a casa mia. Tra una cosa e l'altra ci siamo anche ubriacati abbastanza... e dopo cena eravamo al computer a fare esperimenti vari. Ad un certo punto se mi ricordo bene l'idea è venuta a Lorenzo: perchè non posti il tuo attacco su BUGTRAQ? Gli ho detto che il mio inglese mi preoccupava non sapevo se ero in grado di farlo... ma dopo un pò ci siamo decisi e abbiamo scritto assieme l'email :) E' stato divertente, eravamo allegri ed eccitati, e questo è il testo originale che è venuto fuori:
From: antirez <antirez_at_SECLAB.COM>
Date: Fri, 18 Dec 1998 07:47:57 +0100

Hi,

I have uncovered a new tcp port scan method. Instead all others it allows you to scan using spoofed packets, so scanned hosts can't see your real address. In order to perform this i use three well known tcp/ip implementation peculiarities of most OS:

(1) * hosts reply SYN|ACK to SYN if tcp target port is open, reply RST|ACK if tcp target port is closed.

(2) * You can know the number of packets that hosts are sending using id ip header field. See my previous posting 'about the ip header' in this ml.

(3) * hosts reply RST to SYN|ACK, reply nothing to RST.

The Players:

host A - evil host, the attacker. host B - silent host. host C - victim host.

A is your host. B is a particular host: It must not send any packets while you are scanning C. There are a lot of 'zero traffic' hosts in internet, especially in the night :) C is the victim, it must be vulnerable to SYN scan.

I've called this scan method 'dumb host scan' in honour of host B characteristics.

How it works:

Host A monitors number of outgoing packets from B using id iphdr. You can do this simply using hping:

#hping B -r HPING B (eth0 xxx.yyy.zzz.jjj): no flags are set, 40 data bytes 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=0 ttl=64 id=41660 win=0 time=1.2 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=1 ttl=64 id=+1 win=0 time=75 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=2 ttl=64 id=+1 win=0 time=91 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=3 ttl=64 id=+1 win=0 time=90 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=4 ttl=64 id=+1 win=0 time=91 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=5 ttl=64 id=+1 win=0 time=87 ms -cut- .. .

As you can see, id increases are always 1. So this host have the characteristics that host B should to own.

Now host A sends SYN to port X of C spoofing from B. (using hping => 0.67 is very easy, http://www.kyuzz.org/antirez) if port X of C is open, host C will send SYN|ACK to B (yes, host C don't know that the real sender is A). In this case host B replies to SYN|ACK with a RST. If we send to host C a few of SYN it will reply to B with a few of SYN|ACK, so B will reply to C a few of RST... so we'll see that host B is sending packets!

. .. -cut- 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=17 ttl=64 id=+1 win=0 time=96 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=18 ttl=64 id=+1 win=0 time=80 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=19 ttl=64 id=+2 win=0 time=83 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=20 ttl=64 id=+3 win=0 time=94 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=21 ttl=64 id=+1 win=0 time=92 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=22 ttl=64 id=+2 win=0 time=82 ms -cut- .. .

The port is open!

Instead, if port X of C is closed sending to C a few of SYN spoofed from B, it will reply with RST to B, and B will not reply (see 3). So we'll see that host B is not sending any packet:

. .. -cut- 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=52 ttl=64 id=+1 win=0 time=85 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=53 ttl=64 id=+1 win=0 time=83 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=54 ttl=64 id=+1 win=0 time=93 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=55 ttl=64 id=+1 win=0 time=74 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=56 ttl=64 id=+1 win=0 time=95 ms 60 bytes from xxx.yyy.zzz.jjj: flags=RA seq=57 ttl=64 id=+1 win=0 time=81 ms -cut- .. .

The port is closed.

All this can appear complicated to perform, but using two sessions of hping on Linux virtual consoles or under X makes it more simple. First session listen host B: hping B -r Second session send spoofed SYN: hping C -a B -S

Sorry if my english is not so clear. However this posting is not adequate to describe exaustively this scan method, so i'll write a paper on this topic, specially about how to implement this in a port scanner (i.e. nmap), and about players characteristics and OS used.

happy new year, antirez
C'è voluto un pò prima che l'exploit venisse digerito dalla comunità, ma dopo qualche tempo sono apparse le prime implementazioni, ad oggi la più famosa e stabile e quella implementata dentro il portscanner nmap. Oggi l'idle scan è trattato in molti libri di informatica e viene persino insegnato all'università. Chi lo doveva dire che un post di due ubriachi avrebbe fatto tanta strada? :)
post letto 8330 volte (1.5 letture al giorno in media)
Postato alle 13:29:50 permalink | 14 commenti | stampa | posta | trackbacks