23
Page N°1 4 juin 2004 L’outil Nmap- Stateful Olivier Courtay Thomson R&D / IRISA

Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Embed Size (px)

Citation preview

Page 1: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°14 juin 2004

L’outil Nmap-Stateful

Olivier Courtay

Thomson R&D / IRISA

Page 2: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°24 juin 2004

Plan

• Introduction• Nmap-Stateful: Principe et Fonctionnement• Méthodes et Résultats• Prospective• Conclusion

Page 3: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°34 juin 2004

Nmap

• Outil réseau classique• Scanner de ports avancé• Détection de machines• Détection des services

• Détection des systèmes d’exploitation (OS)– Caractéristique TCP/IP– Base de signatures ( > 700)

Page 4: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°44 juin 2004

Nmap – Détection d’OS

Port ouvertISN (séquence TCP)

IP ID (ouvert)TCP SYN + options

TCP ACK TCP S/F/P/U

TCP NULL

Port ferméIP ID (fermé)

TCP SYN, TCP ACKUDP (réponse ICMP)

TCP Xmas (F/P/U)

TCP ACKTCP S/F/P/U TCP Xmas (F/P/U)TCP NULL

Paquets non-standards

Page 5: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°54 juin 2004

Limites de Nmap

• En environnement filtré– UDP passe rarement– Pas de port fermé– Contrôle des flags par les firewalls stateful

Peu de tests fonctionnent dans ces conditions

• Tests non configurables• Seulement deux états TCP utilisés

Page 6: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°64 juin 2004

Nmap-Stateful

Principe et Fonctionnement

Page 7: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°74 juin 2004

Principe

• Extension du code de Nmap

• Teste plusieurs états TCP (Stateful)1) La machine testée est amenée dans l’état

voulu2) Le test est ensuite lancé3) La réponse est analysée

• Tests configurables par l’utilisateur

Page 8: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°84 juin 2004

Le diagramme d’état TCPCLOSED

SYN_SENT

LISTEN

SYN_RCVD

ESTABLISHED

FIN_WAIT1 CLOSING

FIN_WAIT2 TIME_WAIT

CLOSE_WAIT

LAST_ACK

LISTEN

CLOSED

SYN_RCVD

ESTABLISHED

FIN_WAIT1

FIN_WAIT2 TIME_WAIT

CLOSING

LAST_ACK

SYN_SENT

NMAPNMAP

Page 9: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°94 juin 2004

Trace d’exécution

#nmap-stateful --otf test-estab-SYN -p 22 192.168.1.1

SYN sent for test ESTAB_SYN from port 8557 to port 22

...

SYN_SENT seq:34 sp:8557 -> dp:22 ack:00 SYN_RECV flags:SS

ESTABLISH ack:35 dp:8557 <- sp:22 seq:78 SYN_RECV flags:SASA

ESTABLISH seq:35 sp:8557 -> dp:22 ack:79 ESTABLISHESTABLISH flags:AA

Launch test: ESTAB_SYN

UNKONWN seq:35 sp:8557 -> dp:22 ack:79 UNKONWN flags:S

UNKONWN ack:42 dp:8557 <- sp:22 seq:00 UNKONWN flags:RA

...

Fingerprint:

ESTAB_SYN(Resp=Y%DF=Y%W=0%ACK=O%Flags=AR%Ops=)

Page 10: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°104 juin 2004

Implémentation

• Licence GPL• Mini pile TCP/IP• Firewall

– Inhibe la réaction de la machine testeur• Linux supporté

– Utilisation de Iptables• Aide à la création de tests

Page 11: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°114 juin 2004

Méthodes et Résultats

Détection d’OS

Page 12: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°124 juin 2004

Génération des tests

#fingerprinttool -g template -o test

fptool

NAME=template ESTABLISHED TH_SYN TH_ACK TH_FIN TH_PUSH DATA=foobar DATALEN=7 SEQ=1END

Page 13: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°134 juin 2004

Sélection des tests stables

NmapStateful

fptool

