简体   繁体   中英

Capture packets and redirect them using scapy

I am posting this question after doing a lot of searching about SCAPY, i saw that it is a very interesting tool to craft packets and send them in the wire. What i didnt found is the possibility to use this tool to capture incoming packets and redirect them to the right destination based on information found in the packet (http request). Thank you in advance

You can capture packets with the sniff() function, modify them and send them with sendp() .

from scapy.all import *

while True:
    pkts = sniff(count=1)
    # do some stuff on pkts[0]
    sendp(pkts[0])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM