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

Commit83a5d14

Browse files
committed
add crafting packets scapy tutorial
1 parent25d764e commit83a5d14

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
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/))
1919
-[How to Perform IP Address Spoofing in Python](https://thepythoncode.com/article/make-an-ip-spoofer-in-python-using-scapy). ([code](scapy/ip-spoofer))
2020
-[How to See Hidden Wi-Fi Networks in Python](https://thepythoncode.com/article/uncovering-hidden-ssids-with-scapy-in-python). ([code](scapy/uncover-hidden-wifis))
21+
-[Crafting Dummy Packets with Scapy Using Python](https://thepythoncode.com/article/crafting-packets-with-scapy-in-python). ([code](scapy/crafting-packets))
2122
-[Writing a Keylogger in Python from Scratch](https://www.thepythoncode.com/article/write-a-keylogger-python). ([code](ethical-hacking/keylogger))
2223
-[Making a Port Scanner using sockets in Python](https://www.thepythoncode.com/article/make-port-scanner-python). ([code](ethical-hacking/port_scanner))
2324
-[How to Create a Reverse Shell in Python](https://www.thepythoncode.com/article/create-reverse-shell-python). ([code](ethical-hacking/reverse_shell))

‎scapy/crafting-packets/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#[Crafting Dummy Packets with Scapy Using Python](https://thepythoncode.com/article/crafting-packets-with-scapy-in-python)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server_ips= ["192.168.27.1","192.168.17.129","192.168.17.128"]
2+
3+
fromscapy.allimportIP,ICMP,sr1
4+
importtime
5+
6+
defcheck_latency(ip):
7+
packet=IP(dst=ip)/ICMP()
8+
start_time=time.time()
9+
response=sr1(packet,timeout=2,verbose=0)
10+
end_time=time.time()
11+
12+
ifresponse:
13+
latency= (end_time-start_time)*1000# Convert to milliseconds
14+
print(f"[+] Latency to{ip}:{latency:.2f} ms")
15+
else:
16+
print(f"[-] No response from{ip} (possible packet loss)")
17+
18+
forserver_ipinserver_ips:
19+
check_latency(server_ip)
20+
21+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Uncomment them and run according to the tutorial
2+
#from scapy.all import IP, TCP, send, UDP
3+
4+
# # Step 1: Creating a simple IP packet
5+
# packet = IP(dst="192.168.1.1") # Setting the destination IP
6+
# packet = IP(dst="192.168.1.1") / TCP(dport=80, sport=12345, flags="S")
7+
# print(packet.show()) # Display packet details
8+
# send(packet)
9+
10+
11+
############
12+
# from scapy.all import ICMP
13+
14+
# # Creating an ICMP Echo request packet
15+
# icmp_packet = IP(dst="192.168.1.1") / ICMP()
16+
# send(icmp_packet)
17+
18+
19+
############
20+
# from scapy.all import UDP
21+
22+
# # Creating a UDP packet
23+
# udp_packet = IP(dst="192.168.1.1") / UDP(dport=53, sport=12345)
24+
# send(udp_packet)
25+
26+
27+
28+
###########
29+
# blocked_packet = IP(dst="192.168.1.1") / TCP(dport=80, flags="S")
30+
# send(blocked_packet)
31+
32+
# allowed_packet = IP(dst="192.168.1.1") / UDP(dport=53)
33+
# send(allowed_packet)
34+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scapy

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp