first
This commit is contained in:
commit
a874664b34
3 changed files with 62 additions and 0 deletions
3
Readme.md
Normal file
3
Readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# reporter
|
||||
|
||||
I started using linux again and needed something like this.
|
29
packet.py
Normal file
29
packet.py
Normal file
|
@ -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()
|
30
reporter.py
Normal file
30
reporter.py
Normal file
|
@ -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()
|
Loading…
Reference in a new issue