changed the script so that its only interface bound
Signed-off-by: Ebbe Baß <ebbe.bass>main
parent
9c8031c47a
commit
0d86194f26
|
@ -1,17 +1,28 @@
|
|||
from scapy.all import *
|
||||
from scapy.arch import get_if_addr
|
||||
import socket
|
||||
|
||||
def forward_artnet(pkt):
|
||||
# Check if the packet is an ArtNet packet
|
||||
if pkt.haslayer(IP) and pkt.haslayer(UDP) and pkt[UDP].dport == 6454:
|
||||
# Check the source IP address and interface
|
||||
if pkt[IP].src.startswith("10.0.") and pkt.route()[0] == "eth0":
|
||||
# Modify the source IP address to the new network
|
||||
pkt[IP].src = get_if_addr("wlan0")
|
||||
# Forward the packet to the new network
|
||||
send(pkt, iface="wlan0")
|
||||
print("Forwarded ArtNet packet from eth0 to wlan0")
|
||||
def forward_artnet(iface_in, iface_out):
|
||||
# Create raw socket to receive and send ArtNet packets
|
||||
sock_in = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003))
|
||||
sock_in.bind((iface_in, 0))
|
||||
|
||||
sock_out = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003))
|
||||
sock_out.bind((iface_out, 0))
|
||||
|
||||
# Sniff ArtNet packets on eth0
|
||||
while True:
|
||||
sniff(iface="eth0", prn=forward_artnet, store=0)
|
||||
# Receive ArtNet packet from the input interface
|
||||
pkt, _ = sock_in.recvfrom(65535)
|
||||
|
||||
# Modify the source MAC address if needed
|
||||
# Modify other fields as required
|
||||
|
||||
# Forward the packet to the output interface
|
||||
sock_out.sendall(pkt)
|
||||
|
||||
print(f"Forwarded ArtNet packet from {iface_in} to {iface_out}")
|
||||
|
||||
# Specify the input and output interfaces
|
||||
input_interface = "eth0"
|
||||
output_interface = "wlan0"
|
||||
|
||||
# Start forwarding ArtNet packets between interfaces
|
||||
forward_artnet(input_interface, output_interface)
|
||||
|
|
Loading…
Reference in New Issue