Files
cli/libfish.src
- import_code("/home/me/h/src/utils.src") // exports map.inspect, p
- import_code("/home/me/h/libs/list.src") // exports list utils and map utils
- import_code("/home/me/h/libs/disk.src") // exports Disk, Block
- import_code("/home/me/h/libs/nmap.src") // exports Nmap, Service
- import_code("/home/me/h/libs/scan.src") // exports Scan
- import_code("/home/me/h/libs/json.src") // exports Json
- import_code("/home/me/h/src/rndIP.src") // exports rnd_ip
- import_code("/home/me/h/src/docDB.src") // exports DocDB
- import_code("/home/me/h/src/machine.src") // exports Machine, MachineService, depends on Scan, Nmap , Json, DocDB
- import_code("/home/me/h/libs/meta.src") // exports Meta
- import_code("/home/me/h/src/shell.src") // extend map
- get_shell.host_computer.create_folder(home_dir + "/Config", "libs")
- LIB_STORE_PATH = home_dir + "/Config/libs"
- for i in Service.remote_lib_dict.indexes
- get_shell.host_computer.create_folder(LIB_STORE_PATH,i)
- end for
- for i in Service.local_lib_dict.indexes
- get_shell.host_computer.create_folder(LIB_STORE_PATH,i)
- end for
- Machine.metaxploit = include_lib("/lib/metaxploit.so")
- Scan.metaxploit = include_lib("/lib/metaxploit.so")
- Command = {}
- Command.libfish_sig = {}
- Command.libfish_sig["description"] = "hack random npcs to find libs"
- lib_param_desc = []
- lib_param_desc.push "libs to search for, if this param is present the command will only search for the specific libs passed "
- lib_param_desc.push "but you can pass as many lib names as you want, the valid params are: "
- lib_param_desc.push Service.remote_lib_dict.indexes.join(", ")
- lib_param_desc = lib_param_desc.join("")
- Command.libfish_sig["args"] = [["lib", lib_param_desc]]
- Command.libfish_sig["options"] = [{["-l", "--search-local-libs"]: "save local libs aswell"}]
- get_known_libs_from_libs_folder = function(folder)
- known_libs = []
- lib_folders = folder.get_folders
-
- for lib_folder in lib_folders
- lib_versions_folder = lib_folder.get_folders
-
- for lib_version_folder in lib_versions_folder
- key = lib_folder.name + lib_version_folder.name
- known_libs.push key
- end for
- end for
- return known_libs
- end function
- Command.libfish = function(args = [], options = {})
- if args.len > 0 then
- for arg in args
- if Service.remote_lib_dict.hasIndex(arg) == 0 then exit("invalid param, look at the docs")
- end for
- for i in Service.remote_lib_dict.indexes
- if args.indexOf(i) == null then Service.remote_lib_dict.remove(i)
- end for
- end if
- while true
- machine = new Machine
- machine.init(rnd_ip)
-
- for s in machine.services
known_libs = get_shell.host_computer.File(LIB_STORE_PATH).get_files
for i in known_libs.indexes
known_libs[i] = known_libs[i].name
end for
- libs_folder = get_shell.host_computer.File(LIB_STORE_PATH)
- known_libs = get_known_libs_from_libs_folder(libs_folder)
-
- s.set_exploits
- key = s.info.replace(".", "").replace(" ", "")
-
- if options["-l"] == false then
- // skip service if not listed on libs
- if not Service.remote_lib_dict.hasIndex(s.info.split(" ")[0]) then continue
- // skip service if remote lib is already in store
- if known_libs.indexOf(key) then continue
- end if
- sh = s.quick_root_shell
- if typeof(sh) != "shell" then continue
machine.save_exploits
-
- if Service.remote_lib_dict.hasIndex(s.info.split(" ")[0]) == true then
- if known_libs.indexOf(key) == null and key then
so_name = Service.remote_lib_dict[s.info.split(" ")[0]]
sh.scp("/lib/" + so_name, LIB_STORE_PATH, get_shell)
get_shell.host_computer.File(LIB_STORE_PATH + "/" + so_name).rename(key)
- print "saving remote " + s.info
- so_name = Service.remote_lib_dict[s.info.split(" ")[0]]
- name_key = s.info.split(" ")[0]
- version_key = s.info.split(" ")[1].replace(".", "")
- get_shell.host_computer.create_folder(LIB_STORE_PATH + "/" + name_key, version_key)
-
- sh.scp("/lib/" + so_name, LIB_STORE_PATH + "/" + name_key + "/" + version_key, get_shell)
- end if
- end if
-
- if options["-l"] == true then
- for i in Service.local_lib_dict.values
- if typeof(sh.host_computer.File("/lib/" + i)) != "file" then continue
-
- sh.scp("/lib/" + i, LIB_STORE_PATH, get_shell)
-
- lib = machine.metaxploit.load("/lib/" + i)
key = Service.local_lib_dict.indexOf(i) + lib.version.replace(".", "")
- name_key = Service.local_lib_dict.indexOf(i)
- version_key = lib.version.replace(".", "")
- key = name_key + version_key
-
- if known_libs.indexOf(key) then
- get_shell.host_computer.File(LIB_STORE_PATH + "/" + i).delete
- else
get_shell.host_computer.File(LIB_STORE_PATH + "/" + i).rename(key)
- print "saving local " + name_key + " " + version_key
- get_shell.host_computer.create_folder(LIB_STORE_PATH + "/" + name_key, version_key)
- get_shell.host_computer.File(LIB_STORE_PATH + "/" + i).move(LIB_STORE_PATH + "/" + name_key + "/" + version_key, i)
- end if
- end for
- end if
- end for
- end while
- end function
- import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
- Thor.init(Command, "libfish")
cli/hack.src
- import_code("/home/me/h/src/utils.src") // exports map.inspect, p
- import_code("/home/me/h/libs/list.src") // exports list utils and map utils
- import_code("/home/me/h/libs/disk.src") // exports Disk, Block
- import_code("/home/me/h/libs/nmap.src") // exports Nmap, Service
- import_code("/home/me/h/libs/scan.src") // exports Scan
- import_code("/home/me/h/libs/json.src") // exports Json
- import_code("/home/me/h/src/rndIP.src") // exports rnd_ip
- import_code("/home/me/h/libs/optionSelector.src") // exports option_selector
- import_code("/home/me/h/src/docDB.src") // exports DocDB
- import_code("/home/me/h/src/machine.src") // exports Machine, MachineService, depends on Scan, Nmap , Json, DocDB
- import_code("/home/me/h/libs/meta.src") // exports Meta
- import_code("/home/me/h/src/shell.src") // extend map
- Machine.metaxploit = include_lib("/lib/metaxploit.so")
- Scan.metaxploit = include_lib("/lib/metaxploit.so")
- Command = {}
- Command.hack_sig = {}
- Command.hack_sig["description"] = "hack shit"
- Command.hack_sig["args"] = ["ip*"]
- Command.hack_sig["options"] = []
- Command.hack = function(args = [], options = {})
- machine = new Machine
- machine.init(args[0])
-
- services = machine.services
- f = function(o)
- is_cached = "not cached"
- if machine.exploits_db.obj.hasIndex(o.info_to_key) then
- is_cached = "<color=green>cached</color>"
- end if
-
- return [o, o.lan_ip + ":" + o.port + " " + o.info + " " + is_cached]
- end function
- services = services.map(@f)
-
- print "target which lib?"
- service = user_select(services)
-
- print service.info
-
- service.set_exploits
-
- shell = null
- if user_confirmation("do you want to auto root ? (only works on npcs)") then
- shell = service.quick_root_shell
- else
- for x in service.exploits
- x.set_result
- if typeof(x.result) == "shell" then shell = x.result
- end for
- end if
-
- if shell == null then
- exit("no shells")
- end if
-
- machine.save_exploits
- if user_confirmation("do you want to clear the logs") then
- shell.clear_logs
- end if
-
- shell.start_terminal
- end function
- import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
- Thor.init(Command, "hack")