Writing /net/www/auesnard/teaching/data/cache/a/a0cc0004c73722a7ea33f149b95652db.metadata failed
rx:tp5-bonus
Writing /net/www/auesnard/teaching/data/cache/b/b917139305956507b1746900fb337322.xhtml failed
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rx:tp5-bonus [2016/02/22 11:17] – created orel | rx:tp5-bonus [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====Connexion à un serveur TCP/IP (Bonus) ==== | + | ======Connexion à un serveur TCP/ |
Le but de cet exercice est d' | Le but de cet exercice est d' | ||
* Sur une machine cliente, par exemple // | * Sur une machine cliente, par exemple // | ||
- | - utilisez cette commande : < | + | - utilisez cette commande : < |
- puis lancez Scapy. | - puis lancez Scapy. | ||
Line 21: | Line 21: | ||
</ | </ | ||
- | __Attention__ : Il faut effectuer ces commandes rapidement pour éviter un " | + | __Attention__ : Il faut effectuer ces commandes rapidement pour éviter un " |
+ | |||
+ | |||
+ | Pour aller plus loin : http:// | ||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | |||
+ | import sys | ||
+ | from scapy import * | ||
+ | |||
+ | |||
+ | ### Warning: Do not forget to firewall you host to prevent your kernel | ||
+ | ### sending a RST when receiving a SYN ACK for a SYN it knows nothing | ||
+ | ### about. | ||
+ | ### | ||
+ | ### iptables --table filter -A OUTPUT -p tcp --tcp-flags ALL RST --dport 13 -j DROP | ||
+ | ### | ||
+ | |||
+ | ### CONNECT ### | ||
+ | |||
+ | |||
+ | def connect(dst, | ||
+ | |||
+ | print " | ||
+ | |||
+ | seq = RandShort() * 1 | ||
+ | sport = RandShort() * 1 | ||
+ | |||
+ | print "dst = %s" % dst | ||
+ | print "seq = %s" % seq | ||
+ | print "sport = %s" % sport | ||
+ | print "dport = %s" % dport | ||
+ | |||
+ | # SYN | ||
+ | a = IP(dst=dst)/ | ||
+ | # SYN/ACK | ||
+ | b = sr1(a, | ||
+ | # ACK | ||
+ | c = IP(dst=dst)/ | ||
+ | d = sr1(c, | ||
+ | return d | ||
+ | |||
+ | ### CLOSE ### | ||
+ | |||
+ | def close(f): | ||
+ | |||
+ | print " | ||
+ | |||
+ | # FIN/ACK | ||
+ | g = IP(dst=dst)/ | ||
+ | # FIN/ACK | ||
+ | h = sr1(g, | ||
+ | return | ||
+ | |||
+ | # Après la fermeture, la connexion est dans un état TIME_WAIT... et il | ||
+ | # faut attendre un peu pour que la fermeture soit effective. C' | ||
+ | # pourquoi on ne peut pas réutiliser immédiatement le même numéro de | ||
+ | # port source. | ||
+ | |||
+ | |||
+ | ##################### | ||
+ | |||
+ | dport = 13 | ||
+ | dst = " | ||
+ | |||
+ | # connect | ||
+ | d = connect(dst, | ||
+ | |||
+ | print d.load | ||
+ | |||
+ | # ack | ||
+ | e = IP(dst=dst)/ | ||
+ | f = sr1(e, | ||
+ | |||
+ | # close | ||
+ | close(f) | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
- | * https:// |
rx/tp5-bonus.txt · Last modified: 2024/03/18 15:06 by 127.0.0.1