Open main menu
Posts
Gists
Guilds
Users
Decipher
Docs
Open user menu
Log in
Sign up
Create a new gist
Posts
Gists
Guilds
Users
Decipher
Docs
Files
cli/libfish.src
cli/proxy.src
libs/thor.src
src/shell.src
src/machine.src
libs/optionSelector.src
cli/npcRshell.src
src/rndIP.src
src/rserverInstaller.src
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/machine.src") // exports Machine, MachineService, depends on Scan, Nmap , Json
import_code("/home/me/h/libs/meta.src") // exports Meta
import_code("/home/me/h/src/shell.src") // extend map
TABLEATTACK_SCRIPT = get_shell.host_computer.File(home_dir + "/Config/tableAttack.src")
EMPTY_LOG_PATH = home_dir + "/Config/emptyLog"
PASSWORDS_DISK = new Disk
PASSWORDS_DISK.init(home_dir + "/Config", "passwords")
EXPLOITS_DISK = new Disk
EXPLOITS_DISK.init(home_dir + "/Config", "exploits")
LIB_STORE_PATH = home_dir + "/Config/libs"
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.lib_dict.indexes.join(", ")
lib_param_desc = lib_param_desc.join("")
Command.libfish_sig["args"] = [["lib", lib_param_desc]]
Command.libfish_sig["options"] = []
Command.libfish = function(args = [], options = {})
if args.len > 0 then
for arg in args
if Service.lib_dict.hasIndex(arg) == 0 then exit("invalid param, look at the docs")
end for
for i in Service.lib_dict.indexes
if args.indexOf(i) == null then Service.lib_dict.remove(i)
end for
end if
while true
machine = new Machine
machine.init(
machine.random
_ip, PASSWORDS_DISK, EXPLOITS_DISK)
machine.init(
rnd
_ip, PASSWORDS_DISK, EXPLOITS_DISK)
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
s.set_exploits
if not Service.lib_dict.hasIndex(s.info.split(" ")[0]) then continue
key = s.info.replace(".", "").replace(" ", "")
if known_libs.indexOf(key) then continue
so_name = Service.lib_dict[s.info.split(" ")[0]]
sh = s.quick_root_shell(TABLEATTACK_SCRIPT)
if typeof(sh) != "shell" then continue
sh.scp("/lib/" + so_name, LIB_STORE_PATH, get_shell)
sh.clear_logs(EMPTY_LOG_PATH)
get_shell.host_computer.File(LIB_STORE_PATH + "/" + so_name).rename(key)
end for
end while
end function
import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
Thor.init(Command, "libfish")
cli/proxy.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/machine.src") // exports Machine, MachineService, depends on Scan, Nmap , Json
import_code("/home/me/h/libs/meta.src") // exports Meta
import_code("/home/me/h/src/shell.src") // extend map
TABLEATTACK_SCRIPT = get_shell.host_computer.File(home_dir + "/Config/tableAttack.src")
EMPTY_LOG_PATH = home_dir + "/Config/emptyLog"
PASSWORDS_DISK = new Disk
PASSWORDS_DISK.init(home_dir + "/Config", "passwords")
EXPLOITS_DISK = new Disk
EXPLOITS_DISK.init(home_dir + "/Config", "exploits")
Machine.metaxploit = include_lib("/lib/metaxploit.so")
Scan.metaxploit = include_lib("/lib/metaxploit.so")
get_shell.host_computer.touch(home_dir + "/Config", "proxy.txt")
PROXY_FILE = get_shell.host_computer.File(home_dir + "/Config/proxy.txt")
Command = {}
Command.proxy_sig = {}
Command.proxy_sig["description"] = "hack a random router to use to hide you ip"
Command.proxy_sig["args"] = []
Command.proxy_sig["options"] = []
Command.proxy_sig["options"] = [
{["-w", "--wipe"]: "wipe the server logs instead of connecting"}
]
Command.proxy = function(args = [], options = {})
re_hack = function(ip)
machine = new Machine
machine.init(ip, PASSWORDS_DISK, EXPLOITS_DISK)
root_shell = machine.quick_attack(true, TABLEATTACK_SCRIPT)
if root_shell == null then exit("could not reconnect")
root_shell.clear_logs(EMPTY_LOG_PATH)
if options["-w"] then exit
root_shell.start_terminal
end function
proxies = PROXY_FILE.get_content.split(char(10)).compact
if proxies.len > 0 then
print "you arealdy have hacked proxies, do you want to reuse them?" + char(10)
for i in proxies.indexes
pr
int "[" + i + "] " +
proxies[i]
pr
oxies[i] = [@re_hack, proxies[i],
proxies[i]
]
end for
print "[" + pr
oxies.
len + "]
hack a new one"
option = user_input("select a option: ")
pr
oxies.
push ["return", null, "
hack a new one"
]
if proxies.hasIndex(
option
) then
machine = new Machine
machine.init(proxies[option], PASSWORDS_DISK, EXPLOITS_DISK)
root_shell = machine.quick_attack(true, TABLEATTACK_SCRIPT)
root_shell.clear_logs(EMPTY_LOG_PATH)
root_shell.start_terminal
end if
option
_selector proxies
end if
while true
machine = new Machine
machine.init(
machine.random
_ip, PASSWORDS_DISK, EXPLOITS_DISK)
machine.init(
rnd
_ip, PASSWORDS_DISK, EXPLOITS_DISK)
root_shell = machine.quick_attack(true, TABLEATTACK_SCRIPT)
if root_shell == null then continue
PROXY_FILE.set_content(PROXY_FILE.get_content + char(10) + machine.ip)
machine.save_exploits
root_shell.clear_logs(EMPTY_LOG_PATH)
root_shell.start_terminal
end while
end function
import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
Thor.init(Command, "proxy")
libs/thor.src
ThorParam = {}
ThorParam.init = function(obj)
self.name = obj
if obj isa list then self.name = obj[0]
if obj isa map then self.name = obj.indexes[0]
self.description = null
if obj isa list then self.description = obj[1]
if obj isa map then self.description = obj.values[1]
self.is_required = self.name[-1] == "*"
self.is_optional = not self.is_required
end function
ThorCommand = {}
ThorCommand.init = function(func, sig, name)
self.name = name
self.func = @func
if sig.hasIndex("description") then self.description = sig["description"]
if sig.hasIndex("args") then
f = function(o)
r = new ThorParam
r.init(o)
return r
end function
self.args = sig["args"].map(@f)
end if
if sig.hasIndex("options") then
f = function(obj)
param = {}
param["name"] = obj.indexes[0]
param["description"] = obj[obj.indexes[0]]
return param
end function
self.options = sig["options"].map(@f)
end if
end function
ThorCommand.required_args = function()
f = function(obj)
return obj.is_required
end function
return self.args.select(@f)
end function
ThorCommand.optional_args = function()
f = function(obj)
return self.required_args.indexOf(obj) == null
end function
return self.args.select(@f)
end function
ThorCommand.options_list = function()
f = function(o)
return o.name
end function
return self.options.map(@f)
end function
ThorCommand.args_help = function()
out = self.name
for arg in self.args
out = out + " " + arg.name
end for
f = function(o)
return o.description != null
end function
args_with_description = self.args.select(@f)
if args_with_description.len > 0 then
out = out + char(10) * 2 + "args description:" + char(10)
for arg in args_with_description
out = out + arg.name + " : " + arg.description
end for
end if
return out
end function
ThorCommand.options_help = function()
out = "options for " + self.name + ":" + char(10)
for i in self.options
n = i.name
if typeof(i.name) == "list" then n = i.name.join(" or ")
out = out + n + " : " + i.description
if self.options.indexOf(i) < self.options.len - 1 then out = out + char(10)
end for
return out
end function
ThorCommand.help = function()
out = self.args_help + char(10) + char(10)
if self.options_list.len > 0 then
out = out + self.options_help + char(10) + char(10)
end if
out = out + "program description: " + char(10)
out = out + self.description
return out
end function
ThorCommand.exec = function()
self.func(self.passed_args.compact, self.passed_options)
end function
// class divider ---------------------------------------
ThorManager = {}
ThorManager.init = function(thor)
self.thor = thor
end function
ThorManager.eval_command = function(command)
used_args = self.thor.global_args
self.thor.global_args = self.thor.global_args
self.thor.used_options = self.thor.used_options + command.options_list.flat
for i in range(command.args.len - used_args.len - 1)
used_args.push(null)
end for
command["passed_args"] = used_args
command["passed_options"] = self.options_by_key(command)
self.thor.global_execution_queue.push(command)
end function
ThorManager.options_by_key = function(command)
scope = self
r = {}
get_value = function(o)
if o.indexOf("=") then
striped_options = scope.thor.striped_global_options
if striped_options.indexOf(o) then
value = scope.thor.global_options[striped_options.indexOf(o)]
return value[value.indexOf("=")+1:]
else
return null
end if
else
if scope.thor.global_options.indexOf(i) != null then return true
return null
end if
end function
for o in command.options_list
if typeof(o) == "list" then
v = null
for i in o
if get_value(i) != null then v = get_value(i)
end for
for i in o
r[i] = v
end for
else
r[o] = get_value(o)
end if
end for
return r
end function
// class divider ---------------------------------------
Thor = {}
Thor.init = function(class, main_func_name)
self.class = null
self.global_args = []
self.passed_args_count = 0
self.global_options = []
self.used_options = []
self.global_execution_queue = []
self.manager = new ThorManager
self.manager.init(self)
main_command = new ThorCommand
main_command.init(class[main_func_name], class[main_func_name+"_sig"], main_func_name)
self.params_to_args_options(params)
self.manager.eval_command(main_command)
self.catch_errors
self.exec_queue
end function
Thor.striped_global_options = function()
f = function(ob)
if ob.indexOf("=") then
return ob[:ob.indexOf("=")+1]
end if
return ob
end function
return self.global_options.map(@f)
end function
Thor.params_to_args_options = function(params)
// filter for args
f = function(p)
return p[0] == "-"
end function
args = params.reject(@f)
options = {}
f = function(param)
return param[:1] == "-" and param.indexOf("=") == null
end function
params_options = params.select(@f)
f = function(param)
if param[:2] != "--" and param.len > 2 then
r = []
for i in param[1:].values
r.push("-" + i)
end for
return r
else
return param
end if
end function
params_options = params_options.map(@f).flat.uniq
f = function(param)
return param[:1] == "-" and param.indexOf("=") != null
end function
params_value_options = params.select(@f)
options = params_options + params_value_options
self.global_args = args
self.passed_args_count = args.len
self.global_options = options
end function
Thor.catch_errors = function()
if self.global_options.indexOf("-h") != null or self.global_options.indexOf("--help") != null then
print(self.global_execution_queue[-1].help)
exit()
end if
f = function(c)
return c.required_args.len
end function
required_args = self.global_execution_queue.map(@f)
if self.passed_args_count < required_args.sum then
print("error: required params not passed, check the docs")
exit()
end if
used_options = self.used_options + ["-h", "--help"] //cant use self inside the block
f = function(p)
return used_options.indexOf(p) == null
end function
undefined_options = self.striped_global_options.select(@f)
for i in undefined_options
print("error: " + i + " option is not defined, check the docs")
exit()
end for
end function
Thor.exec_queue = function()
self.global_execution_queue[-1].exec
end function
src/shell.src
// extend shell objs
map.clear_logs = function(empty_log_path)
if typeof(self) != "shell" then
print "<color=red>error obj is not an shell</color>"
end if
shell = self
comp = shell.host_computer
new_log_name = empty_log_path.split("/")[-1]
get_shell.scp(empty_log_path, "/var", shell)
new_log_file = comp.File("/var/"+new_log_name)
copy_out = new_log_file.copy("/var", "system.log")
if copy_out != 1 then print copy_out
new_log_file.rename(".log")
return shell
end function
map.install_rserver = function(installer_script)
if typeof(self) != "shell" then
print "<color=red>error obj is not an shell</color>"
end if
shell = self
comp = shell.host_computer
if comp.File("/home/guest/rinstaller.src") != null then
comp.File("/home/guest/rinstaller.src").delete
end if
comp.touch("/home/guest", "rinstaller.src")
comp.File("/home/guest/rinstaller.src").set_content(installer_script.get_content)
print "building installer"
shell.build("/home/guest/rinstaller.src", "/home/guest")
shell.launch("/home/guest/rinstaller")
return shell
end function
src/machine.src
MachineServices = {}
MachineServices = {}
//class eval shit
exploits_inspect = function(obj, scope)
exploits_len = 0
if scope.hasIndex("exploits") then exploits_len = scope.exploits.len
return scope.exploits.len
end function
Service.attrs.push("exploits")
Service.set_exploits = function()
exploits = self.machine.json.to_object(self.machine.exploits_disk.read_chars)
if exploits.hasIndex(self.info_to_key) then
self.scan = new Scan
self.scan.init(self.nmap.ip, self.port)
self.exploits = []
for x in exploits[self.info_to_key]
exploit = new ScanExploit
exploit.init(self.scan, x)
self.exploits.push(exploit)
end for
else
self.scan = new Scan
self.scan.init(self.nmap.ip, self.port)
self.scan.execute
self.exploits = self.scan.get_exploits
end if
end function
// require passwords list set in custom_object
Service.quick_root_shell = function(attack_script)
for x in self.exploits
x.set_result
if typeof(x.result) != "shell" then continue
remote_shell = x.result
remote_comp = remote_shell.host_computer
if remote_comp.File("/home/guest/tableAttack.src") != null then
remote_comp.File("/home/guest/tableAttack.src").delete
end if
remote_comp.touch("/home/guest", "tableAttack.src")
remote_comp.File("/home/guest/tableAttack.src").set_content(attack_script.get_content)
print "building script"
remote_shell.build("/home/guest/tableAttack.src", "/home/guest")
remote_shell.launch("/home/guest/tableAttack")
root_shell = get_custom_object.shell
return root_shell
end for
return null
end function
Machine = {}
//Machine.passwords_list : required passwords list
//Machine.table_attack_script : required table attack script
Machine.services_inspect = function(obj, scope)
f = function(o)
exploits_len = 0
if o.hasIndex("exploits") then exploits_len = o.exploits.len
return o.inspect(["info", [exploits_len, "exploits_len"], "port"])
end function
return scope.services.map(@f)
end function
Machine.attrs = ["ip", [@Machine.services_inspect, "services"]]
Machine.metaxploit = null //required
Machine.init = function(ip, passwords_disk, exploits_disk)
self.ip = ip
self.set_services
self.passwords_disk = passwords_disk
self.passwords = self.passwords_disk.read_chars.split(char(10))
self.exploits_disk = exploits_disk
if self.exploits_disk.read_chars.len == 0 then
self.exploits_disk.write("{}")
end if
self.json = new JSON
if not get_custom_object.hasIndex("passwords") then
get_custom_object.passwords = self.passwords
end if
end function
end function
Machine.save_exploits = function()
for s in self.services
key = s.info_to_key
exploits = []
if s.hasIndex("exploits") == 0 then continue
for x in s.exploits
x_obj = {}
x_obj["address"] = x.address
x_obj["value"] = x.value
x_obj["requirements"] = x.requirements
x_obj["requirements_len"] = x.requirements_len
if x.hasIndex("result") == 1 then x_obj["result"] = typeof(x.result)
exploits.push x_obj
end for
exploits_db = self.json.to_object(self.exploits_disk.read_chars)
exploits_db[key] = exploits
self.exploits_disk.nuke
self.exploits_disk.write(self.json.to_string(exploits_db))
end for
end function
Machine.quick_attack = function(only_routers = true, table_attack_script)
target_services = self.services
if only_routers == true then
f = function(o)
return o.port == null
end function
target
_service
s.map(@f)
target_services = [self.router
_service
]
end if
for service in target_services
service.set_exploits
root_shell = service.quick_root_shell(table_attack_script)
if typeof(root_shell) == "shell" then return root_shell
end for
return null
end function
Machine.random_ip = function()
first_byte_range = range(0, 255)
first_byte_range.remove(192) //reserved
first_byte_range.remove(191) //reserved
first_byte_range.remove(0) //reserved
first_byte_range.remove(10) //private
first_byte_range.remove(172) //private
first_byte_range.remove(128) //reserved
first_byte_range.remove(223) //reserved
rest_byte_range = range(0,255)
ip = []
ip.push(floor(rnd() * first_byte_range.len))
for i in range(2)
ip.push(floor(rnd() * rest_byte_range.len))
end for
ip = ip.join(".")
if is_valid_ip(ip) and get_router(ip) and get_shell.ping(ip) then
return ip
end if
return self.random_ip
end function
Machine.set_services = function()
self.nmap = new Nmap
self.nmap.init(self.ip)
self.nmap.machine = self
self.services = self.nmap.services
for s in self.services
s.machine = self
end for
end function
Machine.router_service = function()
for s in self.services
if s.port == null then return s
end for
return null
end function
Machine.open_services = function()
f = function(o)
return o.status == "open"
end function
return self.services.select(@f)
end function
// this will get more complicated later on, i want to choose a port that i have the most change of getting in
// so i can check a database of exploits see or see the local ip with most ports open etc
Machine.most_vulnerable_service = function()
if self.services.len == 1 then return self.services[0]
if self.services.len == 0 then return null
with_smallest_version = self.services[0]
for service in self.services[1:]
if service.version_to_int < with_smallest_version.version_to_int then
with_smallest_version = service
end if
end for
return with_smallest_version
end function
libs/optionSelector.src
// expect a l(list) containing this structure [func, params, display_text]
// also instead of a func in the first param you can set the string "return" to make the function return instead
option_selector = function(m)
while true
for i in m.indexes
print "[<color=yellow>" + i + "</color>] " + m[i][2]
end for
selected = user_input("select a option: ").to_int
if selected isa string or m.hasIndex(selected) == false then
print "<color=red>ERROR: invalid option, try again</color>"
continue
end if
selected = m[selected]
if selected[0] == "return" then return
selected[0](selected[1])
return
end while
end function
cli/npcRshell.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/machine.src") // exports Machine, MachineService, depends on Scan, Nmap , Json, rnd_ip
import_code("/home/me/h/src/shell.src") // extend map
TABLEATTACK_SCRIPT = get_shell.host_computer.File(home_dir + "/Config/tableAttack.src")
EMPTY_LOG_PATH = home_dir + "/Config/emptyLog"
RSERVER_INSTALLER_SCRIPT = get_shell.host_computer.File(home_dir + "/Config/rserverInstaller.src")
PASSWORDS_DISK = new Disk
PASSWORDS_DISK.init(home_dir + "/Config", "passwords")
EXPLOITS_DISK = new Disk
EXPLOITS_DISK.init(home_dir + "/Config", "exploits")
Machine.metaxploit = include_lib("/lib/metaxploit.so")
Scan.metaxploit = include_lib("/lib/metaxploit.so")
Command = {}
Command.npcRsrv_sig = {}
Command.npcRsrv_sig["description"] = "hack a random pc and setup rshell server in it"
Command.npcRsrv_sig["args"] = []
Command.npcRsrv_sig["options"] = [{["-w", "--wipe"]: "wipe the server logs instead of connecting"}]
Command.npcRsrv = function(args = [], options = {})
while true
machine = new Machine
machine.init(rnd_ip, PASSWORDS_DISK, EXPLOITS_DISK)
if machine.open_services.len == 0 then continue
server_shell = null
server_port = null
for s in machine.open_services
s.set_exploits
shell = s.quick_root_shell(TABLEATTACK_SCRIPT)
if shell != null then
server_shell = shell
server_port = s.port
break
end if
end for
if server_shell == null then continue
server_shell.clear_logs(EMPTY_LOG_PATH)
router_shell = machine.router_service
router_shell.set_exploits
router_shell = router_shell.quick_root_shell(TABLEATTACK_SCRIPT)
if router_shell == null then continue
router_shell.clear_logs(EMPTY_LOG_PATH)
machine.save_exploits
server_shell.install_rserver(RSERVER_INSTALLER_SCRIPT)
server_shell.start_terminal
end while
end function
import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
Thor.init(Command, "npcRsrv")
src/rndIP.src
rnd_ip = function()
first_byte_range = range(0, 255)
first_byte_range.remove(192) //reserved
first_byte_range.remove(191) //reserved
first_byte_range.remove(0) //reserved
first_byte_range.remove(10) //private
first_byte_range.remove(172) //private
first_byte_range.remove(128) //reserved
first_byte_range.remove(223) //reserved
rest_byte_range = range(0,255)
ip = []
ip.push(floor(rnd() * first_byte_range.len))
for i in range(2)
ip.push(floor(rnd() * rest_byte_range.len))
end for
ip = ip.join(".")
if is_valid_ip(ip) and get_router(ip) and get_shell.ping(ip) then
return ip
end if
return rnd_ip
end function
src/rserverInstaller.src
rnd_ip = function()
first_byte_range = range(0, 255)
first_byte_range.remove(192) //reserved
first_byte_range.remove(191) //reserved
first_byte_range.remove(0) //reserved
first_byte_range.remove(10) //private
first_byte_range.remove(172) //private
first_byte_range.remove(128) //reserved
first_byte_range.remove(223) //reserved
rest_byte_range = range(0,255)
ip = []
ip.push(floor(rnd() * first_byte_range.len))
for i in range(2)
ip.push(floor(rnd() * rest_byte_range.len))
end for
ip = ip.join(".")
if is_valid_ip(ip) and get_router(ip) and get_shell.ping(ip) then
return ip
end if
return rnd_ip
end function
get_hackshop_ip = function()
while true
ip = rnd_ip
router = get_router(ip)
ports = router.used_ports
is_hack_shop = false
for port in ports
info = router.port_info(port)
if info.indexOf("repository") != null then
return ip
end if
end for
end while
end function
repo_ip = get_hackshop_ip
get_shell.launch("/bin/apt-get", "addrepo " + repo_ip)
get_shell.launch("/bin/apt-get", "update")
get_shell.launch("/bin/apt-get", "install librshell.so")
rshelld = include_lib("/lib/librshell.so")
if not rshelld then exit("Error: Missing librshell.so library in the /lib path or the current folder")
output = rshelld.install_service
if output != true then exit(output)
print("<b>Type 'Browser.exe " + get_router.local_ip + ":8080' to access the router configuration to make sure the service it's accesible</b>")