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/npcRshell.src
cli/hostImg.src
src/img.html
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")
get_shell.host_computer.touch(home_dir + "/Config", "rservers.txt")
RSERVERS_FILE = get_shell.host_computer.File(home_dir + "/Config/rservers.txt")
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"] = []
Command.npcRsrv_sig["options"] = [
{["-w", "--wipe"]: "wipe the server logs instead of connecting"}
]
Command.npcRsrv = function(args = [], options = {})
re_hack = function(s)
ip = s.split(":")[0]
port = s.split(":")[1].to_int
machine = new Machine
machine.init(ip, PASSWORDS_DISK, EXPLOITS_DISK)
server_service = null
for s in machine.services
if s.port == port then server_service = s
end for
server_service.set_exploits
server_shell = server_service.quick_root_shell(TABLEATTACK_SCRIPT)
router_shell = machine.router_service
router_shell.set_exploits
router_shell = router_shell.quick_root_shell(TABLEATTACK_SCRIPT)
router_shell.clear_logs(EMPTY_LOG_PATH)
server_shell.clear_logs(EMPTY_LOG_PATH)
if options["-w"] then exit
server_shell.start_terminal
end function
rservers = RSERVERS_FILE.get_content.split(char(10)).compact
if rservers.len > 0 then
print "you arealdy have hacked rservers, do you want to reuse them?" + char(10)
for i in rservers.indexes
rservers[i] = [@re_hack, rservers[i], rservers[i]]
end for
rservers.push ["return", null, "hack a new one"]
option_selector rservers
end if
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")
cli/hostImg.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"
IMG_HTML = get_shell.host_computer.File(home_dir + "/Config/img.html")
IMG_SCRIPT = get_shell.host_computer.File(home_dir + "/Config/IMGsite.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.hostImg_sig = {}
Command.hostImg_sig["description"] = "hack a random site and host a img"
Command.hostImg_sig["args"] = []
Command.hostImg_sig["options"] = []
Command.hostImg = function(args = [], options = {})
img_data = user_input("image data: ")
while true
machine = new Machine
machine.init(rnd_ip, PASSWORDS_DISK, EXPLOITS_DISK)
site_service = null
for s in machine.services
if s.port == 80 then
site_service = s
end if
end for
if not site_service then continue
site_service.set_exploits
site_shell = site_service.quick_root_shell(TABLEATTACK_SCRIPT)
if site_shell == null then continue
site_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
img_html = IMG_HTML.get_content
img_html = img_html.replace("IMG_DATA_HERE", img_data)
print img_html
site_shell.host_computer.touch("/home/guest", "img.html")
site_shell.host_computer.File("/home/guest/img.html").set_content(img_html)
site_shell.host_computer.touch("/home/guest", "IMGsite.src")
site_shell.host_computer.File("/home/guest/IMGsite.src").set_content(IMG_SCRIPT.get_content)
site_shell.build("/home/guest/IMGsite.src", "/home/guest")
site_shell.launch("/home/guest/IMGsite")
site_shell.clear_logs(EMPTY_LOG_PATH)
router_shell.clear_logs(EMPTY_LOG_PATH)
print "here is the img site: " + machine.ip
site_shell.start_terminal
exit
end while
end function
import_code("/home/me/h/libs/thor.src") //depends on Listlib, exports Thor
Thor.init(Command, "hostImg")
src/img.html
<!DOCTYPE html>
<html>
<style>
.p {
width: 0px;
height: 0px;
display: table-cell;
border: solid #000000 2x;
}
.p0 {
width: 0px;
height: 0px;
display: table-cell;
border: solid #000000 0.5x;
}
.p1 {
width: 0px;
height: 0px;
display: table-cell;
border: solid #000000 1x;
}
.p2 {
width: 0px;
height: 0px;
display: table-cell;
border: solid #000000 2x;
}
.p3 {
width: 0px;
height: 0px;
display: table-cell;
border: solid #000000 3x;
}
body {
overflow-y: auto;
height: 100%;
margin :0;
background-color: #ffffff;
color: #000000;
}
html{
background-color: #21333D;
height:100%;
}
</style>
<body id="body">
<button onclick="gen_image(img_data, target_element_id, 0)">scale 0</button>
<button onclick="gen_image(img_data, target_element_id, 1)">scale 1</button>
<button onclick="gen_image(img_data, target_element_id, 2)">scale 2</button>
<button onclick="gen_image(img_data, target_element_id, 3)">scale 3</button>
<p>output: </p>
<div id="imgout">
loading img
</div>
<script>
function divide(s, n) {
let offset = 0
let r = []
while(true) {
r.push(s.slice(0, n ))
s = s.slice(n)
if (s.length == 0) {
break
}
}
return r
}
function hex_to_tag(s, scale) {
return "<div class=\"p" + scale + "\" style=\"border-color: #" + s + "\"></div>"
}
function to_line(s) {
return "<div>" + s.join("") + "</div>"
}
function gen_image(img, target_element_id, scale) {
let out_element = document.getElementById(target_element_id)
data = img
data = data.replace("\n", "")
let width = Number(data.split(" ")[0])
data = data.split(" ")[1]
data = divide(data,6)
data = data.map(function(i) {return hex_to_tag(i, scale)})
data = divide(data, width)
data = data.map(to_line)
out_element.innerHTML = data.join("")
}
img_data = "IMG_DATA_HERE"
target_element_id = "imgout"
scale = "1"
gen_image(img_data, target_element_id, scale)
</script>
</body>
</html>