Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0771345

Browse files
committed
add ip spoofer tutorial
1 parentcf194de commit0771345

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
1616
-[How to Build a WiFi Scanner in Python using Scapy](https://www.thepythoncode.com/article/building-wifi-scanner-in-python-scapy). ([code](scapy/wifi-scanner))
1717
-[How to Make a SYN Flooding Attack in Python](https://www.thepythoncode.com/article/syn-flooding-attack-using-scapy-in-python). ([code](scapy/syn-flood))
1818
-[How to Inject Code into HTTP Responses in the Network in Python](https://www.thepythoncode.com/article/injecting-code-to-html-in-a-network-scapy-python). ([code](scapy/http-code-injector/))
19+
-[How to Perform IP Address Spoofing in Python](https://thepythoncode.com/article/make-an-ip-spoofer-in-python-using-scapy). ([code](scapy/ip-spoofer))
1920
-[Writing a Keylogger in Python from Scratch](https://www.thepythoncode.com/article/write-a-keylogger-python). ([code](ethical-hacking/keylogger))
2021
-[Making a Port Scanner using sockets in Python](https://www.thepythoncode.com/article/make-port-scanner-python). ([code](ethical-hacking/port_scanner))
2122
-[How to Create a Reverse Shell in Python](https://www.thepythoncode.com/article/create-reverse-shell-python). ([code](ethical-hacking/reverse_shell))

‎scapy/ip-spoofer/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[How to Perform IP Address Spoofing in Python](https://thepythoncode.com/article/make-an-ip-spoofer-in-python-using-scapy)
2+
To run this:
3+
-`pip install -r requirements.txt`
4+
-`python ip_spoofer.py [target_ip]`

‎scapy/ip-spoofer/ip_spoofer.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Import the neccasary modules.
2+
importsys
3+
fromscapy.allimportsr,IP,ICMP
4+
fromfakerimportFaker
5+
fromcoloramaimportFore,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+
defgenerate_fake_ip():
14+
returnfake.ipv4()
15+
16+
# Function to craft and send an ICMP packet.
17+
defcraft_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+
returnanswers
23+
24+
# Function to display a summary of the sent and received packets.
25+
defdisplay_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+
iflen(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+
forsent,receivedinanswers:
42+
display_packet_summary(sent,received)

‎scapy/ip-spoofer/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
scapy
2+
faker
3+
colorama

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp