You've already forked greyhack
default binaries
This commit is contained in:
36
provision.py
36
provision.py
@@ -6,6 +6,18 @@ import re
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
SOURCE_DIR = ROOT / "source"
|
||||
OUTPUT = ROOT / "provision.src"
|
||||
DOWNLOADED_BINARIES = [
|
||||
"nmap",
|
||||
"smtp-user-list",
|
||||
"ssh-server",
|
||||
"http-server",
|
||||
"ftp-server",
|
||||
"chat-server",
|
||||
"repository-server",
|
||||
"wallet",
|
||||
"decipher",
|
||||
]
|
||||
DOWNLOADED_EXECUTABLES = ["Stocks.exe", "ExploitReport.exe"]
|
||||
|
||||
|
||||
def variable_name(path: Path) -> str:
|
||||
@@ -42,9 +54,13 @@ def source_files() -> list[Path]:
|
||||
|
||||
|
||||
def install_binary_lines(var: str, bin_name: str) -> list[str]:
|
||||
return install_file_lines(var, f"/bin/{bin_name}", bin_name)
|
||||
|
||||
|
||||
def install_file_lines(var: str, path: str, name: str) -> list[str]:
|
||||
return [
|
||||
f'{var}_bin = cp.File("/bin/{bin_name}")',
|
||||
f'if not {var}_bin then exit("Failed to install {bin_name}")',
|
||||
f'{var}_bin = cp.File("{path}")',
|
||||
f'if not {var}_bin then exit("Failed to install {name}")',
|
||||
f'{var}_bin.set_group("root")',
|
||||
f'{var}_bin.set_owner("root")',
|
||||
f'{var}_bin.chmod("u+rwx,g+rx,o+rx")',
|
||||
@@ -52,6 +68,16 @@ def install_binary_lines(var: str, bin_name: str) -> list[str]:
|
||||
]
|
||||
|
||||
|
||||
def downloaded_program_lines(name: str, destination: str) -> list[str]:
|
||||
var = variable_name(Path(name))
|
||||
return [
|
||||
f'{var}_bin = cp.File(home + "/{name}")',
|
||||
f'if not {var}_bin then exit("Missing downloaded program: {name}")',
|
||||
f'{var}_bin.move("{destination}", "{name}")',
|
||||
*install_file_lines(var, f"{destination}/{name}", name),
|
||||
]
|
||||
|
||||
|
||||
def build_provision() -> str:
|
||||
sources = source_files()
|
||||
if not sources:
|
||||
@@ -77,6 +103,12 @@ def build_provision() -> str:
|
||||
]
|
||||
)
|
||||
|
||||
for name in DOWNLOADED_BINARIES:
|
||||
output.extend(downloaded_program_lines(name, "/bin"))
|
||||
|
||||
for name in DOWNLOADED_EXECUTABLES:
|
||||
output.extend(downloaded_program_lines(name, "/usr/bin"))
|
||||
|
||||
bbuild = sources[0]
|
||||
bbuild_var = variable_name(bbuild)
|
||||
output.extend(
|
||||
|
||||
Reference in New Issue
Block a user