#nmap-stateful -p 22 --otf test --orf r1 t1#nmap-stateful -p 22 --otf test --orf r2 t2#nmap-stateful -p 22 --otf test --orf r3 t3

#fingerprinttool -s -t test -o stable r1 r2 r3

t1 r1

t2 r2

t3 r3

Page 14: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°144 juin 2004

Sélection des tests pertinents

#nmap-stateful -p 22 --otf stable --orf r1 t1#nmap-stateful -p 22 --otf stable --orf r2 t2#nmap-stateful -p 22 --otf stable --orf r3 t3

#fingerprinttool -s -t stable -o good r1 r2 r3

NmapStateful

fptool

r1t1

r2t2

r3t3

Page 15: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°154 juin 2004

Validation de l’outil

#nmap-stateful --otf good --off signatures -p 80 x.x.x.x

Interesting ports on x.x.x.x:

PORT STATE SERVICE

80/tcp open http

OS details: Linux 2.4

• Test sur un Linux 2.4

#nmap-stateful --otf good --off signatures -p 80 y.y.y.y

Interesting ports on y.y.y.y:

PORT STATE SERVICE

80/tcp open http

Aggressive OS guesses: Linux 2.6 (97%), Linux 2.4 (96%)

• Autre test sur un Linux 2.4

Page 16: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°164 juin 2004

Prospective

Page 17: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°174 juin 2004

Actions des Firewalls (1/3)

• Ils bloquent certains paquets• Test sur un Solaris 9 protégé

#nmap-stateful --otf good --off signatures -p 80 x.x.x.x

Interesting ports on x.x.x.x:

PORT STATE SERVICE

80/tcp open http

No OS matchNo OS match

Échec !

Page 18: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°184 juin 2004

Actions des Firewalls (2/3)

• Méthode pour en tirer avantage– Construire des tests non-sensibles aux Firewalls– Découvrir l’OS de la machine protégée– Construire des tests sensibles aux Firewalls– Caractériser le Firewall qui protége la machine

Page 19: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°194 juin 2004

Actions des Firewalls (3/3)

ESTABLI_AP_SEQ-2-2(Resp=Y%DF=Y%W=832C%ACK=0%Flags=A%Ops=)ESTABLI_AP_SEQ-1-1(Resp=Y%DF=Y%W=832C%ACK=0%Flags=A%Ops=)ESTABLI_AP_SEQ00(Resp=Y%DF=Y%W=832C%ACK=0%Flags=A%Ops=)ESTABLI_AP_SEQ11(Resp=Y%DF=Y%W=832C%ACK=0%Flags=A%Ops=)ESTABLI_AP_SEQ22(Resp=Y%DF=Y%W=832C%ACK=0%Flags=A%Ops=)

• Test sur un Solaris 9 protégé par un Firewall

ESTABLI_AP_SEQ-2-2(Resp=N)ESTABLI_AP_SEQ--11(Resp=N)ESTABLI_AP_SEQ00(Resp=Y%DF=Y%W=8325%ACK=0%Flags=A%Ops=)ESTABLI_AP_SEQ11(Resp=N)ESTABLI_AP_SEQ22(Resp=N)

• Test sur un Solaris 9 protégé par un autre type de Firewall

Page 20: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°204 juin 2004

Améliorations (1/2)

• Mini-pile TCP/IP• Portabilité

– Unix Libdnet (Dug Song)– Windows PktFilter (HSC)

• Expressivité des tests

Page 21: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°214 juin 2004

Améliorations (2/2)

• Approche combinatoire– Plus systématique– Sur un panel complet de configurations (OS / FW)

Fournir un jeu de tests– Robuste– Complet

Page 22: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°224 juin 2004

Conclusion

• Les premiers résultats sont encourageants

• Problème de traitement de données• L’aide de la communauté est utile

– Proposer / Tester de nouveaux jeux de tests– Proposer des améliorations de l’outil

Page 23: Page N°14 juin 2004 Loutil Nmap-Stateful Olivier Courtay Thomson R&D / IRISA

Page N°234 juin 2004

Des Questions ?

http://home.gna.org/nmapstateful