|
| 1 | +# Import the neccasary modules. |
| 2 | +import sys |
| 3 | +from scapy.all import sr, IP, ICMP |
| 4 | +from faker import Faker |
| 5 | +from colorama import Fore, init |
| 6 | + |
| 7 | +# Initialize colorama for colored console output. |
| 8 | +init() |
| 9 | +# Create a Faker object for generating fake data. |
| 10 | +fake = Faker() |
| 11 | + |
| 12 | +# Function to generate a fake IPv4 address. |
| 13 | +def generate_fake_ip(): |
| 14 | + return fake.ipv4() |
| 15 | + |
| 16 | +# Function to craft and send an ICMP packet. |
| 17 | +def craft_and_send_packet(source_ip, destination_ip): |
| 18 | + # Craft an ICMP packet with the specified source and destination IP. |
| 19 | + packet = IP(src=source_ip, dst=destination_ip) / ICMP() |
| 20 | + # Send and receive the packet with a timeout. |
| 21 | + answers, _ = sr(packet, verbose=0, timeout=5) |
| 22 | + return answers |
| 23 | + |
| 24 | +# Function to display a summary of the sent and received packets. |
| 25 | +def display_packet_summary(sent, received): |
| 26 | + print(f"{Fore.GREEN}[+] Sent Packet: {sent.summary()}\n") |
| 27 | + print(f"{Fore.MAGENTA}[+] Response: {received.summary()}") |
| 28 | + |
| 29 | +# Check if the correct number of command-line arguments is provided. |
| 30 | +if len(sys.argv) != 2: |
| 31 | + print(f"{Fore.RED}[-] Error! {Fore.GREEN} Please run as: {sys.argv[0]} <dst_ip>") |
| 32 | + sys.exit(1) |
| 33 | + |
| 34 | +# Retrieve the destination IP from the command-line arguments. |
| 35 | +destination_ip = sys.argv[1] |
| 36 | +# Generate a fake source IP. |
| 37 | +source_ip = generate_fake_ip() |
| 38 | +# Craft and send the packet, and receive the response. |
| 39 | +answers = craft_and_send_packet(source_ip, destination_ip) |
| 40 | +# Display the packet summary for each sent and received pair. |
| 41 | +for sent, received in answers: |
| 42 | + display_packet_summary(sent, received) |
0 commit comments