I want to use scapy to manipulate network live packet (change the packet length of a special program) then forward them to dst. How can I do this and Is there better tool than scapy or not?
This is really easy to do using scapy, with the below sample for instance:
from scapy.all import *
def _handle(pkt):
pkt[Ether].dst = None # ask scapy to regenerate it
pkt[IP].dst = “192.168.x.y”. # or any IP
# packet edits
# ...
sendp(pkt)
sniff(prn=_handle). # on each packet received, execute _handle(pkt)
You may also specify an interface in sendp
or sniff
using the iface=...
arg
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.