You've already forked greyhack
39 lines
1.5 KiB
Plaintext
39 lines
1.5 KiB
Plaintext
if params.len < 1 or params[0] == "-h" or params[0] == "--help" then
|
|
current_program = get_shell.host_computer.File(program_path)
|
|
exit "Usage: " + current_program.name + " <source code path>"
|
|
end if
|
|
source_file = get_shell.host_computer.File(params[0])
|
|
if not source_file then
|
|
source_file = get_shell.host_computer.File(current_path + params[0])
|
|
if not source_file then exit("Unable to locate source file")
|
|
end if
|
|
|
|
cp = get_shell.host_computer
|
|
get_shell.build source_file.path, current_path
|
|
bin_name = source_file.name.split("\.")[0]
|
|
bin_file = cp.File(current_path + "/" + bin_name)
|
|
if not bin_file then exit("Compiler error")
|
|
bin_file.move "/bin", bin_name
|
|
bin_file.set_group "root"
|
|
bin_file.set_owner "root"
|
|
|
|
source_content = source_file.get_content
|
|
if source_content.indexOf("""/lib/metaxploit.so""") and bin_name != "bbuild" then
|
|
source_content = source_content.replace("""/lib/metaxploit.so""", "current_path + ""/metaxploit.so""")
|
|
cp.touch current_path, bin_name + "_guest.src"
|
|
guest_source = cp.File(current_path + "/" + bin_name + "_guest.src")
|
|
guest_source.set_content source_content
|
|
get_shell.build guest_source.path, current_path
|
|
guest_source.delete
|
|
guest_file = cp.File(current_path + "/" + bin_name + "_guest")
|
|
else
|
|
get_shell.build source_file.path, current_path
|
|
guest_file = cp.File(current_path + "/" + bin_name)
|
|
end if
|
|
guest_file.move "/home/" + active_user + "/guest/", bin_name
|
|
guest_file.chmod "u+rwx"
|
|
guest_file.chmod "g+rwx"
|
|
guest_file.chmod "o+rwx"
|
|
guest_file.set_group "guest"
|
|
guest_file.set_owner "guest"
|