fixed permissions settings

This commit is contained in:
2026-08-24 02:10:07 +02:00
parent 6bdd6160c0
commit ca97cb6270
2 changed files with 12 additions and 5 deletions

View File

@@ -58,6 +58,11 @@ def source_files() -> list[Path]:
return files return files
def chmod_lines(target: str, spec: str, indent: str = "") -> list[str]:
# Grey Hack File.chmod accepts one class per call, e.g. "u+rwx", not "u+rwx,g+rx".
return [f'{indent}{target}.chmod("{part}")' for part in spec.split(",")]
def install_binary_lines(var: str, bin_name: str) -> list[str]: def install_binary_lines(var: str, bin_name: str) -> list[str]:
return install_file_lines(var, f"/bin/{bin_name}", bin_name) return install_file_lines(var, f"/bin/{bin_name}", bin_name)
@@ -68,7 +73,7 @@ def install_file_lines(var: str, path: str, name: str) -> list[str]:
f'if not {var}_bin then exit("Failed to install {name}")', f'if not {var}_bin then exit("Failed to install {name}")',
f'{var}_bin.set_group("root")', f'{var}_bin.set_group("root")',
f'{var}_bin.set_owner("root")', f'{var}_bin.set_owner("root")',
f'{var}_bin.chmod("u+rwx,g+rx,o+rx")', *chmod_lines(f"{var}_bin", "u+rwx,g+rx,o+rx"),
"", "",
] ]
@@ -87,7 +92,7 @@ def downloaded_program_lines(name: str, destination: str) -> list[str]:
f'\telse', f'\telse',
f'\t\t{var}_bin.set_group("root")', f'\t\t{var}_bin.set_group("root")',
f'\t\t{var}_bin.set_owner("root")', f'\t\t{var}_bin.set_owner("root")',
f'\t\t{var}_bin.chmod("u+rwx,g+rx,o+rx")', *chmod_lines(f"{var}_bin", "u+rwx,g+rx,o+rx", indent="\t\t"),
f'\tend if', f'\tend if',
f'end if', f'end if',
"", "",
@@ -105,9 +110,9 @@ def metaxploit_lines() -> list[str]:
"\tif not metaxploit_guest then", "\tif not metaxploit_guest then",
'\t\tprint("Failed to copy metaxploit.so to guest")', '\t\tprint("Failed to copy metaxploit.so to guest")',
"\telse", "\telse",
*chmod_lines("metaxploit_guest", "u+rwx,g+rx,o+rx", indent="\t\t"),
'\t\tmetaxploit_guest.set_group("guest")', '\t\tmetaxploit_guest.set_group("guest")',
'\t\tmetaxploit_guest.set_owner("guest")', '\t\tmetaxploit_guest.set_owner("guest")',
'\t\tmetaxploit_guest.chmod("u+rwx,g+rx,o+rx")',
"\tend if", "\tend if",
'\tmetaxploit_lib.move("/lib", "metaxploit.so")', '\tmetaxploit_lib.move("/lib", "metaxploit.so")',
'\tmetaxploit_lib = cp.File("/lib/metaxploit.so")', '\tmetaxploit_lib = cp.File("/lib/metaxploit.so")',
@@ -116,7 +121,7 @@ def metaxploit_lines() -> list[str]:
"\telse", "\telse",
'\t\tmetaxploit_lib.set_group("root")', '\t\tmetaxploit_lib.set_group("root")',
'\t\tmetaxploit_lib.set_owner("root")', '\t\tmetaxploit_lib.set_owner("root")',
'\t\tmetaxploit_lib.chmod("u+rw,g+rw,o+rw")', *chmod_lines("metaxploit_lib", "u+rw,g+rw,o+rw", indent="\t\t"),
"\tend if", "\tend if",
"end if", "end if",
"", "",

View File

@@ -31,6 +31,8 @@ else
guest_file = cp.File(current_path + "/" + bin_name) guest_file = cp.File(current_path + "/" + bin_name)
end if end if
guest_file.move "/home/" + active_user + "/guest/", bin_name guest_file.move "/home/" + active_user + "/guest/", bin_name
guest_file.chmod "u+rwx,g+rwx,o+rwx" guest_file.chmod "u+rwx"
guest_file.chmod "g+rwx"
guest_file.chmod "o+rwx"
guest_file.set_group "guest" guest_file.set_group "guest"
guest_file.set_owner "guest" guest_file.set_owner "guest"