commit a874664b34ec5c3bb74d1fc48220f6550b7d2fb8 Author: Tristan Smith Date: Fri May 3 11:52:28 2024 -0400 first diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..8798e4d --- /dev/null +++ b/Readme.md @@ -0,0 +1,3 @@ +# reporter + +I started using linux again and needed something like this. \ No newline at end of file diff --git a/packet.py b/packet.py new file mode 100644 index 0000000..24d45cd --- /dev/null +++ b/packet.py @@ -0,0 +1,29 @@ +import socket +from struct import pack + +def send_arp_packet(): + src_mac = b'\x00\x11\x22\x33\x44\x55' # Source MAC address + dst_ip = "192.168.1.1" # Destination IP address + + # Craft the ARP request packet + arp_packet = b'\xff\xff\xff\xff\xff\xff' # Destination MAC address (broadcast) + arp_packet += src_mac + arp_packet += b'\x08\x06' # Ethernet type: ARP + arp_packet += b'\x00\x01' # ARP hardware type: Ethernet + arp_packet += b'\x08\x00' # ARP protocol type: IPv4 + arp_packet += b'\x06' # Hardware address length + arp_packet += b'\x04' # Protocol address length + arp_packet += b'\x00\x01' # Operation code: ARP request + arp_packet += src_mac # Sender hardware address + arp_packet += socket.inet_aton(src_ip) # Sender protocol address + arp_packet += b'\x00\x00\x00\x00\x00\x00' # Target hardware address (unknown) + arp_packet += socket.inet_aton(dst_ip) # Target protocol address + + # Create a raw socket and send the ARP packet + raw_socket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003)) # ETH_P_ALL + raw_socket.bind(("wlp61s0", 0)) + raw_socket.send(arp_packet) + raw_socket.close() + +if __name__ == "__main__": + send_arp_packet() diff --git a/reporter.py b/reporter.py new file mode 100644 index 0000000..b3b6557 --- /dev/null +++ b/reporter.py @@ -0,0 +1,30 @@ +from scapy.all import IP, UDP, sniff + +# Define the destination IP address and UDP ports to filter +destination_ip = '255.255.255.255' # Destination IP address +source_port = 14236 # Source port +destination_port = 14235 # Destination port + +def extract_packet_info(packet): + # Check if the packet is an IP packet with UDP layer + if IP in packet and UDP in packet: + # Extract the source IP address, source port, and destination port + source_ip = packet[IP].src + udp_source_port = packet[UDP].sport + udp_destination_port = packet[UDP].dport + + # Check if the packet matches the specified destination IP address and UDP ports + if (packet[IP].dst == destination_ip and + udp_source_port == source_port and + udp_destination_port == destination_port): + print("Source IP Address:", source_ip) + #print("UDP Source Port:", udp_source_port) + #print("UDP Destination Port:", udp_destination_port) + +def listen_for_packets(): + # Sniff network traffic and invoke the callback function for each packet + sniff(prn=extract_packet_info, filter="udp and ip", store=0) + +if __name__ == "__main__": + # Start listening for packets + listen_for_packets()