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
- Machine.scan_strategy = "scan_everytime"
- Machine.skip_logging = true
- while true
print "AAAAAAAAAAAA"
- machine = new Machine
- machine.init(rnd_ip)
-
- for s in machine.services
- 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
- // skip service if not listed on libs
- if not Service.remote_lib_dict.hasIndex(s.info.split(" ")[0]) and options["-l"] == null then
- print "skiping for not being requested lib type"
- continue
- end if
- // skip service if remote lib is already in store
- if known_libs.indexOf(key) and not options["-l"] == null then
- print "skiping for lib version already being stored"
- continue
- end if
-
- print "trying to get new " + key
-
- s.set_exploits
- sh = s.quick_root_shell
- if typeof(sh) != "shell" then continue
-
- print "checking for " + s.info.split(" ")[0]
- if Service.remote_lib_dict.hasIndex(s.info.split(" ")[0]) == true then
- print "checking if " + key + " is already stored"
- if known_libs.indexOf(key) == null then
- 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)
- 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
- 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")