123456789101112131415161718192021222324252627282930313233343536373839 |
- import socket
- import sys
- import net_params
- net = net_params.LocalNetwork()
- interface = net.get_default_interface()
- ethernet_frame = bytearray([
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, # Destination MAC (broadcast)
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, # Source MAC
- 0x12, 0x34, # Custom EtherType (0x1234)
- # Payload (just some test data)
- 0xde, 0xad, 0xbe, 0xef # Example payload
- ])
- # 00:11:22:33:44:55
- def send_raw_frame():
- with socket.socket(socket.AF_PACKET, socket.SOCK_RAW) as raw_socket:
- print(raw_socket)
- print(f"Binding to interface: {interface}")
- raw_socket.bind((interface, socket.ETH_P_ALL))
- print("Sending raw packet")
- bytes_send = raw_socket.send(ethernet_frame)
- print(f"Send {bytes_send} bytes to the interface")
- def main():
-
- send_raw_frame()
- if __name__ == '__main__':
- main()
|