Skip to content

Commit 74f0845

Browse files
send_udp_packet
1 parent 6276e9e commit 74f0845

3 files changed

Lines changed: 68 additions & 6 deletions

File tree

poetry.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
name = "bitcap-ipr"
33
version = "1.2.7"
44
description = ""
5-
authors = [
6-
{name = "MatthewWertman",email = "matthewwertman57@gmail.com"}
7-
]
8-
license = {text = "GPL-3.0-only"}
5+
authors = [{ name = "MatthewWertman", email = "matthewwertman57@gmail.com" }]
6+
license = { text = "GPL-3.0-only" }
97
readme = "README.md"
108
requires-python = ">=3.10,<3.14"
119
dependencies = [
1210
"requests (>=2.32.3,<3.0.0)",
1311
"pyside6 (>=6.9.0,<7.0.0)",
1412
"passlib (>=1.7.4,<2.0.0)",
1513
"platformdirs (>=4.3.7,<5.0.0)",
16-
"pycryptodome (>=3.22.0,<4.0.0)"
14+
"pycryptodome (>=3.22.0,<4.0.0)",
1715
]
1816

1917
[tool.poetry]
@@ -26,6 +24,7 @@ pyinstaller = "^6.13.0"
2624

2725
[tool.poetry.group.test.dependencies]
2826
pytest = "^8.3.5"
27+
scapy = "^2.6.1"
2928

3029
[build-system]
3130
requires = ["poetry-core>=2.0.0,<3.0.0"]

scripts/send_udp_packet.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import sys
2+
import argparse
3+
from scapy.all import send, IP, UDP, Raw
4+
5+
6+
def parse_arguments():
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument(
9+
"-p",
10+
"--dport",
11+
action="store",
12+
type=int,
13+
required=True,
14+
help="dst port for UDP packet.",
15+
)
16+
parser.add_argument(
17+
"-s",
18+
"--src",
19+
action="store",
20+
type=str,
21+
default="127.0.0.1",
22+
help="src address for UDP packet.",
23+
)
24+
parser.add_argument(
25+
"-m",
26+
"--msg",
27+
action="store",
28+
type=str,
29+
help="optional data to attach to the UDP datagram.",
30+
)
31+
return parser.parse_args()
32+
33+
34+
if __name__ == "__main__":
35+
args = parse_arguments()
36+
37+
p = (
38+
IP(src=args.src, dst="127.0.0.1")
39+
/ UDP(sport=0, dport=args.dport)
40+
/ Raw(load=args.msg)
41+
)
42+
if p:
43+
print(p.show())
44+
send(p)
45+
46+
sys.exit(0)

0 commit comments

Comments
 (0)