rx:tp5-bonus
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| rx:tp5-bonus [2019/01/31 09:42] – orel | rx:tp5-bonus [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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.1548927750.txt.gz · Last modified: 2024/03/18 15:05 (external edit)
