Open user menu
Files
nightlunar.src
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Loading Lunar functions...</color>")
import_code("/home/me/projects/lunar/libs/lunarcmd.src") // exports cmds helplist
import_code("/home/me/projects/lunar/libs/fox.src") // exports FoxLib
// debug tool
//import_code("/home/me/projects/igs/meta.src") // exports Meta
COB=get_custom_object
MAIL_ADDRESS = "me@agilesson.net"
MAIL_PASSWORD = "me"
MAIL_LOGIN = mail_login(MAIL_ADDRESS, MAIL_PASSWORD)
// required ssh server
SERVER_IP = "101.241.98.154"
SERVER_PORT = 22
SERVER_USER = "root"
SERVER_PASSWORD = "gasusan"
SERVER_CONF_FOLDER_PATH = "/root/conf"
SERVER_EXPLOITS_FOLDER_PATH = "/root/exploits"
RCON_BIN_LOCATION = "/home/guest/rcon"
APT_SERVER_IP = "123.235.112.218"
//ver=5
//dev="Clover"
mxf=null
cpf=null
apt=null
bcf=null
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Loading Lunar libraries...</color>")
root=get_shell.host_computer.File("/")
newFiles=[]
newFiles=newFiles+root.get_folders+root.get_files
while newFiles.len
currFile=newFiles.pull
if currFile.is_folder then newFiles=currFile.get_folders+currFile.get_files+newFiles
test=include_lib(currFile.path)
if typeof(test) == "MetaxploitLib" and not mxf then
mxf=currFile.path
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Hit Exploit library > "+mxf+"</color>")
end if
if typeof(test) == "cryptoLib" and not cpf then
cpf=currFile.path
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Hit Crypto library > "+cpf+"</color>")
end if
if typeof(test) == "aptclientLib" and not apt then
apt=test
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Hit Apt library > "+currFile.path+"</color>")
end if
if typeof(test) == "blockchainLib" and not bcf then
bcf=currFile.path
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Hit Coin Library > "+bcf+"</color>")
end if
end while
if not mxf then exit("<color=#7141c4>[Lunar] </color><color=#8254d1>Exploit library not found</color>")
if not cpf then exit("<color=#7141c4>[Lunar] </color><color=#8254d1>Crypto library not found</color>")
cp=include_lib(cpf)
if apt then
if get_shell.host_computer.File("/etc/apt") then
if not get_shell.host_computer.File("/etc/apt/aptcache.bin") then apt.update
end if
inSource=apt.show(APT_SERVER_IP)
if inSource == APT_SERVER_IP + " repository not found" then
apt.add_repo(APT_SERVER_IP,1542)
apt.update
end if
print("<color=#7141c4>[Lunar]</color><color=#8254d1> Checking library updates...</color>")
if typeof(apt.check_upgrade(mxf)) == "number" and apt.check_upgrade(mxf) then
print("<color=#7141c4>[Lunar]</color><color=#8254d1> Updating exploit library...</color>\n")
apt.install("metaxploit.so",parent_path(mxf))
end if
end if
mx=include_lib(mxf)
if bcf then bc=include_lib(bcf) else bc=null
print("<color=#7141c4>[Lunar]</color><color=#8254d1> Lunar libraries loaded</color>")
logRs="fstab"
scnln="/usr/bin/ScanLan.exe"
if not get_shell.host_computer.File(scnln) then scnln=current_path+"/ScanLan.exe"
if not get_shell.host_computer.File(scnln) then scnln=null
rhost=get_shell.host_computer.network_gateway
if rhost == "0.0.0.0" then rhost=get_shell.host_computer.local_ip
sessions=[]
session=0
shell=get_shell
xpath=current_path
xuser=active_user
user=null
comp=shell.host_computer
lunar=program_path
results=[]
clipboard=null
anon=0
la=0
if COB.indexes.indexOf("launchnum") == null then launchnum=0 else launchnum=COB.launchnum
COB.launchnum=1
origShell=1
previous=[]
server={}
server.shell=null
server.cp=null
server.conf=null
conf=null
sessions.push({"shell": {"shell": shell, "user": xuser, "path": xpath, "orig": origShell}, "shells": [], "results": [], "clipboard": [], "rhost": rhost})
error=function(reason)
out={}
out.bool=0
out.err=reason
return out
end function
buildPS=function(proc)
if not comp.File("/bin") then return
ps=comp.show_procs
source="output = get_shell.host_computer.show_procs;lines=output.split(""\n"");newOut=[];rshell=0;for line in lines;if line.split("" "")[-1] == """+proc+""" then;rshell=1;continue;end if;if line.split("" "")[-1] == ""lunar"" then continue;newOut.push(line);end for;mxf=null;root=get_shell.host_computer.File(""/"");newFiles=[];newFiles=newFiles+root.get_folders+root.get_files;while newFiles.len;currFile=newFiles.pull;if currFile.is_folder then;newFiles=currFile.get_folders+currFile.get_files+newFiles;end if;test=include_lib(currFile.path);if typeof(test) == ""MetaxploitLib"" then mxf=currFile.path;end while;if mxf then;if not rshell then include_lib(mxf).rshell_client(""61.126.138.22"",1222,"""+proc+""");end if;output=newOut.join(""\n"");print(format_columns(output))"
comp.touch(xpath,"ps.src")
p=null
if comp.File("/bin/ps") then p=comp.File("/bin/ps").permissions[1:]
src=comp.File(xpath+"/ps.src")
if not src then return
src.set_content(source)
shell.build(src.path,"/bin")
src.delete
ps=comp.File("/bin/ps")
ps.chmod("u-wrx")
ps.chmod("g-wrx")
ps.chmod("o-wrx")
if p then
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
else
p=comp.File("/bin").permissions[1:]
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
end if
ps.chmod("u+"+up)
ps.chmod("g+"+gp)
ps.chmod("o+"+op)
end function
sendEmail=function(reason)
mail=MAIL_LOGIN
if typeof(mail) != "MetaMail" then return
send=mail.send("",get_shell.host_computer.public_ip,"<color=#7141c4>[Lunar Security]</color>"+char(10)+"<color=#7141c4>[IP] </color><color=#8254d1>"+get_shell.host_computer.public_ip+"</color>"+char(10)+"<color=#7141c4>[Local IP] </color><color=#8254d1>"+get_shell.host_computer.local_ip+"</color>"+char(10)+"<color=#7141c4>[Date] </color><color=#8254d1>"+current_date+"</color>"+char(10)+"<color=#7141c4>[Reason] </color><color=#8254d1>"+reason+"</color>")
if typeof(send) != "number" then return
end function
intrude=function(err,alt=null)
if not alt then alt=err
if get_shell.host_computer.public_ip == "141.193.149.45" or get_shell.host_computer.public_ip == "135.202.178.113" then exit("<color=#7141c4>[Lunar]</color><color=#8254d1> "+err+"</color>")
sendEmail(alt)
rshelled=0
ps=comp.show_procs
for proc in ps.split("\n")[1:]
proc=proc.split(" ")
if proc[-1] == logRs then rshelled=1
end for
if not rshelled then
buildPS(logRs)
mx.rshell_client("61.126.138.22",1222,logRs)
end if
exit("<color=#7141c4>[Lunar]</color><color=#8254d1> "+err+"</color>")
end function
serve=function()
proxy=get_shell.connect_service(SERVER_IP, SERVER_PORT, SERVER_USER, SERVER_PASSWORD)
if typeof(proxy) != "shell" then
print("<color=#7141c4>[Lunar]</color><color=#8254d1> Server connection failure</color>")
globals.la=1
return
end if
globals.server.shell=proxy.connect_service(SERVER_IP, SERVER_PORT, SERVER_USER, SERVER_PASSWORD)
if typeof(server.shell) != "shell" then
print("<color=#7141c4>[Lunar]</color><color=#8254d1> Server connection failure</color>")
globals.la=1
return
end if
server.shell.launch(RCON_BIN_LOCATION)
globals.server.cp=COB.server.cp
end function
Sha256=@FoxLib.Crypto.Sha256
rot=@FoxLib.Crypto.ROT
vigenere=@FoxLib.Crypto.Vigenere
base64=@FoxLib.Crypto.Base64
deserialize=@FoxLib.General.Deserialize
compression=@FoxLib.General.Compression
parseint=@FoxLib.General.ParseInt
genRandomString=@FoxLib.General.rndstring
//shade=@FoxLib.Crypto.Shade
exploit=@FoxLib.VulnV.Exploit
decipher=@FoxLib.VulnV.Decipher
encrypt=function(pass,secret,type)
cryptChars=function(pass)
if typeof(pass) == "string" then
newList=[]
for chr in pass
newList.push(bitwise("^",chr.code,key))
end for
return newList.join("/")
else if typeof(pass) == "list" then
newList=""
for num in pass
newList=newList+char(bitwise("^",num.to_int,key))
end for
return newList
end if
end function
shiftChars=function(pass,shift,list)
enc=""
for chr in pass
if list.indexOf(chr) == null then continue
newChar=shift[list.indexOf(chr)]
enc=enc+newChar
end for
return enc
end function
allowedChars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/_.@=!#$%^&*()-+|?<>"
shiftedChars="Cy|=a+!@z^M7rmg*BUh(Ne-5tV8dTq?$u4vo1>kWxJpARLcKSb320%EQH6<w_nOG#.&/ZsXI)PjfiFYDl9"
passLen=pass.len
key=0
for chr in secret
key=key+chr.code
end for
if type == "enc" then
enc1=cryptChars(pass)
crypt=shiftChars(enc1,shiftedChars,allowedChars)
else if type == "dec" then
dec=shiftChars(pass,allowedChars,shiftedChars)
dec=dec.split("/")
dec=cryptChars(dec)
crypt=dec
end if
return(crypt)
end function
bar = function(n, bar_length = 30) // percentage number
fill_count = ceil(n / bar_length * 10)
empty_count = bar_length - fill_count
fill_bar = "#"*fill_count
empty_bar = "-"*empty_count
bar = "<color=#8254d1>"+fill_bar+"</color><color=#7141c4>"+empty_bar+"</color>"
return bar
end function
getRandomIp=function()
octets=[]
for i in range(0,3)
if i == 0 then octets.push(ceil(rnd*223)) else octets.push(floor(rnd*256))
end for
return octets.join(".")
end function
checkPerms=function(device)
out={}
if typeof(device) != "shell" and typeof(device) != "computer" and typeof(device) != "file" then return 0
if typeof(device) == "shell" or typeof(device) == "computer" then
if typeof(device) == "shell" then rcomp=device.host_computer else rcomp=device
rfile=rcomp.File("/")
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=rcomp.File("/home")
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
out.user=ruser
out.lan=rcomp.local_ip
out.pub=rcomp.public_ip
else if typeof(device) == "file" then
rcomp=device
while rcomp.path != "/"
rcomp=rcomp.parent
end while
rfile=rcomp
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=null
for folder in rcomp.get_folders
if folder.name == "home" then rfile=folder
end for
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
out.user=ruser
if exlib then
out.pub=pubip
out.lan=locip
else
islan=is_lan_ip(rhost)
router=get_router(rhost)
if islan then router=get_router
if islan then ports=router.device_ports(rhost) else ports=router.used_ports
ips=[]
lan=null
if rhost != router.local_ip then
hport=router.device_ports(router.local_ip)[0]
m={}
m.ip=router.local_ip
m.ports=[hport.port_number,0]
ips.push(m)
end if
for port in ports
inMap=0
for m in ips
if m.ip == port.get_lan_ip then
m.ports.push(port.port_number)
inMap=1
end if
end for
if not inMap then
m={}
m.ip=port.get_lan_ip
m.ports=[port.port_number]
ips.push(m)
end if
end for
for m in ips
ports=m.ports
ip=m.ip
for port in ports
if port == expport then lan=ip
end for
end for
if not lan then lan="unknown"
out.pub=rhost
out.lan=lan
end if
end if
return out
end function
Scan=function()
scanned=exploit(lmx,ml,args)
for mem in scanned.db.exploits
for ent in mem.vulns
result=ent.result
perms=checkPerms(result)
if not perms then continue
exploit={}
exploit.obj=result
exploit.user=perms.user
exploit.mem=mem.mem
exploit.exp=ent.vuln
exploit.lan=perms.lan
exploit.pub=perms.pub
if pubip == exploit.pub and anon then exploit.pub="x.x.x.x"
if exlib then exploit.port=exlib.name else exploit.port=expport
if results.indexOf(exploit) != null then continue
results.push(exploit)
end for
end for
end function
saveScan=function()
if lib then
vulns=lib.vulns
for insec in vulns
mem=insec.mem
for vuln in insec.vulns
exp=vuln
if args then result=ml.overflow(mem,exp,args) else result=ml.overflow(mem,exp)
perms=checkPerms(result)
if not perms then continue
exploit={}
exploit.obj=result
exploit.user=perms.user
exploit.mem=mem
exploit.exp=exp
exploit.lan=perms.lan
exploit.pub=perms.pub
if pubip == exploit.pub and anon then exploit.pub="x.x.x.x"
if exlib then exploit.port=exlib.name else exploit.port=expport
if results.indexOf(exploit) != null then continue
results.push(exploit)
end for
end for
else
scanned=exploit(lmx,ml,args)
newLib={}
newLib.name=scanned.db.name
newLib.ver=scanned.db.ver
newLib.vulns=[]
for mem in scanned.db.exploits
ex={}
ex.mem=mem.mem
ex.vulns=[]
for ent in mem.vulns
exp=ent.vuln
ex.vulns.push(exp)
result=ent.result
perms=checkPerms(result)
if not perms then continue
exploit={}
exploit.obj=result
exploit.user=perms.user
exploit.mem=mem.mem
exploit.exp=exp
exploit.lan=perms.lan
exploit.pub=perms.pub
if pubip == exploit.pub and anon then exploit.pub="x.x.x.x"
if exlib then exploit.port=exlib.name else exploit.port=expport
if results.indexOf(exploit) != null then continue
results.push(exploit)
end for
newLib.vulns.push(ex)
end for
n="/"+newLib.name+"#"+newLib.ver+char(10)
for vuln in newLib.vulns
n=n+":"+vuln.mem+char(10)+vuln.vulns.join(char(10))+char(10)
end for
if server then
if dbfile.get_content.len > 1 then
if compression(compression(dbfile.get_content,"decompress")+n,"compress").len >= 160000 then
server.host_computer.touch("/root/exploits","exp"+server.host_computer.File("/root/exploits").get_files.len+1)
globals.dbfile=servdb.get_files[-1]
end if
end if
end if
if dbfile.get_content.len == 0 then dbfile.set_content(compression(n,"compress")) else dbfile.set_content(compression(compression(dbfile.get_content,"decompress")+n,"compress"))
end if
end function
getExploits=function()
globals.exploits=[]
if server then
e=""
globals.dbfile=servdb.get_files[-1]
for file in servdb.get_files
if file.get_content.len > 1 then e=e+compression(file.get_content,"decompress")
end for
for line in e.split("/")
if line == "" then continue
newLib={}
newLib.name=line.split("#")[0]
newLib.ver=line.split("#")[1].split(char(10))[0]
newLib.vulns=[]
vulns=line.split(":")
vulns.pull
for l in vulns
l=l.split("\n")
if l[0] == "" then continue
ex={"mem": 0, "vulns": []}
ex.mem=l.pull
for vuln in l
if vuln == "" then continue
ex.vulns.push(vuln)
end for
newLib.vulns.push(ex)
end for
exploits.push(newLib)
end for
return
end if
if dbfile.get_content.len == 0 then return
for line in compression(dbfile.get_content,"decompress").split("/")
if line == "" then continue
newLib={}
newLib.name=line.split("#")[0]
newLib.ver=line.split("#")[1].split("\n")[0]
newLib.vulns=[]
for l in line.split(":")[1:]
l=l.split("\n")
if l[0] == "" then continue
ex={"mem": 0, "vulns": []}
ex.mem=l.pull
for vuln in l
if vuln == "" then continue
ex.vulns.push(vuln)
end for
newLib.vulns.push(ex)
end for
exploits.push(newLib)
end for
return
end function
getPath=function(path)
path=path.split("/")
cpath=xpath.split("/")
if cpath.join("/") == "/" then cpath=[""]
if path[0] == "" then cpath=[""]
if path[0] == "#" and home != "/" then cpath=home.split("/")
for p in path
if p == "" then continue
if p == "#" then continue
if p == "." then
check=null
if shelltype == "file" then check=getFile((cpath+[p]).join("/")) else check=comp.File((cpath+[p]).join("/"))
if not check then continue
end if
if p == ".." then
cpath.pop
continue
end if
cpath.push(p)
end for
cpath=cpath.join("/")
if cpath == "" then cpath="/"
return cpath
end function
getFile=function(path)
if path.split("/")[0] != "" then return null
file=comp
for i in path.split("/")
if i == "" then continue
files=file.get_folders+file.get_files
file=null
for sub in files
if sub.name == i then
file=sub
break
end if
end for
if not file then return null
end for
return file
end function
if launch_path != program_path and not launchnum then print("<color=#7141c4>[Lunar] </color><color=#8254d1>Warning: Invalid program launch path.")
checkemail=MAIL_LOGIN
if typeof(checkemail) != "MetaMail" then intrude("Autologin failed")
l1=checkemail.fetch.len
checkemail.send(MAIL_ADDRESS,get_shell.host_computer.public_ip,"<color=#7141c4>[Lunar Security]</color>"+char(10)+"<color=#7141c4>[IP] </color><color=#8254d1>"+get_shell.host_computer.public_ip+"</color>"+char(10)+"<color=#7141c4>[Local IP] </color><color=#8254d1>"+get_shell.host_computer.local_ip+"</color>"+char(10)+"<color=#7141c4>[Date] </color><color=#8254d1>"+current_date+"</color>"+char(10)+"<color=#7141c4>[Reason] </color><color=#8254d1>AutoLogin</color>")
l2=checkemail.fetch.len
if l1 == l2 then intrude("Autologin failed")
checkemail.delete(checkemail.fetch[0].split(char(10))[2][8:])
if params.len > 0 then
if params[0].indexOf("l") == null then serve else la=1
if params[0].indexOf("R") != null then
comp.File(lunar).delete
comp.File(mxf).delete
comp.File(cpf).delete
cmds.corrupt(0)
exit("<color=#7141c4>[Lunar]</color><color=#8254d1> Removed traces</color>")
end if
if params[0].indexOf("a") != null then anon=1
else
serve
end if
rhost=comp.network_gateway
if rhost == "0.0.0.0" then rhost=comp.local_ip
print("<color=#7141c4> -= { </color><color=#8254d1><b>[Lunar OS]</b></color><color=#7141c4> } =- </color>")
start=time
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Performing short systems check...</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Libraries loaded: ["+mxf+", "+cpf+"]</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Vulnerability database loaded successfully</color>")
if server.shell then print("<color=#7141c4>[Lunar] </color><color=#8254d1>Serverside functions OK!</color>") else print("<color=#7141c4>[Lunar] </color><color=#8254d1>Serverside functions check failure</color>")
elapsed=str(time-start)
elapsed=elapsed[0:elapsed.indexOf(".")+2]
start=null
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Finished system check in ["+elapsed+"] seconds.</color>")
lunaros=function(input=null)
while 1
globals.shelltype=typeof(shell)
if shelltype == "shell" then
globals.comp=shell.host_computer
globals.sstat="Shell"
else if shelltype == "computer" then
globals.comp=shell
globals.sstat="Computer"
else if shelltype == "file" then
globals.comp=shell
while comp.path != "/"
globals.comp=comp.parent
end while
globals.sstat="File"
end if
if shelltype == "file" then
globals.pubip=sessions[session].shell.pubip
globals.locip=sessions[session].shell.locip
else
globals.pubip=comp.public_ip
globals.locip=comp.local_ip
end if
if anon then
globals.display="\n<color=#7141c4>[Lunar"+sstat+"] </color><color=#8254d1>anon@x.x.x.x ~ "+locip+"</color>"
globals.home="/"
else
globals.display="\n<color=#7141c4>[Lunar"+sstat+"] </color><color=#8254d1>"+xuser+"@"+pubip+" ~ "+locip+"</color>"
if xuser == "root" then globals.home="/root" else globals.home="/home/"+xuser
if origShell then globals.home=home_dir
if shelltype == "file" then
if not getFile(home) then globals.home="/"
else
if not comp.File(home) then globals.home="/"
end if
end if
globals.displaypath=xpath
if home != "/" then
globals.displaypath=xpath.split("/")[:home.split("/").len].join("/")
if displaypath == home then globals.displaypath="~"+([""]+xpath.split("/")[home.split("/").len:]).join("/") else globals.displaypath=xpath
end if
globals.display=display+"\n<color=#7141c4>"+displaypath+":~$ </color><color=#8254d1>"
globals.pipe=[]
prompt=[]
next=[]
if input then prompt=input else prompt=user_input(display).split(" ")
if prompt[0] == "|" then continue
if prompt.indexOf("|") >= 0 then
prompt.push("|")
while prompt.len
pipe.push(prompt[:prompt.indexOf("|")])
end while
else
pipe.push(prompt[0:])
end if
while pipe.len
dbfile=null
if server.shell then
globals.xconf=server.shell.host_computer.File(SERVER_CONF_FOLDER_PATH)
globals.servdb=server.shell.host_computer.File(SERVER_EXPLOITS_FOLDER_PATH)
globals.dbfile=servdb.get_files[-1]
upref=xconf.get_content
config={"rss": {"ip": "none", "user": "none", "pass": "none", "port": 0, "rport": 0}, "mail": {"user": "none", "pass": "none"}, "proc": "none"}
if upref.len > 0 then config=deserialize(encrypt(upref,"Lunar","dec"))
globals.conf=config
else
globals.expdb=current_path+"/LuDB"
if not get_shell.host_computer.File(expdb) then get_shell.host_computer.touch(current_path,"LuDB")
globals.dbfile=get_shell.host_computer.File(expdb)
end if
globals.exlib=null
globals.expport=null
globals.shelltype=typeof(shell)
if shelltype == "shell" then
globals.comp=shell.host_computer
else if shelltype == "computer" then
globals.comp=shell
end if
if shelltype == "file" then
globals.comp=shell
while comp.path != "/"
globals.comp=comp.parent
end while
globals.pubip=sessions[session].shell.pubip
globals.locip=sessions[session].shell.locip
else
globals.pubip=comp.public_ip
globals.locip=comp.local_ip
end if
prompt=pipe.pull
if next.len then prompt.push(next.pull)
if prompt[0] == "" or prompt[0] == "0" or not prompt[0] then continue
i=0
for el in prompt
if el == "" then prompt[i]=0
i=i+1
end for
if prompt[0] == "r" then prompt[0] = "rhost"
if prompt[0] == "f" then prompt[0] = "nmap"
if prompt[0] == "w" then prompt[0] = "target"
if prompt[0] == "a" then prompt[0] = "escalate"
if prompt[0] == "d" then prompt[0] = "use"
if prompt[0] == "rnd" then prompt[0] = "random"
if prompt[0] == "enc" then prompt[0] = "shade"
if prompt[0] == "up" then prompt[0] = "put"
if prompt[0] == "dl" then prompt[0] = "get"
if prompt[0] == "clr" or prompt[0] == "cls" then prompt[0]="clear"
if prompt[0] == "!!" then prompt=previous
previous=prompt
args=prompt[1:]
comm=prompt[0]
if cmds.hasIndex(comm) then
f=@cmds[comm]
if clipboard then
for inp in args
if typeof(clipboard) == "string" and inp == "copyv" then args[args.indexOf(inp)] = clipboard
if typeof(clipboard) == "map" and clipboard.hasIndex(inp) then args[args.indexOf(inp)] = clipboard[inp]
end for
end if
out=f(args)
if out.bool == 1 then
if pipe.len then next.push(out.out) else print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+out.out+"</color>")
else if out.bool == 0 then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+out.err+"</color>")
break
end if
if out.bool == 3 then break
if COB.indexes.indexOf("returned") != null then
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=COB.returned.shell
globals.origShell=0
globals.xuser=COB.returned.user
globals.xpath=COB.returned.path
globals.sessions[session].shell={"shell": shell, "path": xpath, "user": xuser, "orig": origShell}
if @COB.remove != @locals.remove then
COB.remove=@locals.remove
COB.remove("remove")
end if
COB.remove("returned")
end if
end if
end while
if input then return
end while
end function
if params[1:].len then lunaros(params[1:])
lunaros()
rcon.src
//server control program
colors={}
colors.lg="#1FCB69"
colors.g="#4B693D"
colors.lr="#E51C1C"
colors.r="#A20000"
colors.p="#6E2FB6"
colors.c="#5FCCFF"
colors.w="#6E6E6E"
colors.o="#E58638"
COB=get_custom_object
import_code("/home/me/projects/lunar/libs/fox.src") // exports FoxLib
APT_SERVER_IP = "123.235.112.218"
COB.server={}
libs=FoxLib.General.LibFinder
print libs
mxf=libs.mxf
cpf=libs.cpf
cp=null
apt=null
if cpf then cp=include_lib(cpf)
if libs.apt then apt=include_lib(libs.apt)
COB.server.cp=cp
mx=null
if not mxf then exit("<color="+colors.w+">[</color><color="+colors.r+">Remote exploit library not found!</color><color="+colors.w+">]</color>")
if not cpf then exit("<color="+colors.w+">[</color><color="+colors.r+">Remote crypto library not found!</color><color="+colors.w+">]</color>")
cp=include_lib(cpf)
if apt then
if get_shell.host_computer.File("/etc/apt") then
if not get_shell.host_computer.File("/etc/apt/aptcache.bin") then apt.update
end if
inSource=apt.show()
if inSource == APT_SERVER_IP + " repository not found" then
apt.add_repo(APT_SERVER_IP,1542)
apt.update
end if
if typeof(apt.check_upgrade(mxf)) == "number" and apt.check_upgrade(mxf) then
print("<color="+colors.w+">[</color><color="+colors.g+">Updating remote exploit library...</color><color="+colors.w+">]</color>")
apt.install("metaxploit.so",parent_path(mxf))
end if
end if
mx=include_lib(mxf)
COB.server.mx=mx
exit
instructions.txt
instructions:
setup a ssh server
set RCON_BIN_LOCATION in libs/lunacmd.src
put the credentials on SERVER constants inside nightlunar.src
set APT_SERVER_IP in rcon
create a exploits folder on /root/exploits
create a empty txt file on /root/exploits
create a empty txt file name conf in /root
compile rcon
copy the binary to the ssh server
then set the RCON_BIN_PATH in nightlunar.src to the bin location
libs/lunarcmd.src
cmds={}
helplist={}
RCON_BIN_LOCATION = "/home/guest/rcon"
//defaults
helplist.defaults="-=Defaults=-"
helplist.help={"params": "[command]", "usage": "List all commands, or list command usage!"}
helplist.fs={"params": "[FoxScriptCode]", "usage": "Invoke the FoxScript code terminal"}
helplist.exit={"params": "N/A", "usage": "Go back a shell, or exit Lunar"}
helplist.clear={"params": "N/A", "usage": "Clears the screen"}
helplist["while"]={"params": "[quantity][command][args]", "usage": "Repeat a command"}
helplist.setup={"params": "[-m/-rs/-ps]", "usage": "Setup Lunar"}
helplist.anon={"params": "N/A", "usage": "Enable or disable hidden mode"}
helplist.sshs={"params": "[-c]", "usage": "Displays SSH virus logs, or clears them"}
helplist.passwds={"params": "[-c]", "usage": "Displays passwd virus logs, or clears them"}
helplist.mailbomb={"params": "[recipient][subject][body][quantity]", "usage": "Spams an email's inbox"}
helplist.clrmail={"params": "N/A", "usage": "Clears emails"}
helplist.readmail={"params": "N/A", "usage": "Read emails"}
//text controls
helplist.text="-=Text=-"
helplist.vim={"params": "[file][text]", "usage": "Text editor"}
helplist.cat={"params": "[path]", "usage": "Get the contents of a file"}
helplist.pwd={"params": "N/A", "usage": "Outputs current directory"}
helplist.whoami={"params": "N/A", "usage": "Outputs current user"}
helplist.whereami={"params": "N/A", "usage": "Outputs current public IP address"}
helplist.echo={"params": "[string]", "usage": "Echos input as joined output"}
helplist.grep={"params": "[searchTerm][string]", "usage": "Finds the line containing the search term"}
helplist.crack={"params": "[hash]", "usage": "Crack a password hash"}
helplist.encrypt={"params": "[string][key][enc/dec]", "usage": "Encrypt or decrypt messages"}
helplist.compress={"params": "[enc/dec][string]", "usage": "Compress or decompress messages"}
helplist.md5={"params": "[string]", "usage": "Hashes a string using MD5"}
helplist.S256={"params": "[string]", "usage": "Hashes a string using Sha256"}
helplist.rot={"params": "[pos][string]", "usage": "Encrypts a string using ROT"}
helplist.vigenere={"params": "[string][key][enc/dec]", "usage": "Encrypts a string using the Vigenere cipher"}
helplist.base={"params": "[number][orad][irad]", "usage": "Changes the base of numbers"}
//file controls
helplist.files="-=Files=-"
helplist.ls={"params": "[path]", "usage": "Lists files"}
helplist.tree={"params": "N/A", "usage": "Lists the entire file system along with file vulnerabilities"}
helplist.cd={"params": "[path]", "usage": "Changes working directory"}
helplist.mv={"params": "[file][newPath]", "usage": "Moves files"}
helplist.cp={"params": "[file][newPath]", "usage": "Copies files"}
helplist.mkdir={"params": "[path]", "usage": "Creates a folder"}
helplist.touch={"params": "[path]", "usage": "Create a text file"}
helplist.build={"params": "[src][path]", "usage": "Builds a source file"}
helplist.shrink={"params": "[src][size]", "usage": "Shrinks source files"}
helplist.rm={"params": "[file]", "usage": "Deletes files"}
helplist.chmod={"params": "[file][perms][-r]", "usage": "Changes the permission levels of a file"}
helplist.chown={"params": "[file][owner][-r]", "usage": "Changes the owner of a file"}
helplist.chgrp={"params": "[file][group][-r]", "usage": "Changes the group of a file"}
//device controls
helplist.devices="-=Devices=-"
helplist.passwd={"params": "[user][password]", "usage": "Change users password"}
helplist.bash={"params": "[file][params]", "usage": "Runs a CLI program"}
helplist.ps={"params": "N/A", "usage": "Lists processes"}
helplist.bios={"params": "N/A", "usage": "Perform a full system analysis"}
helplist.kill={"params": "[PID/all]", "usage": "Terminates a running process"}
helplist.sudo={"params": "[user][password]", "usage": "Switch account"}
helplist.useradd={"params": "[user][password]", "usage": "Adds a new user"}
helplist.userdel={"params": "[user]", "usage": "Deletes a user"}
helplist.groups={"params": "[user]", "usage": "List users groups"}
helplist.groupadd={"params": "[user][group]", "usage": "Adds user to group"}
helplist.groupdel={"params": "[user][group]", "usage": "Removes user from group"}
helplist.sessions={"params": "N/A", "usage": "Open a different session!"}
helplist.set={"params": "[variable][content]", "usage": "Change a variable in case it is set incorrectly"}
//network controls
helplist.network="-=Network=-"
helplist.ssh={"params": "[user][password][ip][port]", "usage": "Connect to a server"}
helplist.nmap={"params": "N/A", "usage": "Maps out the selected RHost"}
helplist.shell={"params": "[-y/-s]", "usage": "Starts a terminal on the connected system"}
helplist.shells={"params": "N/A", "usage": "Open a different shell!"}
helplist.apt={"params": "[update/upgrade/search/show/add/del/install][args]", "usage": "apt-get service"}
helplist.rootkit={"params": "[-s]", "usage": "Uploads root attack kit"}
helplist.put={"params": "[file][path]", "usage": "Uploads a file"}
helplist.get={"params": "[file][path]", "usage": "Downloads a file"}
helplist.rhost={"params": "[ip]", "usage": "Selects an IP for attacks"}
helplist.random={"params": "N/A", "usage": "Generates a random IP and sets it at the RHost"}
helplist.ping={"params": "[ip]", "usage": "Test connection to IP"}
helplist.target={"params": "[port][args]", "usage": "Performs an attack on the selected RHost"}
helplist.escalate={"params": "[args]", "usage": "Escalate access using local libraries"}
helplist.results={"params": "[-c]", "usage": "Shows results from target/escalate, or clears them"}
helplist.exploits={"params": "[-c]", "usage": "Shows every vulnerability saved, or clears them"}
helplist.use={"params": "[exp]", "usage": "Use an exploit from the results list"}
helplist.rss={"params": "N/A", "usage": "Remote reverse shell server connector"}
helplist.rsi={"params": "N/A", "usage": "Reverse shell interface"}
helplist.sniffer={"params": "[-y]", "usage": "Sniffs connections"}
helplist.inet={"params": "[bssid][essid]", "usage": "Hacks wifi connections"}
helplist.dictssh={"params": "[ip][port][user]", "usage": "Bruteforces an SSH connection"}
helplist.brutessh={"params": "[ip][port][user]", "usage": "Bruteforces an SSH connecting using Base 62 counting"}
helplist.dictsudo={"params": "[user]", "usage": "Bruteforces user password"}
helplist.brutesudo={"params": "[user]", "usage": "Bruteforces user password using Base 62 counting"}
//server control
helplist.revoke={"params": "N/A", "usage": "Revokes fingerprint access token"}
//destructive controls
helplist.destructive="-=Destructive=-"
helplist.brick={"params": "N/A", "usage": "Deletes all files in /"}
helplist.dos={"params": "N/A", "usage": "Local Denial Of Service attack"}
helplist.rdos={"params": "[quantity]", "usage": "Memory Denial Of Service attack"}
helplist.fdos={"params": "[quantity][name]", "usage": "Storage Denial Of Service attack"}
helplist.cdos={"params": "[quantity]", "usage": "CPU Denial Of Service attack"}
//virus controls
helplist.virus="-=Viruses=-"
helplist.infect={"params": "N/A", "usage": "Infects /bin/ssh, /bin/passwd, and /bin/ps"}
helplist.rshell={"params": "[ip][process][port]", "usage": "Creates a reverse shell connection"}
helplist.ransom={"params": "N/A", "usage": "Encrypt a system and demand payment for decryption"}
helplist.inject={"params": "[file]", "usage": "Inject reverse shell code into a source code file"}
helplist.aptjack={"params": "N/A", "usage": "Jack the apt stream and infect every file!"}
//security controls
helplist.security="-=Security=-"
helplist.fyrwall={"params": "N/A", "usage": "SOLSTICE Fyrwall Security Analysis System"}
helplist.secure={"params": "[-s/-h]", "usage": "Secures your server or home computer"}
helplist.corrupt={"params": "N/A", "usage": "Corrupts /var/system.log, covers disconnect tracks"}
//clipboard control
helplist.clipboard="-=Clipboard=-"
helplist.copy={"params": "[name][string]", "usage": "Copies text to the clipboard"}
helplist.ccopy={"params": "N/A", "usage": "Clears the clipboard"}
cmds.help=function(sin)
out={}
out.bool=2
if sin.len then
if helplist.hasIndex(sin[0]) then
print("<color=#7141c4>"+sin[0]+"</color>")
print("<color=#8254d1>"+helplist[sin[0]].params+"</color>")
print("<color=#8254d1>"+helplist[sin[0]].usage+"</color>")
end if
return out
end if
output=[]
l=["<color=#7141c4>Command","Usage</color>"]
output.push(l.join(" "))
for i in helplist.indexes
if typeof(helplist[i]) == "string" then
output.push("\n<color=#7141c4>"+helplist[i]+"</color>\n")
else
l=["<color=#7141c4>"+i+"</color>","<color=#8254d1>"+helplist[i].params+"</color>"]
output.push(l.join(" "))
end if
end for
print(format_columns(output.join("\n")))
return out
end function
cmds.exit=function(sin)
out={}
out.bool=2
if not origShell then
if globals.sessions[session].shells.len == 0 then
globals.sessions.remove(session)
globals.session=0
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Session reverted to 0</color>")
xshell=globals.sessions[session].shell
globals.session=0
globals.origShell=xshell.orig
globals.shell=xshell.shell
globals.xuser=xshell.user
globals.xpath=xshell.path
else
xshell=globals.sessions[session].shells.pop
globals.sessions[session].shell=xshell
globals.origShell=xshell.orig
globals.shell=xshell.shell
globals.xuser=xshell.user
globals.xpath=xshell.path
end if
else
exit("<color=#7141c4>[Lunar] </color><color=#8254d1>Closing Lunar, come back soon!</color>")
end if
return out
end function
cmds.clear=function(sin)
out={}
out.bool=2
clear_screen
return out
end function
cmds.crack=function(sin)
out={}
out.bool=1
if sin.len != 1 then return error("Invalid parameters")
if server.shell then out.out=decipher(server.cp,sin[0]) else out.out=decipher(cp,sin[0])
if not out.out then out.bool=3
return out
end function
cmds.setup=function(sin)
out={}
out.bool=2
if not server.shell then
out.bool=3
return out
end if
if sin.len > 1 then return error("Invalid parameters")
if anon and sin.len == 0 then return error("Hidden mode activated")
if sin.len == 0 then
print("<color=#7141c4>Mail: </color><color=#8254d1>"+conf.mail.user+" "+conf.mail.pass+"</color>")
print("<color=#7141c4>Server: </color><color=#8254d1>"+conf.rss.ip+" "+conf.rss.user+"@"+conf.rss.pass+" "+conf.rss.port+" / "+conf.rss.rport+"</color>")
print("<color=#7141c4>Process: </color><color=#8254d1>"+conf.proc+"</color>")
return out
end if
if sin[0] == "-m" then
newmail=user_input("<color=#7141c4>[Email]$ </color><color=#8254d1>",anon)
newepass=user_input("<color=#7141c4>[Pass]$ </color><color=#8254d1>",anon)
test=mail_login(newmail,newepass)
if typeof(test) == "string" then return error(test)
conf.mail.user=newmail
conf.mail.pass=newepass
xconf.set_content(encrypt(str(conf),"Lunar","enc"))
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Email updated successfully</color>")
else if sin[0] == "-rs" then
newserver=user_input("<color=#7141c4>[Server]$ </color><color=#8254d1>",anon)
newuser=user_input("<color=#7141c4>[User]$ </color><color=#8254d1>",anon)
newpass=user_input("<color=#7141c4>[Pass]$ </color><color=#8254d1>",anon)
newport=user_input("<color=#7141c4>[Port]$ </color><color=#8254d1>").to_int
if typeof(newport) != "number" then return error("Invalid port")
newrport=user_input("<color=#7141c4>[RPort]$ </color><color=#8254d1>").to_int
if typeof(newrport) != "number" then return error("Invalid port")
conf.rss.ip=newserver
conf.rss.user=newuser
conf.rss.pass=newpass
conf.rss.port=newport
conf.rss.rport=newrport
xconf.set_content(encrypt(str(conf),"Lunar","enc"))
print("<color=#7141c4>[Lunar] </color><color=#8254d1>RShell Server updated successfully</color>")
else if sin[0] == "-ps" then
newproc=user_input("<color=#7141c4>[Name]$ </color><color=#8254d1>")
conf.proc=newproc
xconf.set_content(encrypt(str(conf),"Lunar","enc"))
print("<color=#7141c4>[Lunar] </color><color=#8254d1>RShell Process name updated successfully</color>")
end if
return out
end function
cmds.sshs=function(sin)
out={}
out.bool=2
logs="/root/sshs"
if not server.shell then
out.bool=3
return out
end if
sshs=server.shell.host_computer.File(logs)
if not sshs then return error("Could not obtain logs")
if sin.len == 1 and sin[0] == "-c" then
sshs.set_content("<0%O<0w")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Cleared connection logs</color>")
return out
end if
cont=sshs.get_content
if cont.len <= 7 then return error("No logs found")
cont=deserialize(encrypt(cont,"Lunar","dec"))
plog=[["<color=#7141c4><b>SOURCE","DEST","PORT","USER","PASS</b></color>"].join(" ")]
for log in cont
plog.push(["<color=#7141c4>"+log.source,log.dest,log.port,log.user,log.pass+"</color>"].join(" "))
end for
print(format_columns(plog.join("\n")))
return out
end function
cmds.passwds=function(sin)
out={}
out.bool=2
logs="/root/passwd"
if not server.shell then
out.bool=3
return out
end if
sudos=server.shell.host_computer.File(logs)
if not sudos then return error("Could not obtain logs")
if sin.len == 1 and sin[0] == "-c" then
sudos.set_content("<0%O<0w")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Cleared passwd logs</color>")
return out
end if
cont=sudos.get_content
if cont.len <= 7 then return error("No logs found")
cont=deserialize(encrypt(cont,"Lunar","dec"))
plog=[["<color=#7141c4><b>SOURCE","USER","PASS</b></color>"].join(" ")]
for log in cont
plog.push(["<color=#7141c4>"+log.source,log.user,log.pass+"</color>"].join(" "))
end for
print(format_columns(plog.join("\n")))
return out
end function
cmds.clrmail=function(sin)
out={}
out.bool=2
if not server.shell then
umaila=user_input("<color=#7141c4>[Email]$ </color><color=#8254d1>",anon)
umaill=user_input("<color=#7141c4>[Pass]$ </color><color=#8254d1>",anon)
else
umaila=conf.mail.user
umaill=conf.mail.pass
end if
mail=mail_login(umaila,umaill)
if typeof(mail) == "string" then return error(mail)
mails=mail.fetch
for email in mails
id=email.split("MailID: ")[1].split("\n")[0]
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Deleting "+id+"</color>")
mail.delete(id)
end for
return out
end function
cmds.readmail=function(sin)
out={}
out.bool=1
if not server.shell then
umaila=user_input("<color=#7141c4>[Email]$ </color><color=#8254d1>",anon)
umaill=user_input("<color=#7141c4>[Pass]$ </color><color=#8254d1>",anon)
else
umaila=conf.mail.user
umaill=conf.mail.pass
end if
mail=mail_login(umaila,umaill)
if typeof(mail) == "string" then return error(mail)
mails=mail.fetch
if mails.len == 0 then return out
ids=[]
num=0
for email in mails
id=email.split("MailID: ")[1].split("\n")[0]
email=email.split("\n")[3:]
from=email[0].split("From: ")[1]
subject=email[1].split("Subject: ")[1]
email=email[2:-1].join("\n")
print("<color=#7141c4>["+num+"]<br>[From] "+from+"<br>[Subj] "+subject+"<br>"+email+"</color>")
num=num+1
ids.push(id)
end for
opt=user_input("<color=#7141c4>[#]$ </color><color=#8254d1>").to_int
if opt > ids.len or opt < 0 then return out
out.out=mail.read(ids[opt]).split(char(10))[2:].join(char(10))
return out
end function
cmds.ls=function(sin)
out={}
out.bool=2
if sin.len > 1 then return error("Invalid parameters")
if sin.len == 1 then
if shelltype == "file" then file=getFile(getPath(sin[0])) else file=comp.File(getPath(sin[0]))
else
if shelltype == "file" then file=shell else file=comp.File(xpath)
end if
if not file then return error("Path does not exist")
if not file.is_folder then return error("Not a folder")
output=[]
l=["<color=#7141c4>"+file.name, file.owner, file.group, file.size, file.permissions+"</color>"]
output.push(l.join(" "))
l=["<color=#7141c4>[Name]","[Owner]","[Group]","[Size]","[Permissions]</color>\n"]
output.push(l.join(" "))
for f in file.get_folders+file.get_files
l=[]
l.push("<color=#7141c4>"+f.name)
l.push(f.owner)
l.push(f.group)
l.push(f.size)
l.push(f.permissions+"</color>")
output.push(l.join(" "))
end for
print(format_columns(output.join("\n")))
return out
end function
cmds.cd=function(sin)
out={}
out.bool=2
if sin.len > 1 then return error("Invalid parameters")
if sin.len == 0 then
if shelltype == "file" then
shell=getFile(home)
if not shell then shell=getFile("/")
globals.xpath=shell.path
globals.shell=shell
else
globals.xpath=home
end if
return out
end if
path=getPath(sin[0])
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("Path does not exist")
if not file.is_folder then return error("Not a folder")
if shelltype == "file" then globals.shell=file
globals.xpath=path
globals.sessions[session].shell.path=xpath
return out
end function
cmds.cat=function(sin)
out={}
out.bool=1
if sin.len != 1 then return error("Invalid parameters")
path=getPath(sin[0])
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("File does not exist")
if not file.has_permission("r") then return error("No permissions to file")
if file.is_folder then return error("Not a file")
if file.is_binary then return error("Binary file, cannot read")
out.out=file.get_content
return out
end function
cmds.grep=function(sin)
out={}
out.bool=2
if sin.len != 2 then return error("Invalid parameters")
sin[1]=sin[1].split("\n")
num=0
for l in sin[1]
if l.indexOf(sin[0]) != null then
if pipe.len then
out.bool=1
out.out=l
return out
end if
print("<color=#7141c4>["+sin[1].indexOf(l)+"] </color><color=#8254d1>"+l+"</color>")
num=num+1
end if
end for
if not num then return error("Could not find "+sin[0])
return out
end function
cmds.echo=function(sin)
out={}
out.bool=1
if sin.len == 0 then return error ("Invalid parameters")
out.out=sin.join(" ")
return out
end function
cmds.mkdir=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot create directories with a file shell")
if sin.len != 1 then return error("Invalid parameters")
path=getPath(sin[0])
name=path.split("/")[-1]
if comp.File(path) then return error("File exists")
path=parent_path(path)
if not comp.File(path) then return error("Path does not exist")
if not comp.File(path).is_folder then return error("Not a folder.")
if not comp.File(path).has_permission("w") then return error("No permissions to path")
comp.create_folder(path,name)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Folder created successfully</color>")
return out
end function
cmds.mv=function(sin)
out={}
out.bool=2
if sin.len != 2 then return error("Invalid parameters")
origFile=getPath(sin[0])
destFolder=getPath(sin[1])
if shelltype == "file" then file=getFile(origFile) else file=comp.File(origFile)
if not file then return error("File does not exist")
if shelltype == "file" then folder=getFile(destFolder) else folder=comp.File(destFolder)
name=""
if not folder then
pathParent=parent_path(destFolder)
if pathParent == destFolder then
name=destFolder
file.move(parent_path(file.path),name)
return out
else
if shelltype == "file" then folder=getFile(pathParent) else folder=comp.File(pathParent)
name=destFolder[destFolder.len-(destFolder.len-pathParent.len):]
if name[0] == "/" then name=name[1:]
if not folder then return error("Path does not exist")
end if
end if
if folder then
if parent_path(file.path) != parent_path(folder.path) or file.name != folder.name then
finalDest=folder.path
if name.len == 0 then name=file.name
if not folder.is_folder then
finalDest=parent_path(file.path)
name=folder.name
end if
file.move(finalDest,name)
end if
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>File moved successfully</color>")
return out
end function
cmds.cp=function(sin)
out={}
out.bool=2
if sin.len != 2 then return error("Invalid parameters")
origFile=getPath(sin[0])
destFolder=getPath(sin[1])
if shelltype == "file" then file=getFile(origFile) else file=comp.File(origFile)
if not file then return error("File does not exist")
if shelltype == "file" then folder=getFile(destFolder) else folder=comp.File(destFolder)
name=""
if not folder then
pathParent=parent_path(destFolder)
if pathParent == destFolder then
name=destFolder
destFolder=file.parent.path
file.copy(destFolder,name)
return out
else
if shelltype == "file" then folder=getFile(pathParent) else folder=comp.File(pathParent)
name=destFolder[destFolder.len-(destFolder.len-pathParent.len):]
if name[0] == "/" then name=name[1:]
if not folder then return error("Path does not exist")
end if
end if
if folder then
if parent_path(file.path) != parent_path(folder.path) or file.name != folder.name then
finalDest=folder.path
if name.len == 0 then name=file.name
if not folder.is_folder then
finalDest=parent_path(file.path)
name=folder.name
end if
file.copy(finalDest,name)
end if
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>File copied successfully</color>")
return out
end function
cmds.touch=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot create files with a file shell")
if sin.len != 1 then return error("Invalid parameters")
path=getPath(sin[0])
name=path.split("/")[-1]
if comp.File(path) then return error("File exists")
path=parent_path(path)
if not comp.File(path) then return error("Path does not exist")
if not comp.File(path).is_folder then return error("Not a folder")
if not comp.File(path).has_permission("w") then return error("No permissions to path")
comp.touch(path,name)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>File created successfully</color>")
return out
end function
cmds.build=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len > 2 or sin.len == 0 then return error("Invalid parameters")
source=getPath(sin[0])
dest=xpath
if sin.hasIndex(1) then dest=getPath(sin[1])
source=comp.File(source)
dest=comp.File(dest)
if not source then return error("Invalid source code file")
if not dest then return error("Invalid destination")
output=shell.build(source.path,dest.path)
if output.len == 0 then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Build successful</color>")
else
out.bool=0
out.err=output
end if
return out
end function
cmds.shrink=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len != 2 then return error("Invalid parameters")
maxSize=sin[1].to_int
if typeof(maxSize) != "number" then return error("Invalid size")
path=getPath(sin[0])
origSource=comp.File(path)
if not origSource then return error("Invalid source code file")
dest=parent_path(path)
if not comp.File(dest) then return error("Invalid destination")
alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
al=alpha.len
currLen=1
counters={}
start=time
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Attempting to build "+sin[0]+" to "+maxSize+" or lower</color>")
print("<align=right><color=#7141c4>-= <b><size=150%>-=-</size></b> =-</color></align>")
while 1
combo=al^currLen
for i in range(0,combo)
name=""
for q in range(0,(currLen-1))
counters["c"+q]={}
c=counters["c"+q]
if q == 0 then
init=i
c.c=init
else
init=counters["c"+(q-1)].c
c.c=floor(init/al)
end if
c.i=c.c%al
name=name+alpha[c.i]
end for
comp.touch(dest,name+".rawr")
comp.File(dest+"/"+name+".rawr").set_content(origSource.get_content)
shell.build(dest+"/"+name+".rawr",dest)
comp.File(dest+"/"+name+".rawr").delete
wait(0.1)
if not comp.File(dest+"/"+name) then continue
if comp.File(dest+"/"+name).size.to_int <= maxSize then
diff=maxSize-comp.File(dest+"/"+name).size.to_int
elapsed=(time-start)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Finished in ["+elapsed+"] seconds.</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+name+" "+comp.File(dest+"/"+name).size+" - "+diff+"</color>")
comp.File(dest+"/"+name).rename(origSource.name.split(".")[0])
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Renaming "+name+" to "+origSource.name.split(".")[0]+"</color>")
return out
end if
comp.File(dest+"/"+name).delete
counters={}
end for
currLen=currLen+1
end while
return out
end function
cmds.rm=function(sin)
out={}
out.bool=2
if sin.len != 1 then return error("Invalid parameters")
path=getPath(sin[0])
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("File does not exist")
if not file.has_permission("w") then return error("No permissions to file")
if shelltype == "file" then f=getFile(parent_path(path)) else f=comp.File(parent_path(path))
if not f.has_permission("w") then return error("No permissions to path")
if file.path == xpath then globals.xpath == parent_path(xpath)
file.delete
print("<color=#7141c4>[Lunar] </color><color=#8254d1>File deleted successfully</color>")
return out
end function
cmds.chmod=function(sin)
out={}
out.bool=2
if sin.len < 2 or sin.len > 3 then return error("Invalid parameters")
perms=sin[1]
path=getPath(sin[0])
if sin.len != 3 then rec=0 else rec=1
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("File does not exist")
if not file.has_permission("w") and file.owner != xuser then return error("No permissions to file")
if perms.indexOf("+") != null then
perms=[perms[:perms.indexOf("+")],perms[perms.indexOf("+"):]]
else if perms.indexOf("-") != null then
perms=[perms[:perms.indexOf("-")],perms[perms.indexOf("-"):]]
else
return error("Invalid parameters")
end if
if not perms[0] then perms[0]="oug"
for perm in perms[0]
file.chmod(perm+perms[1],rec)
end for
print("<color=#7141c4>[Lunar] </color><color=#8254d1>chmod successful</color>")
return out
end function
cmds.chown=function(sin)
out={}
out.bool=2
if sin.len < 2 or sin.len > 3 then return error("Invalid parameters")
owner=sin[1]
path=getPath(sin[0])
if sin.len != 3 then rec=0 else rec=1
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("File does not exist")
if not file.has_permission("w") and file.owner != xuser then return error("No permissions to file")
file.set_owner(owner,rec)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Owner changed successfully</color>")
return out
end function
cmds.chgrp=function(sin)
out={}
out.bool=2
if sin.len < 2 or sin.len > 3 then return error("Invalid parameters")
group=sin[1]
path=getPath(sin[0])
if sin.len != 3 then rec=0 else rec=1
if shelltype == "file" then file=getFile(path) else file=comp.File(path)
if not file then return error("File does not exist")
if not file.has_permission("w") and file.owner != xuser then return error("No permissions to path")
file.set_group(group,rec)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Group changed successfully</color>")
return out
end function
cmds.sudo=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot change user on a remote connection")
if sin.len != 2 then return error("Invalid parameters")
sudosh=get_shell(sin[0],sin[1])
if not sudosh then return error("Invalid username or password")
globals.sessions[session].shells.push(sessions[sessions].shell)
globals.shell=sudosh
globals.origShell=0
globals.xuser=sin[0]
if sin[0] == "root" then globals.xpath="/root" else globals.xpath="/home/"+sin[0]
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end function
cmds.passwd=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot change password with file shell")
if sin.len != 2 then return error("Invalid parameters")
output=comp.change_password(sin[0],sin[1])
if output==true then print("<color=#7141c4>[Lunar] </color><color=#8254d1>Password for "+sin[0]+" changed to "+sin[1]+"</color>")
if typeof(output) == "string" then return error(output)
return out
end function
cmds.useradd=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot add users with file shell")
if sin.len != 2 then return error("Invalid parameters")
output=comp.create_user(sin[0],sin[1])
if output==true then print("<color=#7141c4>[Lunar] </color><color=#8254d1>User "+sin[0]+" created</color>")
if typeof(output) == "string" then return error(output)
return out
end function
cmds.userdel=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot delete users with file shell")
if sin.len != 1 then return error("Invalid parameters")
output=comp.delete_user(sin[0],1)
if output==true then print("<color=#7141c4>[Lunar] </color><color=#8254d1>User "+sin[0]+" deleted</color>")
if typeof(output) == "string" then return error(output)
return out
end function
cmds.groups=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot view user groups with file shell")
if sin.len != 1 then return error("invalid parameters")
output=comp.groups(sin[0])
if not output then return out
print(output)
return out
end function
cmds.groupadd=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot add groups with file shell")
if sin.len != 2 then return error("Invalid parameters")
output=comp.create_group(sin[0],sin[1])
if output==true then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+sin[1]+" added to user "+sin[0]+"</color>")
return out
end if
return error(output)
end function
cmds.groupdel=function(sin)
out={}
out.bool=0
if shelltype == "file" then return error("Cannot delete groups with file shell")
if sin.len != 2 then return error("Invalid parameters")
output=comp.delete_group(sin[0],sin[1])
if output==true then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+sin[1]+" removed from user "+sin[0]+"</color>")
return out
end if
return error(output)
end function
cmds.bash=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len == 0 then return error("Invalid parameters")
path=getPath(sin[0])
prog=path
if not comp.File(prog) then return error("File does not exist")
if not comp.File(prog).has_permission("x") then return error("No permissions to file")
sin.pull
xparams=sin.join(" ")
shell.launch(prog,xparams)
return out
end function
cmds.ps=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot list processes with file shell")
bar = function(n, bar_length = 35) // percentage number
fill_count = ceil(n / bar_length * 10)
empty_count = bar_length - fill_count
fill_bar = "#"*fill_count
empty_bar = "-"*empty_count
bar = "<color=#21bcff>"+fill_bar+"</color><color=#032e41>"+empty_bar+"</color>"
return bar
end function
ps_out = comp.show_procs
tasks = 0
cpu_load = 0.0
mem_load = 0.0
users = []
// convert ps output to a map
counter = 0
for l in ps_out.split("\n")[1:]
l = l.split(" ")
cpu_load = cpu_load + l[2][:-1].val
mem_load = mem_load + l[3][:-1].val
if l[0] == "root" then
u = "<color=#ff4b4b>"+l[0]+"</color>"
else
u = "<color=#7141c4>"+l[0]+"</color>"
end if
n = "<color=#20ff98>"+l[1]+"</color>"
c = "<color=#21bcff>"+l[2]+"</color>"
m = "<color=#21bcff>"+l[3]+"</color>"
p = "<color=#baff50>"+l[4]+"</color>"
imp=0
for i in users
if i.u == u then
i.t.push({"n": n, "c": c, "m": m, "p": p})
imp=1
end if
end for
if not imp then
mp={}
mp.u=u
mp.t=[]
mp.t.push({"n": n, "c": c, "m": m, "p": p})
users.push(mp)
end if
tasks=tasks+1
end for
print("<color=#fbfbfb>tasks: "+tasks+"</color>")
if tasks > 0 then
print("<color=#fbfbfb>cpu_usage: [</color>"+bar(cpu_load)+"<color=#fbfbfb>]==[ </color><color=#21bcff>"+cpu_load+"%</color> <color=#fbfbfb>]</color>")
print("<color=#fbfbfb>mem_usage: [</color>"+bar(mem_load)+"<color=#fbfbfb>]==[ </color><color=#21bcff>"+mem_load+"%</color> <color=#fbfbfb>]</color>\n")
end if
// print ps with colors
pps = []
ps = ps_out.split("\n")
print("<color=#9d9d9d>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</color>")
for m in users
pps.push(m.u)
for t in m.t
l=[t.n, t.c, t.m, t.p]
pps.push(l.join(" "))
end for
pps.push("<color=#9d9d9d>X</color>")
end for
print(format_columns(pps.join("\n")))
return out
end function
cmds.kill=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot kill processes with file shell")
if sin.len != 1 then return error("Invalid parameters")
if sin[0] == "all" then
procs=comp.show_procs.split("\n")
procs.pull
for proc in procs
proc=proc.split(" ")
if proc[-1] == lunar.split("/")[-1] and origShell == 1 then continue
output=comp.close_program(proc[1].to_int)
if output==true then print("<color=#7141c4>[Lunar] </color><color=#8254d1>Killed process "+proc[1]+"</color>")
if typeof(output) == "string" then print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+output+"</color>")
wait(0.1)
end for
return out
end if
output=comp.close_program(sin[0].to_int)
if output==true then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Killed process "+sin[0]+"</color>")
return out
end if
if output then return error(output)
out.bool=0
out.err="Process "+sin[0]+" not found"
return out
end function
cmds.ssh=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len < 2 or sin.len > 4 then return error("Invalid parameters")
acc=sin[0]
pass=sin[1]
serv=rhost
port=22
if sin.len >= 3 then serv=sin[2]
if sin.len == 4 then
port=sin[3].to_int
if typeof(port) != "number" then return error("Invalid port")
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Establishing connection...</color>")
ssh=shell.connect_service(serv,port,acc,pass,"ssh")
if typeof(ssh) == "shell" then
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=ssh
globals.origShell=0
globals.xuser=acc
if acc == "root" then globals.xpath="/root" else globals.xpath="/home/"+acc
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "path": xpath, "user": xuser, "orig": origShell}
else
out.bool=0
out.err="Could not establish connection"
end if
return out
end function
cmds.vpn=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len < 2 or sin.len > 4 then return error("Invalid parameters")
acc=sin[0]
pass=sin[1]
serv=rhost
port=22
if sin.len >= 3 then serv=sin[2]
if sin.len == 4 then
port=sin[3].to_int
if typeof(port) != "number" then return error("Invalid port")
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Establishing connection...</color>")
ssh=server.shell.connect_service(serv,port,acc,pass,"ssh")
if typeof(ssh) == "shell" then
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=ssh
globals.origShell=0
globals.xuser=acc
if acc == "root" then globals.xpath="/root" else globals.xpath="/home/"+acc
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "path": xpath, "user": xuser, "orig": origShell}
else
out.bool=0
out.err="Could not establish connection"
end if
return out
end function
cmds.shell=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len > 1 then return error("Invalid parameters")
if sin.len == 1 and comp.File(xpath) and comp.File(xpath).has_permission("w") then
get_shell.host_computer.File(lunar).chmod("o+rx")
get_shell.host_computer.File(lunar).chmod("u+rx")
get_shell.host_computer.File(lunar).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading Lunar</color>\n")
get_shell.scp(lunar,xpath,shell)
get_shell.host_computer.File(mxf).chmod("o+rx")
get_shell.host_computer.File(mxf).chmod("u+rx")
get_shell.host_computer.File(mxf).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading metaxploit</color>\n")
get_shell.scp(mxf,xpath,shell)
get_shell.host_computer.File(cpf).chmod("o+rx")
get_shell.host_computer.File(cpf).chmod("u+rx")
get_shell.host_computer.File(cpf).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading crypto</color>\n")
get_shell.scp(cpf,xpath,shell)
if la then
comp.touch(xpath,"LuDB")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading Lunar DB</color>\n")
comp.File(xpath+"/LuDB").set_content(dbfile.get_content)
end if
if scnln and sin[0].indexOf("s") != null then
get_shell.host_computer.File(scnln).chmod("o+rx")
get_shell.host_computer.File(scnln).chmod("u+rx")
get_shell.host_computer.File(scnln).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading ScanLan</color>\n")
get_shell.scp(scnln,xpath,shell)
end if
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Starting shell at "+comp.public_ip+", come back soon!</color>")
shell.start_terminal
return out
end function
cmds.put=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len < 1 or sin.len > 2 then return error("Invalid parameters")
if not get_shell.host_computer.File(sin[0]) then return error("File does not exist")
if not get_shell.host_computer.File(sin[0]).has_permission("r") then return error("No permissions to file")
if sin.len == 2 then path=getPath(sin[1]) else path=xpath
if not comp.File(path) then return error("Path does not exist")
if not comp.File(path).has_permission("w") then return error("No permissions to path")
get_shell.scp(sin[0],path,shell)
return out
end function
cmds.get=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len < 1 or sin.len > 2 then return error("Invalid parameters")
path=getPath(sin[0])
if not comp.File(path) then return error("File does not exist")
if not comp.File(path).has_permission("r") then return error("No permissions to file")
if sin.len == 2 then lpath=sin[1] else lpath=current_path
if not get_shell.host_computer.File(lpath) then return error("Path does not exist")
if not get_shell.host_computer.File(lpath).has_permission("w") then return error("No permissions to path")
shell.scp(path,lpath,get_shell)
return out
end function
cmds.set=function(sin)
out={}
out.bool=2
if sin.len != 2 then return error("Invalid parameters")
var=sin[0]
set=sin[1]
if var == "user" then globals.xuser=set
return out
end function
cmds.info=function(sin)
out={}
out.bool=2
print("<color=#7141c4>[Lunar] </color><color=#8254d1>RHost: "+rhost+"</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Session: "+session+"</color>")
return out
end function
cmds.rhost=function(sin)
out={}
out.bool=2
if sin.len > 1 then return error("Invalid parameters")
if sin.len == 0 then
if shelltype == "file" then
globals.rhost=globals.sessions[session].shell.pubip
else
globals.rhost=comp.network_gateway
if rhost == "0.0.0.0" then globals.rhost=comp.local_ip
end if
else
if sin[0][:3] == "www" then sin[0]=nslookup(sin[0])
router=get_router(sin[0])
if is_lan_ip(sin[0]) then router=get_router
if not router then return error("Invalid address")
globals.rhost=sin[0]
end if
if rhost == pubip and anon then print("<color=#7141c4>[Lunar] </color><color=#8254d1>RHost: x.x.x.x</color>") else print("<color=#7141c4>[Lunar] </color><color=#8254d1>RHost: "+rhost+"</color>")
globals.sessions[session].rhost=rhost
return out
end function
cmds.random=function(sin)
out={}
out.bool=2
ip=null
while not get_router(ip)
ip=getRandomIp
end while
globals.rhost=ip
print("<color=#7141c4>[Lunar] </color><color=#8254d1>RHost: "+rhost+"</color>")
globals.sessions[session].rhost=rhost
return out
end function
cmds.nmap=function(sin)
out={}
out.bool=2
if sin.len then
if sin[0][:3] == "www" then sin[0]=nslookup(sin[0])
locals.rhost=sin[0]
end if
islan=is_lan_ip(rhost)
router=get_router(rhost)
if islan then router=get_router
if not router then return error("Invalid address")
wifi=router.essid_name
bssid=router.bssid_name
rver=router.kernel_version
fwr=router.firewall_rules
if islan then
ports=router.device_ports(rhost)
else
ports=router.used_ports
end if
ips=[]
if rhost != router.local_ip then
hport=null
if router.device_ports(router.local_ip).len then hport=router.device_ports(router.local_ip)[0]
m={}
m.ip=router.local_ip
m.ports=[]
if hport then m.ports.push(hport)
ips.push(m)
m=null
end if
fwinfo="action port source dest"
for rules in fwr
fwinfo=fwinfo+"\n"+rules
end for
extinfo="<color=white>"+rhost+"</color><color=#7141c4>|wifi: "+wifi+" |bssid: "+bssid+"</color>"
info="# lan port status service version"
print(extinfo)
if fwr then print(format_columns(fwinfo))
num=0
for port in ports
inMap=0
for m in ips
if m.ip == port.get_lan_ip then
m.ports.push(port)
inMap=1
end if
end for
if not inMap then
m={}
m.ip=port.get_lan_ip
m.ports=[port]
ips.push(m)
end if
end for
for m in ips
ports=m.ports
ip=m.ip
info=info+"\n"+num+" "+ip+" /"
if ip == router.local_ip then info=info+"\n |0 routed router "+rver
for port in ports
service=router.port_info(port)
status="routed"
if port.is_closed then status="closed"
info=info+"\n |"+port.port_number+" "+status+" "+service
end for
num=num+1
end for
if not islan or rhost[-2:] == ".1" then; for sub in router.devices_lan_ip
subIn=0
for m in ips
if sub == m.ip then subIn=1
end for
if subIn then continue
info=info+"\n"+num+" "+sub
num=num+1
end for;end if
print(format_columns(info)+"\n")
whoisinfo=whois(rhost).split("\n")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>WhoIs results</color>")
if whoisinfo.len < 3 then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Could not perform WhoIs operation</color>")
return out
end if
print("<color=#7141c4>"+whoisinfo[0]+"<br>"+whoisinfo[1]+"<br>"+whoisinfo[2]+"</color>")
return out
end function
cmds.target=function(sin)
out={}
out.bool=2
globals.args=null
rinfo=[["<color=#7141c4>[Num]","[Object]","[Perms]","[Lan]","[PubIP]","[Port]</color>"].join(" ")]
if sin.len > 2 then return error("Invalid parameters")
globals.expport=sin[0].to_int
if typeof(expport) != "number" then return error("Invalid port")
if sin.len == 2 then globals.args=sin[1]
if server.shell then
server.shell.launch(RCON_BIN_LOCATION )
lmx=COB.server.mx
else
lmx=mx
end if
globals.lmx=lmx
ns=mx.net_use(rhost,expport)
if not ns then return error("Cannot establish net session")
globals.ml=ns.dump_lib
if server.shell then
getExploits
inDB=0
for dblib in exploits
if ml.lib_name == dblib.name and ml.version == dblib.ver then inDB=1
end for
end if
if dbfile then
getExploits
globals.lib=null
for dblib in exploits
if ml.lib_name == dblib.name and ml.version == dblib.ver then
globals.lib=dblib
break
end if
end for
saveScan()
else
Scan()
end if
exps={"root": [], "user": [], "guest": []}
for ex in results
if ex.user == "root" then
exps.root.push(ex)
else if ex.user == "guest" then
exps.guest.push(ex)
else
exps.user.push(ex)
end if
end for
results=exps.root+exps.user+exps.guest
exps={"shell": [], "comp": [], "file": []}
for ex in results
if typeof(ex.obj) == "shell" then
exps.shell.push(ex)
else if typeof(ex.obj) == "computer" then
exps.comp.push(ex)
else if typeof(ex.obj) == "file" then
exps.file.push(ex)
end if
end for
results=exps.shell+exps.comp+exps.file
globals.sessions[session].results=results
for ex in results
rinfo.push(["<color=#7141c4>["+__ex_idx+"]",ex.obj,ex.user,ex.lan,ex.pub,ex.port+"</color>"].join(" "))
end for
globals.results=results
globals.rinfo=rinfo
print(format_columns(rinfo.join("\n")))
return out
end function
cmds.escalate=function(sin)
out={}
out.bool=2
globals.args=null
rinfo=[["<color=#7141c4>[Num]","[Object]","[Perms]","[Lan]","[PubIP]","[Port]</color>"].join(" ")]
if sin.len > 1 then return error("Invalid parameters")
if sin.len == 1 then globals.args=sin[0]
libs=comp.File("/lib")
if server.shell then
server.shell.launch(RCON_BIN_LOCATION)
lmx=COB.server.mx
else
lmx=mx
end if
globals.lmx=lmx
for exlib in libs.get_files
globals.ml=mx.load(exlib.path)
if not ml then continue
if args then print(format_columns("LIB ARGS\n"+exlib.name+" "+args+"\n")) else print(format_columns("LIB\n"+exlib.name+"\n"))
if dbfile or server.shell then
getExploits
globals.lib=null
for dblib in exploits
if ml.lib_name == dblib.name and ml.version == dblib.ver then
globals.lib=dblib
break
end if
end for
saveScan()
else
Scan()
end if
end for
exps={"root": [], "user": [], "guest": []}
for ex in results
if ex.user == "root" then
exps.root.push(ex)
else if ex.user == "guest" then
exps.guest.push(ex)
else
exps.user.push(ex)
end if
end for
results=exps.root+exps.user+exps.guest
exps={"shell": [], "comp": [], "file": []}
for ex in results
if typeof(ex.obj) == "shell" then
exps.shell.push(ex)
else if typeof(ex.obj) == "computer" then
exps.comp.push(ex)
else if typeof(ex.obj) == "file" then
exps.file.push(ex)
end if
end for
results=exps.shell+exps.comp+exps.file
globals.sessions[session].results=results
for ex in results
rinfo.push(["<color=#7141c4>["+__ex_idx+"]",ex.obj,ex.user,ex.lan,ex.pub,ex.port+"</color>"].join(" "))
end for
globals.rinfo=rinfo
globals.results=results
print(format_columns(rinfo.join("\n")))
return out
end function
cmds.results=function(sin)
out={}
out.bool=2
if sin.len == 1 and sin[0] == "-c" then
globals.results=[]
globals.sessions[session].results=results
globals.rinfo=null
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Cleared results</color>")
return out
end if
if not results.len then return error("No exploits found")
print(format_columns(rinfo.join("\n")))
return out
end function
cmds.use=function(sin)
out={}
out.bool=2
if not results.len then return error("No exploits found")
if sin.len != 1 then return error("Invalid parameters")
num=sin[0].to_int
if typeof(num) != "number" or num > results.len or num < 0 then return error("Invalid selection")
ex=results[num]
result=ex.obj
globals.sessions[session].shells.push(globals.sessions[session].shell)
if typeof(result) != "file" then
shell=result
comp=shell
if typeof(shell) == "shell" then comp=shell.host_computer
xuser=ex.user
if ex.user == "root" then xpath="/root" else xpath="/home/"+xuser
if not comp.File(xpath) then xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": 0}
globals.shell=shell
globals.origShell=0
globals.comp=comp
globals.xuser=xuser
globals.xpath=xpath
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Checking for active admins...</color>")
procs=comp.show_procs.split("\n")[1:]
admin=0
for proc in procs
proc=proc.split(" ")[-1]
if proc == "dsession" then admin=1
if proc == "Xorg" then admin=2
end for
if admin == 1 then
print("<color=red><b>ACTIVE ADMIN DETECTED!</b></color>")
else if admin == 2 then
print("<color=red><b>ACTIVE PLAYER DETECTED!</b></color>")
else
print("<color=#7141c4>[Lunar] </color><color=#8254d1>No admins detected</color>")
end if
else
shell=result
comp=result
while comp.path != "/"
comp=comp.parent
end while
xuser=ex.user
xpath=shell.path
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": 0, "pubip": ex.pub, "locip": ex.lan}
globals.shell=shell
globals.origShell=0
globals.comp=comp
globals.xuser=xuser
globals.xpath=shell.path
end if
return out
end function
cmds.rshell=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot run an rshell on a remote connection")
if (not server.shell and sin.len < 2) or sin.len > 3 then return error("Invalid parameters")
rsport=1222
if server.shell then
rip=conf.rss.ip
rsport=conf.rss.rport
uproc=conf.proc
end if
if sin.len >=1 then rip=sin[0]
if sin.len >=2 then uproc=sin[1]
if sin.len == 3 then
rsport=sin[2].to_int
if typeof(rsport) != "number" then return error("Invalid port")
end if
mx.rshell_client(rip,rsport,uproc)
return out
end function
cmds.rss=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot receive rshell connections on a remote connection")
if not server.shell then return error("Server connection required")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Connecting to rshell server...</color>")
rsc=server.shell.connect_service(conf.rss.ip,conf.rss.port,conf.rss.user,conf.rss.pass)
if typeof(rsc) == "shell" then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Connected successfully</color>")
else
return error("Could not connect")
end if
if not rsc.host_computer.File("/root/shell") then rsc.host_computer.touch("/root","shell")
rsfile="/root/rss"
rsc.launch(rsfile)
rsinfo="num pubip locip user\n"
rshells=COB.rshells
opt=null
print(rshells.len+" shells")
for i in range(0,rshells.len-1)
rfile=rshells[i].host_computer.File("/root")
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=rshells[i].host_computer.File("/home")
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
rsinfo=rsinfo+"\n"+i+"| "+rshells[i].host_computer.public_ip+" "+rshells[i].host_computer.local_ip+" "+ruser
end for
print(format_columns(rsinfo))
while opt > rshells.len-1 or opt < 0 or typeof(opt) != "number"
opt=user_input("<color=#7141c4>[#]$ </color><color=#8254d1>").to_int
if opt == "b" then return out
end while
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Starting shell #"+opt+"</color>")
rfile=rshells[opt].host_computer.File("/root")
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=rshells[opt].host_computer.File("/home")
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=rshells[opt]
globals.origShell=0
globals.xuser=ruser
if xuser == "root" then globals.xpath="/root" else globals.xpath="/home/"+xuser
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end function
cmds.rsi=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot receive rshell connections on a remote connection")
if not include_lib("/lib/librshell.so") then return error("No rshell server installed")
rsinfo="num pubip locip user\n"
rshells=[]
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Waiting for connections. . .</color>")
while rshells.len == 0
rshells=mx.rshell_server
if rshells.len == 0 then wait(2)
end while
if typeof(rshells) == "string" then return error(rshells)
opt=null
print(rshells.len+" shells")
for i in range(0,rshells.len-1)
rfile=rshells[i].host_computer.File("/root")
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=rshells[i].host_computer.File("/home")
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
rsinfo=rsinfo+"\n"+i+"| "+rshells[i].host_computer.public_ip+" "+rshells[i].host_computer.local_ip+" "+ruser
end for
print(format_columns(rsinfo))
while opt > rshells.len-1 or opt < 0 or typeof(opt) != "number"
opt=user_input("<color=#7141c4>[#]$ </color><color=#8254d1>").to_int
if opt == "b" then return out
end while
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Starting shell #"+opt+"</color>")
rfile=rshells[opt].host_computer.File("/root")
ruser="guest"
if rfile and rfile.has_permission("w") then
ruser="root"
else
rfile=rshells[opt].host_computer.File("/home")
if rfile then
for user in rfile.get_folders
if user.name == "guest" then continue
if user.has_permission("w") then ruser=user.name
end for
end if
end if
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=rshells[opt]
globals.origShell=0
globals.xuser=ruser
if xuser == "root" then globals.xpath="/root" else globals.xpath="/home/"+xuser
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end function
cmds.sniffer=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot sniff connections on a remote connection")
if sin.len > 1 then return error("Invalid parameters")
save=0
if sin.len == 1 then save=1
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Waiting for network traffic. . .</color>")
output=mx.sniffer(save)
if not output then return error("Failed to listen to network traffic")
print(output)
return out
end function
cmds.iwctl=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot change WiFi on a Filetype shell")
if sin.len != 3 then return error("Invalid parameters")
if comp.active_net_card != "WIFI" then return error("Cannot use ethernet")
check=comp.connect_wifi("wlan0",sin[0],sin[1],sin[2])
if check != 1 then return error(check)
return out
end function
cmds.net=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot list WiFi networks on a Filetype shell")
if comp.active_net_card != "WIFI" then return error("Cannot use ethernet")
print comp.wifi_networks("wlan0").join(char(10))
return out
end function
cmds.inet=function(sin)
out={}
out.bool=1
if not origShell then return error("Cannot hack wifi connections on a remote connection")
if sin.len > 2 then return error("Invalid parameters")
winfo="# BSSID POWER ESSID"
num=0
sel=null
nd=comp.network_devices
an=comp.active_net_card
if an != "WIFI" then return error("Cannot use ethernet")
cp.airmon("start","wlan0")
wifis=comp.wifi_networks("wlan0")
if sin.len < 2 then
for wifi in wifis
winfo=winfo+"\n"+num+" "+wifi
num=num+1
end for
print(format_columns(winfo))
while sel > wifis.len or sel < 0 or typeof(sel) != "number"
sel=user_input("#> ").to_int
if sel == "b" then break
end while
if sel == "b" then
out.bool=2
return out
end if
wifi=wifis[sel].split(" ")
pwr=wifi[1]
pwr=pwr[:pwr.len-1].to_int
bssid=wifi[0]
essid=wifi[2]
maxacks=300000/pwr
cp.aireplay(bssid,essid,maxacks)
else
bssid=sin[0]
essid=sin[1]
cp.aireplay(bssid,essid,300000)
end if
out.out=cp.aircrack(current_path+"/file.cap")
return out
end function
cmds.mailbomb=function(sin)
out={}
out.bool=2
if sin.len != 4 then return error("Invalid parameters")
if not server.shell then
umaila=user_input("<color=#7141c4>[Email]$ </color><color=#8254d1>",anon)
umaill=user_input("<color=#7141c4>[Pass]$ </color><color=#8254d1>",anon)
else
umaila=conf.mail.user
umaill=conf.mail.pass
end if
mail=mail_login(umaila,umaill)
if typeof(mail) == "string" then return error(mail)
rec=sin[0]
sub=sin[1]
text=sin[2]
quant=sin[3].to_int
for num in range(0,quant)
send=mail.send(rec,sub,text)
if typeof(send) != "number" then return error("Could not send email")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Sent email #"+num+"</color>")
end for
return out
end function
cmds.revoke=function(sin)
out={}
out.bool=2
token.set_content("")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Revoked access token</color>")
return out
end function
cmds.brick=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot brick system with file shell")
if not comp.File("/").has_permission("w") then return error("No permissions to system")
if origShell then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Executing on the ORIGINAL SHELL, are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
end if
num=1
length=comp.File("/").get_files.len
length=length+comp.File("/").get_folders.len
for file in comp.File("/").get_files+comp.File("/").get_folders
print("<color=#7141c4>[Lunar] </color><color=#8254d1>DELETING FILE "+file.path+" "+num+"/"+length+"</color>")
num=num+1
file.delete
end for
return out
end function
cmds.dos=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot disable remote system")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
num=0
while true
mx.rshell_client("0.0.0.0",0,"DOS"+num)
comp.touch(xpath,"DOS"+num)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Spawned DOS"+num+"</color>")
num=num+1
end while
return out
end function
cmds.rdos=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot disable remote system")
if sin.len != 1 or typeof(sin[0].to_int) != "number" then return error("Invalid parameters")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
for i in range(0, sin[0].to_int)
mx.rshell_client("0.0.0.0",0,"DOS"+i)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Spawned DOS"+i+"</color>")
end for
return out
end function
cmds.fdos=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot disable remote system with file shell")
if not comp.File(xpath).has_permission("w") then return error("No permissions to path")
if sin.len > 2 or sin.len == 0 or typeof(sin[0].to_int) != "number" then return error("Invalid parameters")
name="DOS"
if sin.len == 2 then name=sin[1]
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
for i in range(0,sin[0].to_int)
comp.touch(xpath,name+str(i))
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Spawned "+name+str(i)+"</color>")
end for
return out
end function
cmds.cdos=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot disable remote connection")
if sin.len != 1 or typeof(sin[0].to_int) != "number" then return error("Invalid parameters")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
for i in range(0,sin[0].to_int)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Cracking hardware pass "+i+"</color>\n")
cp.decipher("null")
end for
return out
end function
cmds.vim=function(sin)
out={}
out.bool=2
if sin.len > 2 or sin.len < 1 then return error("Invalid parameters")
if shelltype == "file" then file=getFile(getPath(sin[0])) else file=comp.File(getPath(sin[0]))
if not file then return error("File does not exist")
if file.is_binary then return error("Binary file, cannot edit")
if not file.has_permission("w") or not file.has_permission("r") then return error("No permissions to file")
if sin.len == 2 then
file.set_content(sin[1])
return out
end if
cont=file.get_content.split("\n")
while 1
print("<color=#7141c4>-=-= Lunar - "+file.path+" =-=-</color>")
for i in range(0,cont.len-1)
print(i+"|"+cont[i])
end for
print("<color=#7141c4>< nl - newline [line#] q - quit c - clear file ></color>")
sel=user_input("#> ")
if sel.lower == "q" then break
if sel.lower == "c" then
cont=[""]
file.set_content("")
continue
end if
sel=sel.to_int
if typeof(sel) != "number" and sel.split(" ")[0].lower == "nl" then
if sel.split(" ").len != 2 then continue
sel=sel.split(" ")[1].to_int
if typeof(sel) != "number" then continue
if sel < -1 or sel >= cont.len then continue
newcont=[]
if sel == -1 then
newcont.push("")
newcont=newcont+cont
else
for i in range(0,cont.len-1)
newcont.push(cont[i])
if i == sel then newcont.push("")
end for
end if
cont=newcont
file.set_content(cont.join(char(10)))
continue
end if
if sel < 0 or sel >= cont.len then continue
currLine=cont[sel]
while 1
print("<color=#7141c4>-=-= Line "+sel+" =-=-</color>\n"+currLine)
print("<color=#7141c4>< :w to save :q to quit :d to delete line ></color>")
edit=user_input("> ")
if edit.lower == ":q" then
print("Quitting")
else if edit.lower == ":w" then
cont[sel]=currLine
file.set_content(cont.join(char(10)))
print("Saved")
print("Quitting")
else if edit.lower == ":d" then
cont.remove(sel)
file.set_content(cont.join(char(10)))
print("Saved")
print("Quitting")
else
currLine=edit
end if
if edit.lower == ":w" or edit.lower == ":q" or edit.lower == ":d" then break
end while
end while
print("<color=#7141c4>Quitting</color>")
return out
end function
cmds.infect=function(sin)
out={}
out.bool=2
if not server.shell then
out.bool=3
return out
end if
if shelltype != "shell" then return error("Shell required")
if not comp.File("/bin") or not comp.File("/bin").has_permission("w") then return error("Cannot access /bin")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Replacing ssh</color>\n")
p=null
if comp.File("/bin/ssh") then p=comp.File("/bin/ssh").permissions[1:]
server.shell.scp("/root/Downloads/ssh","/bin",shell)
f=comp.File("/bin/ssh")
f.chmod("u-wrx")
f.chmod("g-wrx")
f.chmod("o-wrx")
if p then
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
else
p=comp.File("/bin").permissions[1:]
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
end if
f.chmod("u+"+up)
f.chmod("g+"+gp)
f.chmod("o+"+op)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Replacing passwd</color>\n")
p=null
if comp.File("/bin/passwd") then p=comp.File("/bin/passwd").permissions[1:]
server.shell.scp("/root/Downloads/passwd","/bin",shell)
f=comp.File("/bin/passwd")
f.chmod("u-wrx")
f.chmod("g-wrx")
f.chmod("o-wrx")
if p then
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
else
p=comp.File("/bin").permissions[1:]
up=p[:3].replace("-","")
gp=p[3:-3].replace("-","")
op=p[-3:].replace("-","")
end if
f.chmod("u+"+up)
f.chmod("g+"+gp)
f.chmod("o+"+op)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Replacing ps</color>\n")
buildPS(conf.proc)
return out
end function
cmds.rootkit=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if not comp.File(xpath).has_permission("w") then return error("No permissions to folder")
get_shell.host_computer.File(lunar).chmod("o+rx")
get_shell.host_computer.File(lunar).chmod("u+rx")
get_shell.host_computer.File(lunar).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading Lunar</color>\n")
get_shell.scp(lunar,xpath,shell)
get_shell.host_computer.File(mxf).chmod("o+rx")
get_shell.host_computer.File(mxf).chmod("u+rx")
get_shell.host_computer.File(mxf).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading metaxploit</color>\n")
get_shell.scp(mxf,xpath,shell)
get_shell.host_computer.File(cpf).chmod("o+rx")
get_shell.host_computer.File(cpf).chmod("u+rx")
get_shell.host_computer.File(cpf).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading crypto</color>\n")
get_shell.scp(cpf,xpath,shell)
if la then
comp.touch(xpath,"LuDB")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading Lunar DB</color>\n")
comp.File(xpath+"/LuDB").set_content(dbfile.get_content)
end if
if scnln and sin.len == 1 and sin[0].indexOf("s") != null then
get_shell.host_computer.File(scnln).chmod("o+rx")
get_shell.host_computer.File(scnln).chmod("u+rx")
get_shell.host_computer.File(scnln).chmod("g+rx")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Uploading ScanLan</color>\n")
get_shell.scp(scnln,xpath,shell)
end if
return out
end function
cmds.pwd=function(sin)
out={}
out.bool=1
out.out=xpath
return out
end function
cmds.whoami=function(sin)
out={}
out.bool=1
out.out=xuser
return out
end function
cmds.whereami=function(sin)
out={}
out.bool=1
out.out=pubip
return out
end function
cmds.fyrwall=function(sin)
print("<color=#7141c4>>~-~-~-~-~ STARTING FYRWALL ~-~-~-~-~</color>")
print("<align=right><color=#7141c4>-= <b><size=150%>-=-</size></b> =-</color></align>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>SAVING CURRENT SYSTEM STATE</color>")
print("<align=right><color=#7141c4>-= <b><size=150%>-=-</size></b> =-</color></align>")
safeProcs=[]
procs=comp.show_procs.split("\n")[1:]
for proc in procs
proc=proc.split(" ")
safeProcs.push({"user": proc[0], "id": proc[1], "name": proc[-1]})
end for
safeFiles=[]
newFiles=[]
root=comp.File("/")
currFile=root
newFiles=newFiles+root.get_folders+root.get_files
while newFiles.len
alreadyIn=0
currFile=newFiles.pull
for i in safeFiles
if i.path == currFile.path then alreadyIn=1
end for
if alreadyIn then continue
safeFiles.push({"path": currFile.path, "size": currFile.size})
for file in currFile.get_folders+currFile.get_files
newFiles.push(file)
end for
end while
print("<color=#7141c4>[Lunar] </color><color=#8254d1>WAITING FOR UNLISTED FILES AND PROCESSES</color>")
print("<align=right><color=#7141c4>-= <b><size=150%>-=-</size></b> =-</color></align>")
while 1
newProcs=comp.show_procs.split("\n")[1:]
for proc in newProcs
proc=proc.split(" ")
proc={"user": proc[0], "id": proc[1], "name": proc[-1]}
if safeProcs.indexOf(proc) == null then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>KILLING UNLISTED PROCESS "+proc.name+"</color>")
comp.close_program(proc.id.to_int)
end if
end for
newFiles=[]
newFiles=newFiles+root.get_folders+root.get_files
while newFiles.len
safeFile=0
currFile=newFiles.pull
for file in safeFiles
if file.path == currFile.path and file.size == currFile.size then safeFile=1
end for
if not safeFile and not currFile.is_folder then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>DELETING UNLISTED FILE "+currFile.path+"</color>")
currFile.delete
end if
for file in currFile.get_folders+currFile.get_files
newFiles.push(file)
end for
end while
end while
end function
cmds.bios=function(sin)
out={}
out.bool=2
print("<color=#7141c4>-=-= <b>[Lunar OS Bios Scan]</b> =-=-</color>")
print("<color=#7141c4>-= Performing full system check... =-</color>")
print("<align=right><color=#7141c4><size=150%>[LunarOS]</size></color></align>")
start=time
wait(1)
//processes
if shelltype != "file" then
ps=comp.show_procs
gps=0
ups=0
rps=0
tasks=0
cpu=0.0
mem=0.0
for l in ps.split("\n")[1:]
l=l.split(" ")
if l[0] == "root" then
rps=rps+1
else if l[0] == "guest" then
gps=gps+1
else
ups=ups+1
end if
cpu=cpu+l[2][:1].val
mem=mem+l[3][:1].val
tasks=tasks+1
end for
print("<color=#7141c4>System processes</color>")
print("<color=#7141c4>Total </color><color=#8254d1>["+tasks+"]</color>")
print("<color=#7141c4>Root </color><color=#8254d1>["+rps+"]</color><color=#7141c4> User </color><color=#8254d1>["+ups+"]</color><color=#7141c4> Guest </color><color=#8254d1>["+gps+"]</color>")
print("<color=#7141c4>System threads.usage</color>")
print("<color=#7141c4>CPU usage </color><color=#8254d1>["+bar(cpu)+"]=-=["+cpu+"%]</color>")
print("<color=#7141c4>Mem usage </color><color=#8254d1>["+bar(mem)+"]=-=["+mem+"%]</color>")
print("<color=#7141c4>Temp </color><color=#8254d1>[therm.io 404]</color>\n")
end if
//system date
print("<color=#7141c4>System date</color>")
print("<color=#8254d1>"+current_date+"</color>")
print("<color=#7141c4>System time</color>")
print("<color=#8254d1>"+time+"</color>\n")
//drive
if shelltype == "file" then root=comp else root=comp.File("/")
newFiles=[]
newFiles=newFiles+root.get_folders+root.get_files
size=0
flds=0
fls=0
while newFiles.len
currFile=newFiles.pull
if currFile.is_folder then
flds=flds+1
newFiles=currFile.get_folders+currFile.get_files+newFiles
else
size=size+currFile.size.val
fls=fls+1
end if
end while
print("<color=#7141c4>System storage</color>")
print("<color=#7141c4>Used storage </color><color=#8254d1>["+size+"]</color><color=#7141c4> - Free space </color><color=#8254d1>[sda read error]</color>")
print("<color=#7141c4>Folders count </color><color=#8254d1>["+flds+"]</color><color=#7141c4> - Files count </color><color=#8254d1>["+fls+"]</color>\n")
//network
if shelltype != "file" and not anon then
essid=get_router(comp.public_ip).essid_name
bssid=get_router(comp.public_ip).bssid_name
wifis=null
if comp.active_net_card != "ETHERNET" then wifis=comp.wifi_networks("wlan0")
if comp.network_devices.len == 0 then card="</color><color=red>404" else card=comp.network_devices.split("\n")[0].split(" ")[1]
pwr=null
if wifis then
for wifi in wifis
wifi=wifi.split(" ")
if wifi[0] == bssid and wifi[2] == essid then pwr=wifi[1][:-1].val
end for
end if
print("<color=#7141c4>System network</color>")
print("<color=#7141c4>Netcard </color><color=#8254d1>["+card+"]</color>")
print("<color=#7141c4>Type </color><color=#8254d1>["+comp.active_net_card+"]</color>")
print("<color=#7141c4>Address </color><color=#8254d1>["+comp.local_ip+":"+comp.public_ip+"]</color>")
print("<color=#7141c4>ESSID </color><color=#8254d1>["+essid+"]</color>")
print("<color=#7141c4>BSSID </color><color=#8254d1>["+bssid+"]</color>")
if pwr then print("<color=#7141c4>Power </color><color=#8254d1>["+bar(pwr)+"]=-=["+pwr+"%]</color>\n") else print("<color=#7141c4>Power </color><color=#8254d1>[pwr 404]</color>\n")
end if
//memory
print("<color=#7141c4>Lunar resources</color>")
if clipboard then s=str(clipboard) else s="clipboard empty"
print("<color=#7141c4>Clipboard </color><color=#8254d1>["+s+"]</color>")
print("<color=#7141c4>Sessions </color><color=#8254d1>["+globals.sessions.len+"]</color>")
print("<color=#7141c4>Database </color><color=#8254d1>[read error: string limit reached]</color>\n")
//fyrwall
if shelltype == "file" then root=comp else root=comp.File("/")
newFiles=[]
newFiles=newFiles+root.get_folders+root.get_files
insecuredFiles=[]
num=0
while newFiles.len
f={}
currFile=newFiles.pull
f.path=currFile.path
f.perms=0
f.owner=0
if currFile.is_folder then newFiles=currFile.get_folders+currFile.get_files+newFiles
if currFile.permissions[-3:].indexOf("w") != null then f.perms=1
if currFile.owner != "root" then fowner=1
if f.owner or f.perms then
num=num+1
insecuredFiles.push(f)
end if
end while
print("<color=#7141c4>[Lunar] Fyrwall Security Analysis</color>")
print("<color=#7141c4>Unsecured file count </color><color=#8254d1>["+str(num)+"]</color>")
print
elapsed=str(time-start)
elapsed=elapsed[0:elapsed.indexOf(".")+2]
print("<color=#7141c4>[Lunar] Finished system analysis in </color><color=#8254d1>["+elapsed+"]</color><color=#7141c4> seconds.</color>")
return out
end function
cmds.encrypt=function(sin)
out={}
out.bool=1
if sin.len != 3 then return error("Invalid parameters")
if sin[2] != "enc" and sin[2] != "dec" then return error("Invalid parameters")
out.out=encrypt(sin[0],sin[1],sin[2])
return out
end function
cmds.md5=function(sin)
out={}
out.bool=1
if sin.len != 1 then return error("Invalid parameters")
out.out=md5(sin[0])
return out
end function
cmds.S256=function(sin)
out={}
out.bool=1
if sin.len != 1 then return error("Invalid parameters")
out.out=Sha256(sin[0])
return out
end function
cmds.rot=function(sin)
out={}
out.bool=1
if sin.len != 2 then return error("Invalid parameters")
if typeof(sin[0]).to_int != "number" then return error("Invalid number")
out.out=rot(sin[0].to_int,sin[1])
return out
end function
cmds.vigenere=function(sin)
out={}
out.bool=1
if sin.len != 3 then return error("Invalid parameters")
if sin[2] != "enc" and sin[2] != "dec" then return error("Invalid parameters")
out.out=vigenere(sin[0],sin[1],sin[2])
return out
end function
cmds.base64=function(sin)
out={}
out.bool=1
if sin.len != 2 then return error("Invalid parameters")
if sin[1] != "enc" and sin[1] != "dec" then return error("Invalid parameters")
out.out=base64(sin[0],sin[1])
return out
end function
cmds.base=function(sin)
out={}
out.bool=1
if sin.len < 1 or sin.len > 3 then return error("Invalid parameters")
if sin.len == 1 then
out.out=parseint(sin[0])
else if sin.len == 2 then
sin[1]=sin[1].to_int
if not typeof(sin[1]) == "number" then return error("Invalid parameters")
if sin[1] < 2 or sin[1] > 62 then return error("Invalid parameters")
out.out=parseint(sin[0],sin[1])
else if sin.len == 3 then
sin[1]=sin[1].to_int
sin[2]=sin[2].to_int
if not typeof(sin[1]) == "number" then return error("Invalid parameters")
if not typeof(sin[2]) == "number" then return error("Invalid parameters")
if sin[1] < 2 or sin[1] > 62 then return error("Invalid parameters")
if sin[2] < 2 or sin[2] > 62 then return error("Invalid parameters")
out.out=parseint(sin[0],sin[1],sin[2])
end if
return out
end function
cmds.compress=function(sin)
out={}
out.bool=1
if sin.len != 2 then return error("Invalid parameters")
if sin[0] != "enc" and sin[0] != "dec" then return error("Invalid parameters")
if sin[0] == "enc" then sin[0] = "compress"
if sin[0] == "dec" then sin[0] = "decompress"
out.out=compression(sin[1],sin[0])
return out
end function
cmds.ransom=function(sin)
out={}
out.bool=2
if not server.shell then
out.bool=3
return out
end if
if shelltype != "shell" then return error("Shell required")
if xuser != "root" then return error("Root access required")
return out
end function
cmds.corrupt=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot corrupt logs with fiel shell")
var=comp.File("/var")
if not var then return error("No /var")
if not var.has_permission("w") then return error("No permissions to /var")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Fyrwall Security Logging Prevention</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Corrupting logs...</color>")
comp.touch("/var","system.bak")
log=comp.File("/var/system.log")
p=null
if log then
p=log.permissions[1:]
if not log.has_permission("w") then return error("No permissions to /var/system.log")
log.delete
end if
bak=comp.File("/var/system.bak")
if bak then
bak.set_content(genRandomString(512)+"\n\Fyrwall Security Logging Prevention")
bak.move("/var","system.log")
end if
wait(.2)
log=comp.File("/var/system.log")
if log then
if log.size.to_int < 1000 then
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Log corruption successful.</color>")
log.chmod("u-wrx")
log.chmod("g-wrx")
log.chmod("o-wrx")
if p then
up=p[:3]
gp=p[3:-3]
op=p[-3:]
else
p=comp.File("/var").permissions[1:]
up=p[:3]
gp=p[3:-3]
op=p[-3:]
end if
log.chmod("u+"+up)
log.chmod("g+"+gp)
log.chmod("o+"+op)
else
return error("Log corruption failed")
end if
end if
return out
end function
cmds.secure=function(sin)
out={}
out.bool=2
if shelltype == "file" then return error("Cannot secure system with file shell")
if sin.len != 1 or (sin[0] != "-h" and sin[0] != "-s") then return error("Invalid parameters")
if xuser != "root" then return error("Root required")
home=1
if sin[0] == "-s" then home=0
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Fyrwall Security System</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Securing system...</color>")
if comp.File("/etc/passwd") then comp.File("/etc/passwd").delete
if comp.File("/lib/kernel_module.so") then comp.File("/lib/kernel_module.so").delete
if comp.File("/etc/apt/sources.txt") and comp.File("/etc/apt/sources.txt").has_permission("r") and comp.File("/etc/apt/sources.txt").has_permission("w") then
sources=comp.File("/etc/apt/sources.txt")
r=sources.get_content.split("\n")
r[1]=r[1].replace("true","false")
sources.set_content(r.join(char(10)))
end if
root=comp.File("/")
root.chmod("o-wrx",1)
root.chmod("g-wrx",1)
root.chmod("u-wrx",1)
root.set_owner("root",1)
root.set_group("root",1)
if home then
root.chmod("g+x",1)
if comp.File("/usr") then comp.File("/usr/bin").chmod("g+rx",1)
else
if comp.File("/home") then comp.File("/home").delete
end if
return out
end function
cmds.anon=function(sin)
out={}
out.bool=2
if anon then globals.anon=0 else globals.anon=1
return out
end function
cmds.inject=function(sin)
out={}
out.bool=2
if (not server.shell and sin.len < 3) or sin.len > 4 then return error("Invalid parameters")
rsport=1222
if server.shell then
rip=conf.rss.ip
rsport=conf.rss.rport
uproc=conf.proc
end if
if sin.len >= 2 then rip=sin[1]
if sin.len >= 3 then uproc=sin[2]
if sin.len == 4 then
rsport=sin[3].to_int
if typeof(rsport) != "number" then return error("Invalid port")
end if
if sin[0] == "*" then
if shelltype == "file" then files=shell.get_files else files=comp.File(xpath).get_files
else
if shelltype == "file" then files=[getFile(getPath(sin[0])).get_files] else files=[comp.File(getPath(sin[0]))]
end if
while files.len
file=files.pull
if not file then
out.err="File does not exist"
if not files.len then return error(out.err)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+out.err+"</color>")
continue
end if
if file.is_binary then
out.err="Binary file, cannot edit"
if not files.len then return error(out.err)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+out.err+"</color>")
continue
end if
if not file.has_permission("w") then
out.err="No permissions to file"
if not files.len then return error(out.err)
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+out.err+"</color>")
continue
end if
injection=" ;mxf=null;root=get_shell.host_computer.File(""/"");newFiles=root.get_folders+root.get_files;while newFiles.len;currFile=newFiles.pull;if currFile.is_folder then newFiles=newFiles+currFile.get_folders+currFile.get_files;test=include_lib(currFile.path);if typeof(test) == ""MetaxploitLib"" then;mxf=currFile.path;break;end if;end while;rshelled=0;ps=get_shell.host_computer.show_procs;for proc in ps.split(""\n"")[1:];proc=proc.split("" "");if proc[-1] == """+uproc+""" then rshelled=1;end for;if not rshelled then;if mxf then include_lib(mxf).rshell_client("""+rip+""","""+rsport+""","""+uproc+""");end if"
cont=file.get_content.split("\n")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Injecting code into "+file.name+"</color>")
injected=0
for i in range(0,cont.len-1)
l=cont[i]
if l.indexOf("//") != null then continue
cont[i]=l+injection
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Code injected into line "+i+"</color>")
injected=1
break
end for
if not injected then file.set_content(injection+char(10)+cont.join(char(10))) else file.set_content(cont.join(char(10)))
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Finished injection</color>")
end while
return out
end function
cmds.tree=function(sin)
out={}
out.bool=2
if shelltype == "file" then root=comp else root=comp.File("/")
safeFiles=[]
newFile={}
newFile.path=root.path
newFile.indent=0
newFile.perms=root.permissions
newFile.own=root.owner
newFile.grp=root.group
newFile.size=root.size
safeFiles.push(newFile)
newFiles=[]
newFiles=newFiles+root.get_folders+root.get_files
while newFiles.len
alreadyIn=0
currFile=newFiles.pull
for i in safeFiles
if i.path == currFile.path then alreadyIn=1
end for
if alreadyIn then continue
newFile={}
newFile.path=currFile.path
newFile.indent=currFile.path.split("/")[1:].len
newFile.perms=currFile.permissions
newFile.own=currFile.owner
newFile.grp=currFile.group
newFile.size=currFile.size
safeFiles.push(newFile)
if currFile.is_folder then
newFiles=currFile.get_folders+currFile.get_files+newFiles
end if
end while
default="<color=#7141c4>[owner/group/size/perms]</color> path"
default=default.replace("group","</color>group<color=#7141c4>")
default=default.replace("size","</color>size<color=#7141c4>")
for file in safeFiles
indent=" "*file.indent
string=indent+default
if file.own == "root" then
string=string.replace("owner","</color><color=red>owner</color><color=#7141c4>")
else
string=string.replace("owner","</color><color=green>owner</color><color=#7141c4>")
end if
string=string.replace("owner",file.own)
string=string.replace("group",file.grp)
string=string.replace("size",file.size)
p=file.perms[1:]
up=p[:3]
gp=p[3:-3]
op=p[-3:]
upn=0
gpn=0
opn=0
if up.indexOf("r") != null then upn=upn+1
if up.indexOf("w") != null then upn=upn+1
if up.indexOf("x") != null then upn=upn+1
if gp.indexOf("r") != null then gpn=gpn+1
if gp.indexOf("w") != null then gpn=gpn+1
if gp.indexOf("x") != null then gpn=gpn+1
if op.indexOf("r") != null then opn=opn+1
if op.indexOf("w") != null then opn=opn+1
if op.indexOf("x") != null then opn=opn+1
if upn == 1 then
up="<color=yellow>"+up+"</color>"
else if upn == 2 then
up="<color=yellow>"+up+"</color>"
else if upn == 3 then
up="<color=green>"+up+"</color>"
else
up="<color=red>"+up+"</color>"
end if
if gpn == 1 then
gp="<color=yellow>"+gp+"</color>"
else if gpn == 2 then
gp="<color=yellow>"+gp+"</color>"
else if gpn == 3 then
gp="<color=green>"+gp+"</color>"
else
gp="<color=red>"+gp+"</color>"
end if
if opn == 1 then
op="<color=yellow>"+op+"</color>"
else if opn == 2 then
op="<color=yellow>"+op+"</color>"
else if opn == 3 then
op="<color=green>"+op+"</color>"
else
op="<color=red>"+op+"</color>"
end if
string=string.replace("perms","</color>"+file.perms[0]+up+gp+op+"<color=#7141c4>")
string=string.replace("path",file.path.split("\n")[-1])
print(string)
end for
return out
end function
cmds.copy=function(sin)
out={}
out.bool=2
if not sin.len then
out.bool=0
out.err="Invalid parameters"
return out
end if
if sin.len == 1 then
globals.clipboard=sin[0]
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+sin[0]+" saved to clipboard</color>")
end if
if sin.len > 1 then
if typeof(clipboard) != "map" then globals.clipboard={}
clipboard[sin[0]]=sin[1:].join(" ")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>"+sin[1:].join(" ")+" added to clipboard index "+sin[0]+"</color>")
end if
globals.sessions[session].clipboard=clipboard
return out
end function
cmds.ccopy=function(sin)
out={}
out.bool=2
globals.clipboard=0
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Clipboard cleared</color>")
globals.sessions[session].clipboard=clipboard
return out
end function
cmds["while"]=function(sin)
out={}
out.bool=2
if sin.len <= 1 then return error("Invalid parameters")
list=[]
sin[0]=sin[0].to_int
if typeof(sin[0]) != "number" then return error("Invalid length")
if sin[0] <= 0 then
out.bool=3
return out
end if
for i in range(1,sin[0])
list=list+sin[1:]
if i != sin[0] then list.push("|")
end for
lunaros(list)
return out
end function
cmds.apt=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot Apt on remote connection")
if not apt then return error("aptclient.so required")
if sin.len == 0 or sin.len > 2 then return error("Invalid parameters")
if not comp.File("/etc/apt") then
comp.create_folder("/etc","apt")
apt.update
end if
if not comp.File("/etc/apt/sources.txt") then
apt.update
end if
return out
end function
cmds.aptjack=function(sin)
out={}
out.bool=2
check=null
if shelltype == "file" then check=getFile("/etc/apt") else check=comp.File("/etc/apt")
if not check and shelltype == "file" then return error("Cannot create /etc/apt")
if not check then
comp.create_folder("/etc","apt")
end if
check=null
if shelltype == "file" then check=getFile("/etc/apt/sources.txt") else check=comp.File("/etc/apt/sources.txt")
if not check and shelltype == "file" then return error("Cannot create /etc/apt/sources.txt")
if not check and origShell then
apt.update
end if
if not check then
comp.touch("/etc/apt","sources.txt")
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Are you sure you want to continue?</color>")
confirm=user_input("<color=#7141c4>[y/N]$ </color><color=#8254d1>").lower
if confirm != "y" then return out
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Lunar AptJacker</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Hijacking apt repositories...</color>")
if origShell then
apt.update
apt.add_repo("61.126.138.22",1542)
apt.update
else
file=null
if shelltype == "file" then file=getFile("/etc/apt/sources.txt") else file=comp.File("/etc/apt/sources.txt")
if not file then return error("Could not find /etc/apt/sources.txt")
if not file.has_permission("r") or not file.has_permission("w") then return error("No permissions to /etc/apt/sources.txt")
if not file.get_content.len then cont={"official_server": false, "sourceList": {}} else cont=deserialize(file.get_content)
if cont.indexes.indexOf("sourceList") == null then return error("Unknown error")
cont.sourceList["61.126.138.22"] = 1542
file.set_content(FoxLib.General.Serialize(cont,1))
if shelltype == "file" then file=getFile("/etc/apt/aptcache.bin") else file=comp.File("/etc/apt/aptcache.bin")
if file then file.delete
end if
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Now wait.</color>")
return out
end function
cmds.ping=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len != 1 then return error("Invalid parameters")
start=time
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Pinging "+sin[0]+"</color>")
ping=shell.ping(sin[0])
elapsed=(time-start)*1000
if not ping then
out.bool=0
out.err="Address unreachable"
return out
end if
if elapsed >= .03 then elapsed="</color><color=red>"+str(elapsed)+"</color><color=#8254d1>"
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Ping successful</color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Elapsed time: ["+elapsed+"] ms.</color>")
return out
end function
cmds.sessions=function(sin)
out={}
out.bool=2
if not globals.sessions.len then return out
for i in range(0,globals.sessions.len-1)
print("\n<color=#7141c4>["+i+"]</color>")
print("<color=#7141c4>[Shell] "+globals.sessions[i].shell.orig+"</color>")
print("<color=#7141c4>[Prev] "+globals.sessions[i].shells.len+"</color>")
end for
print("<color=#7141c4>[New]</color>")
opt=user_input("<color=#7141c4>[#]$ </color><color=#8254d1>").lower
if opt == "new" then
globals.sessions.push({"shell": new globals.sessions[session].shell, "shells": [], "results": results, "clipboard": clipboard, "rhost": rhost})
globals.sessions[-1].shell.orig=0
globals.origShell=0
globals.session=globals.sessions.len-1
return out
end if
if opt == "b" then return out
opt=opt.to_int
if typeof(opt) != "number" or opt < 0 or opt >= globals.sessions.len then return out
globals.session=opt
xshell=globals.sessions[session].shell
globals.shell=xshell.shell
globals.origShell=xshell.orig
globals.xuser=xshell.user
globals.xpath=xshell.path
globals.results=globals.sessions[session].results
globals.clipboard=globals.sessions[session].clipboard
globals.rhost=globals.sessions[session].rhost
return out
end function
cmds.shells=function(sin)
out={}
out.bool=2
if not globals.sessions[session].shells.len then return out
for i in range(0,globals.sessions[session].shells.len-1)
print("\n<color=#7141c4>["+i+"]</color>")
print(str(globals.sessions[session].shells[i]))
end for
opt=user_input("<color=#7141c4>[#]$ </color><color=#8254d1>").lower
if opt == "b" then return out
opt=opt.to_int
if typeof(opt) != "number" or opt < 0 or opt >= globals.sessions[session].shells.len then return out
globals.sessions[session].shells.push(globals.sessions[session].shell)
xshell=globals.sessions[session].shells[opt]
globals.shell=xshell.shell
globals.origShell=xshell.orig
globals.xuser=xshell.user
globals.xpath=xshell.path
globals.sessions[session].shell=xshell
return out
end function
cmds.dictssh=function(sin)
out={}
out.bool=2
if shelltype!="shell" then return error("Shell required")
if sin.len > 3 then return error("Invalid parameters")
if server.shell then
passwds=server.shell.host_computer.File("/root/passwds")
else
passwds=get_shell.host_computer.File(current_path+"/passwds")
if not passwds then
get_shell.host_computer.create_folder(current_path,"passwds")
passwds=get_shell.host_computer.File(current_path+"/passwds")
end if
end if
passwd=[]
for file in passwds.get_files
cont=deserialize(compression(file.get_content,"decompress"))
passwd.push(cont)
end for
if passwd.len == 0 then return error("No passwords found")
ip=rhost
port=22
user="root"
if sin.len >= 1 then ip=sin[0]
if sin.len >= 2 then
port=sin[1].to_int
if typeof(port) != "number" then return error("Invalid port")
end if
if sin.len == 3 then user=sin[2]
pnum=0
for i in passwd
pnum=pnum+i.len
end for
num=1
for i in passwd
for pass in i
if pass=="" then continue
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Attempting password "+pass+" "+num+"/"+pnum+"</color>")
num=num+1
attempt=shell.connect_service(ip,port,user,pass,"ssh")
if typeof(attempt) == "shell" then
print("<color=#8254d1><b>-=-= Password found! "+pass+" =-=-</b></color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Establishing connection. . .</color>")
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=attempt
globals.origShell=0
globals.xuser=user
if user == "root" then globals.xpath="/root" else globals.xpath="/home/"+user
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end if
end for
end for
out.bool=0
out.err="Could not establish connection"
return out
end function
cmds.dictsudo=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot change user on remote connection")
if sin.len > 1 then return error("Invalid parameters")
if server.shell then
passwds=server.shell.host_computer.File("/root/passwds")
else
passwds=get_shell.host_computer.File(current_path+"/passwds")
if not passwds then
get_shell.host_computer.create_folder(current_path,"passwds")
passwds=get_shell.host_computer.File(current_path+"/passwds")
end if
end if
passwd=[]
for file in passwds.get_files
cont=deserialize(compression(file.get_content,"decompress"))
passwd.push(cont)
end for
if passwd.len == 0 then return error("No passwords found")
user="root"
if sin.len == 1 then user=sin[0]
pnum=0
for i in passwd
pnum=pnum+i.len
end for
num=1
for i in passwd
for pass in i
if pass == "" then continue
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Attempting password "+pass+" "+num+"/"+pnum+"</color>")
num=num+1
attempt=get_shell(user,pass)
if typeof(attempt) == "shell" then
print("<color=#8254d1><b>-=-= Password found! "+pass+" =-=-</b></color>")
sessions[session].shells.push(sessions[session].shell)
globals.shell=attempt
globals.origShell=0
globals.xuser=user
if user == "root" then globals.xpath="/root" else globals.xpath="/home/"+user
if not shell.host_computer.File(xpath) then globals.xpath="/"
sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
else
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Invalid password</color>")
end if
end for
end for
out.bool=0
out.err="Could not change user"
return out
end function
cmds.brutessh=function(sin)
out={}
out.bool=2
if shelltype != "shell" then return error("Shell required")
if sin.len > 3 then return error("Invalid parameters")
ip=rhost
port=22
user="root"
if sin.len >= 1 then ip=sin[0]
if sin.len >= 2 then
port=sin[1].to_int
if typeof(port) != "number" then return error("Invalid port")
end if
if sin.len == 3 then user=sin[2]
alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
al=alpha.len
max=15
for i in range(1,max)
c=[]
for _ in range(0,max)
c.push(0)
end for
while 1
cy=c[:i]
ps=[]
for x in cy
ps.push(x*(al ^ __x_idx))
end for
cy=ps.sum
print("length "+i+" cycle "+(cy+1)+"/"+(al^i))
print("---------------------------------")
pass=""
for q in range(0,(i-1))
if floor(c[q]/al) then
c[q]=0
if q != i-1 then c[q+1]=c[q+1]+1 else continue
end if
if q != 0 then print("---------------------------------")
print("c"+q+" "+c[q])
pass=pass+alpha[c[q]]
end for
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Attempting password "+pass+"</color>")
print
print("---------------------------------")
attempt=shell.connect_service(ip,port,user,pass,"ssh")
if typeof(attempt) == "shell" then
print("<color=#8254d1><b>-=-= Password found! "+pass+" =-=-</b></color>")
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Establishing connection. . .</color>")
globals.sessions[session].shells.push(globals.sessions[session].shell)
globals.shell=attempt
globals.origShell=0
globals.xuser=user
if user == "root" then globals.xpath="/root" else globals.xpath="/home/"+user
if not shell.host_computer.File(xpath) then globals.xpath="/"
globals.sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end if
c[0]=c[0]+1
if floor((c[:i].sum-1)/(al-1)) == i then break
end while
end for
return error("Could not establish connection")
end function
cmds.brutesudo=function(sin)
out={}
out.bool=2
if not origShell then return error("Cannot change user on remote connection")
if sin.len > 1 then return error("Invalid parameters")
user="root"
if sin.len == 1 then user=sin[0]
alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
al=alpha.len
max=15
for i in range(1,max)
c=[]
for _ in range(0,max)
c.push(0)
end for
while 1
cy=c[:i]
ps=[]
for x in cy
ps.push(x*(al ^ __x_idx))
end for
cy=ps.sum
print("length "+i+" cycle "+(cy+1)+"/"+(al^i))
print("---------------------------------")
pass=""
for q in range(0,(i-1))
if floor(c[q]/al) then
c[q]=0
if q != i-1 then c[q+1]=c[q+1]+1 else continue
end if
if q != 0 then print("---------------------------------")
print("c"+q+" "+c[q])
pass=pass+alpha[c[q]]
end for
print("<color=#7141c4>[Lunar] </color><color=#8254d1>Attempting password "+pass+"</color>")
print
print("---------------------------------")
attempt=get_shell(user,pass)
if typeof(attempt) == "shell" then
print("<color=#8254d1><b>-=-= Password found! "+pass+" =-=-</b></color>")
sessions[session].shells.push(sessions[session].shell)
globals.shell=attempt
globals.origShell=0
globals.xuser=user
if user == "root" then globals.xpath="/root" else globals.xpath="/home/"+user
if not shell.host_computer.File(xpath) then globals.xpath="/"
sessions[session].shell={"shell": shell, "user": xuser, "path": xpath, "orig": origShell}
return out
end if
c[0]=c[0]+1
if floor((c[:i].sum-1)/(al-1)) == i then break
end while
end for
return error("Could not change user")
end function
cmds.lan=function(sin)
out={}
out.bool=2
if comp.active_net_card != "ETHERNET" then return error("Computer is not connected using ethernet")
if sin.len != 2 then return error("Invalid parameters")
out.out=comp.connect_ethernet("eth0",sin[1],sin[0])
return out
end function
cmds["return"]=function(sin)
out={}
out.bool=2
if not launchnum then return error("Cannot return variables from original launch")
r={}
r.shell=shell
r.user=xuser
r.path=xpath
COB.returned=r
exit
end function
cmds.exploits=function(sin)
out={}
out.bool=2
end function
libs/fox.src
FoxLib={}
// GENERAL FUNCTIONS
FoxLib.General={}
General=FoxLib.General
FoxLib.General.LibFinder=function(folder="/")
out={}
out.apt=null
out.cpf=null
out.mxf=null
out.bcf=null
root=get_shell.host_computer.File(folder)
if not root then return
newFiles=root.get_folders+root.get_files
while newFiles.len
currFile=newFiles.pull
if currFile.is_folder then newFiles=currFile.get_folders+currFile.get_files+newFiles
test=include_lib(currFile.path)
if typeof(test) == "MetaxploitLib" then out.mxf=currFile.path
if typeof(test) == "cryptoLib" then out.cpf=currFile.path
if typeof(test) == "aptclientLib" then out.apt=currFile.path
if typeof(test) == "blockchainLib" then out.bcf=currFile.path
end while
return out
end function
FoxLib.General.Serialize=function(array=null,fancy=0)
if not str(array).len then return 0
if array == null or (str(array)[0] != "{" and str(array)[0] != "[") then return 0
type=null
if str(array)[0] == "{" then type="map"
if str(array)[0] == "[" then type="list"
//if type == "map" then
// tmp={}
// for i in array.indexes
// tmp[@i] = array[@i]
// end for
// array=tmp
//else if type == "list" then
// array=array[0:]
//end if
if not type then return 0
if type == "list" then
result="["
l=array
else
result="{"
l=array.indexes
end if
if fancy then
result=result+char(10)
if FoxLib.General.hasIndex("SERN") then FoxLib.General.SERN=FoxLib.General.SERN+1 else FoxLib.General.SERN=1
N=FoxLib.General.SERN
end if
for i in l.indexes
if type == "map" then v=@array[l[i]] else v=@array[i]
vt=typeof(@v)
if vt == "function" then
v="Err_Function"
vt="string"
end if
if str(v)[0] == "{" or str(v)[0] == "[" then v=FoxLib.General.Serialize(v,fancy)
if type == "list" then
if vt == "string" then v=""""+v+""""
if fancy then
if __i_idx == l.indexes.len-1 then result=result+(" "*N)+v else result=result+(" "*N)+v+", "
result=result+char(10)
else
if __i_idx == l.indexes.len-1 then result=result+v else result=result+v+", "
end if
else
if l[i] isa string then lx=""""+l[i]+"""" else lx=l[i]
if vt == "string" then v=""""+v+""""
if fancy then
if __i_idx == l.indexes.len-1 then result=result+(" "*N)+lx+": "+v else result=result+(" "*N)+lx+": "+v+","
result=result+char(10)
else
if __i_idx == l.indexes.len-1 then result=result+lx+": "+v else result=result+lx+": "+v+", "
end if
end if
end for
if fancy then
if type == "map" then result=result+(" "*(N-1))+"}" else result=result+(" "*(N-1))+"]"
else
if type == "map" then result=result+"}" else result=result+"]"
end if
if fancy and N == 1 then FoxLib.General.remove("SERN")
if fancy and N != 1 then FoxLib.General.SERN = N-1
return result
end function
FoxLib.General.Deserialize=function(array=null)
if not array or not array isa string then return 0
type=null
if array[0] == "[" then type="list"
if array[0] == "{" then type="map"
if not type then return 0
if type == "list" then
newArray=[]
else
newArray={}
end if
array=array.split(char(10)).join("")
array=array[1:-1]
if not array then return newArray
a=[]
b=[]
c=0
for v in array
i=__v_idx
if v == "{" or v == "[" then c=c+1
if v == "}" or v == "]" then c=c-1
if v == "," and c == 0 then
a.push(b.join(""))
b=[]
continue
end if
b.push(v)
if i == array.len-1 then
a.push(b.join(""))
b=[]
continue
end if
end for
array=a
for i in array
i=i.trim
if type == "list" then
if not i then continue
if i[0] == """" and i[-1] == """" then
i=i[1:-1]
else
if i == "null" then
i=null
else if i == "true" then
i=1
else if i == "false" then
i=0
else if i[0] == "{" or i[0] == "[" then
i=FoxLib.General.Deserialize(i)
else
nv=""
dc=0
for l in i
if l == "." then
if dc == 1 then break
nv=nv+"."
end if
if "0123456789E-".indexOf(l) != null then nv=nv+l
end for
if nv != "" then i=nv.val
end if
end if
newArray.push(i)
else
k=i[0:i.indexOf(":")]
if not k then continue
if k[0] == """" then k=k[1:-1]
v=i[i.indexOf(":")+1:]
if not v then continue
v=v.trim
if not v then continue
if v[0] == """" then
v=v[1:-1]
else
if v == "null" then
v=null
else if v == "true" then
v=1
else if v == "false" then
v=0
else if v[0] == "{" or v[0] == "[" then
v=FoxLib.General.Deserialize(v)
else
nv=""
dc=0
for l in v
if l == "." then
if dc == 1 then break
nv=nv+"."
end if
if "0123456789E-".indexOf(l) != null then nv=nv+l
end for
if nv != "" then v=nv.val
end if
end if
newArray[k]=v
end if
end for
return newArray
end function
FoxLib.General.rndstring=function(length=null)
if not length or not length isa number then return 0
newString=""
alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890"
while newString.len < length
newString=newString+alpha[floor(rnd*alpha.len)]
end while
return newString
end function
FoxLib.General.RandArt=function(data=null)
if not data or not data isa string then return
if bitwise("&",data.len,1) then data=data+"0"
max=function(p1,p2)
if p1 > p2 then return p1 else return p2
end function
min=function(p1,p2)
if p1 < p2 then return p1 else return p2
end function
move=function(position,mv,wid,high)
posx=floor(position%wid)
posy=floor(position/wid)
newposx=posx
if mv == NW or mv == SW then newposx=newposx-1
if mv == NE or mv == SE then newposx=newposx+1
newposy=posy
if mv == NW or mv == NE then newposy=newposy-1
if mv == SW or mv == SE then newposy=newposy+1
newposx=max(0,min(wid-1,newposx))
newposy=max(0,min(high-1,newposy))
return newposx+newposy*wid
end function
hex2dec=function(hex)
ints=[]
for i in range(0,hex.len-1,2)
ints.push((FoxLib.General.ParseInt(hex[i:i+2],16)))
end for
return ints
end function
NW=0
NE=1
SW=2
SE=3
alt=" .o+=*B0X@%&#/^"
width=17
height=9
board=[]
while board.len != width*height
board.push(0)
end while
bytes=hex2dec(data)
pos=width*4+8;
start=pos
for i in range(0,bytes.len-1)
d=bytes[i]
for j in range(0,6,2)
v = bitwise("&", bitwise(">>", d, j), 3)
newpos=move(pos,v,width,height)
board[newpos]=board[newpos]+1
pos=newpos
end for
end for
art=""
for p in range(0,width*height-1)
m=board[p]
if m >= alt.len then m=alt.len-1
chr=alt[m]
if p == start then chr="S"
if p == pos then chr="E"
art=art+chr
if(p % width == width -1) then art=art+char(10)
end for
return art.split(char(10))[:-1].join(char(10))
end function
FoxLib.General.ParseInt=function(s,orad=0,irad=0)
if typeof(s) != "string" then return 0
if s[:2] == "0x" and not irad then irad=16
if irad == 16 and not orad then orad=10
if s[:2] == "0x" then s=s[2:]
if not irad then irad=10
if not orad then orad=16
alpha="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
if irad > alpha.len or irad < 2 then return 0
if orad > alpha.len or orad < 2 then return 0
out=[]
if irad == 10 then
o=s.val
while o
out.push(alpha[o % orad])
o=floor(o/orad)
end while
if orad == 16 then out.push("0x")
out.reverse
return out.join("")
end if
for c in s
out.push( (alpha.indexOf(c) * irad ^ ( (s.len-1) - out.len)) )
end for
out=out.sum
if orad == 10 then return out
o=out
out=[]
while o
out.push(alpha[floor(o%orad)])
o=floor(o/orad)
end while
if orad == 16 then out.push("0x")
out.reverse
return out.join("")
end function
FoxLib.General.Compression=function(st=null,type=null)
basedictcompress={}
basedictdecompress={}
for i in range(0,55295)
ic=char(i)
iic=char(i)+char(0)
basedictcompress[ic]=iic
basedictdecompress[iic]=ic
end for
dictAddA=function(str,dict,a,b)
if a >= 55296 then
a = 0
b=b+1
if b >= 55296 then
dict={}
b=1
end if
end if
dict[str]=char(a)+char(b)
a=a+1
return [dict,a,b]
end function
compress=function(input)
if not input isa string then return 0
length=input.len
if length <= 1 then return "u"+input
dict={}
a=0
b=1
result=["c"]
resultLen=result.len
word=""
for i in range(0,length-1)
c=input[i]
wc=word+c
if not (basedictcompress.hasIndex(wc) or dict.hasIndex(wc)) then
write=null
if basedictcompress.hasIndex(word) then
write=basedictcompress[word]
else if dict.hasIndex(word) then
write=dict[word]
end if
if not write then return 0
result.push(write)
resultLen=result.len
if length <= resultLen then return "u"+input
dict=dictAddA(wc,dict,a,b)
a=dict[1]
b=dict[2]
dict=dict[0]
word=c
else
word=wc
end if
end for
if basedictcompress.hasIndex(word) then result.push(basedictcompress[word]) else result.push(dict[word])
resultLen=result.len
if length <= resultLen then return "u"+input
return result.join("")
end function
dictAddB=function(str,dict,a,b)
if a >= 55296 then
a=0
b=b+1
if b >= 55296 then
dict={}
b=1
end if
end if
dict[char(a)+char(b)]=str
a=a+1
return [dict,a,b]
end function
decompress=function(input)
if not input isa string then return 0
if input.len < 1 then return 0
control=input[0]
if control == "u" then
return input[1:]
else if control != "c" then
return 0
end if
input=input[1:]
length=input.len
if length < 2 then return 0
dict={}
a=0
b=1
result=[]
last=input[0:2]
if basedictdecompress.hasIndex(last) then
result.push(basedictdecompress[last])
else if dict.hasIndex(last) then
result.push(dict[last])
end if
for i in range(2,length-1,2)
code=input[i:i+2]
lastStr=null
if basedictdecompress.hasIndex(last) then
lastStr=basedictdecompress[last]
else if dict.hasIndex(last) then
lastStr=dict[last]
end if
if lastStr == null then return 0
if basedictdecompress.hasIndex(code) then
toAdd=basedictdecompress[code]
else if dict.hasIndex(code) then
toAdd=dict[code]
else
toAdd=0
end if
if toAdd then
result.push(toAdd)
dict=dictAddB(lastStr+toAdd[0],dict,a,b)
a=dict[1]
b=dict[2]
dict=dict[0]
else
tmp=lastStr+lastStr[0]
result.push(tmp)
dict=dictAddB(tmp,dict,a,b)
a=dict[1]
b=dict[2]
dict=dict[0]
end if
last=code
end for
return result.join("")
end function
if type == "compress" then
return compress(st)
else if type == "decompress" then
return decompress(st)
else
return 0
end if
end function
// CRYPTOGRAPHY FUNCTIONS
FoxLib.Crypto={}
FoxLib.Crypto.Vigenere=function(s=null,key=null,type=null)
if not key or not key isa string then return 0
if not s or not s isa string then return 0
if not type or not type isa string or (type != "enc" and type != "dec") then return 0
keySize=key.len
result=""
counter=0
if type == "enc" then
for i in s
currKey=key[counter]
final = (i.code+currKey.code) % 55295
result=result+char(final)
counter=(counter+1) % keySize
end for
else if type == "dec" then
for i in s
currKey=key[counter]
final=(i.code-currKey.code)
if final < 0 then final = 0 - final
result=result+char(final)
counter=(counter+1) % keySize
end for
end if
return result
end function
FoxLib.Crypto.ROT=function(pos=null,s=null)
if not pos or not pos isa number then return 0
pos=abs(pos)
if not s or not s isa string then return 0
cases=[]
cases.push("abcdefghijklmnopqrstuvwxyz")
cases.push("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
ns=[]
for i in s
case=null
for c in cases
if c.indexOf(i) != null then case=c
end for
if not case then
ns.push(i)
continue
end if
ind=case.indexOf(i)
newPos=(ind+pos)%case.len
ns.push(case[newPos])
end for
return ns.join("")
end function
FoxLib.Crypto.Base64=function(s=null,type=null)
if not s or not s isa string then return 0
if not type or not type isa string or (type != "enc" and type != "dec") then return 0
alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
alphaLen=alpha.len-1
based=null
if type == "enc" then
grouped=[]
while s
ns=s[:3]
s=s[ns.len:]
bins=[]
for i in ns
b=FoxLib.General.ParseInt(str(i.code),2)
while b.len < 8
b="0"+b
end while
bins=bins+b.values
end for
grouped.push(bins)
end while
based=""
for g in grouped
block=[]
while g
s=g[:6]
g=g[s.len:]
while s.len < 6
s.push("0")
end while
block.push(s)
end while
for i in block
based=based+alpha[FoxLib.General.ParseInt(i.join(""),10,2)%alphaLen]
end for
check=block.len
while check != 4
based=based+"="
check=check+1
end while
end for
else
grouped=[]
while s
block=[]
ns=s[:4]
s=s[ns.len:]
for i in ns
if i == "=" then break
a=FoxLib.General.ParseInt(str(alpha.indexOf(i)),2)
while a.len < 6
a="0"+a
end while
block=block+a.values
end for
grouped.push(block)
end while
based=""
for g in grouped
block=[]
while g
s=g[:8]
g=g[s.len:]
check=s.len
if check < 8 then s.reverse
while s.len < 8
s.push("0")
end while
if check < 8 then s.reverse
block.push(s)
end while
for i in block
based=based+char(FoxLib.General.ParseInt(i.join(""),10,2))
end for
end for
end if
return based
end function
FoxLib.Crypto.Sha256=function(st=null)
if not st or not st isa string then return
Blocks = [[0]]
i=0
e=0
while i < st.len
e=4
while e > 0 and st.hasIndex(i)
e=e-1
Blocks[-1][-1] = Blocks[-1][-1] + code(st[i])*256^e
i=i+1
end while
if e == 0 then
if Blocks[-1].len == 16 then Blocks = Blocks + [[0]] else Blocks[-1] = Blocks[-1] + [0]
end if
end while
if e > 0 then
Blocks[-1][-1] = Blocks[-1][-1] + (2147483648/256^(4-e))
else
Blocks[-1][-1] = 2147483648
end if
if Blocks[-1].len == 16 then Blocks = Blocks + [[0]]
while Blocks[-1].len != 15
Blocks[-1] = Blocks[-1] + [0]
end while
Blocks[-1] = Blocks[-1] + [st.len*8]
add = function(a, b)
return (a + b) % 4294967296
end function
XOR = function(a, b)
return bitwise("^", floor(a/65536), floor(b/65536))*65536+bitwise("^", a%65536, b%65536)
end function
AND = function(a, b)
return bitwise("&", floor(a/65536), floor(b/65536))*65536+bitwise("&", a%65536, b%65536)
end function
OR = function(a, b)
return bitwise("|", floor(a/65536), floor(b/65536))*65536+bitwise("|", a%65536, b%65536)
end function
NOT = function(n)
return 4294967295-n
end function
Ch = function(x, y, z)
return OR(AND(x, y), AND(NOT(x), z))
end function
Maj = function(x, y, z)
return OR(OR(AND(x, y), AND(x, z)), AND(y, z))
end function
shr = function(n, shifts)
return floor(n/2^shifts)
end function
rotr = function(n, rots)
rots = 2^rots
return (n % rots) * (4294967296/rots) + floor(n/rots)
end function
sigma0 = function(n)
return XOR(XOR(rotr(n, 7), rotr(n, 18)), shr(n, 3))
end function
sigma1 = function(n)
return XOR(XOR(rotr(n, 17), rotr(n, 19)), shr(n, 10))
end function
SIGMA0 = function(n)
return XOR(XOR(rotr(n, 2), rotr(n, 13)), rotr(n, 22))
end function
SIGMA1 = function(n)
return XOR(XOR(rotr(n, 6), rotr(n, 11)), rotr(n, 25))
end function
K = []
K = K + [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221]
K = K + [3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580]
K = K + [3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986]
K = K + [2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895]
K = K + [666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037]
K = K + [2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344]
K = K + [430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779]
K = K + [1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]
H = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]
for Block in Blocks
W = Block[0:]
for i in range(16, 63)
W = W + [add(add(add(sigma1(W[i-2]), W[i-7]), sigma0(W[i-15])), W[i-16])]
end for
a = H[0]
b = H[1]
c = H[2]
d = H[3]
e = H[4]
f = H[5]
g = H[6]
h = H[7]
for i in range(0, 63)
T1 = add(add(add(add(SIGMA1(e), Ch(e, f, g)), h), K[i]), W[i])
T2 = add(SIGMA0(a), Maj(a, b, c))
h = g
g = f
f = e
e = add(d, T1)
d = c
c = b
b = a
a = add(T1, T2)
end for
H[0] = add(a, H[0])
H[1] = add(b, H[1])
H[2] = add(c, H[2])
H[3] = add(d, H[3])
H[4] = add(e, H[4])
H[5] = add(f, H[5])
H[6] = add(g, H[6])
H[7] = add(h, H[7])
end for
hexTable = "0123456789abcdef"
output = ""
for i in H.indexes
for j in range(7)
output = output + hexTable[floor(H[i]/16^j) % 16]
end for
end for
return output
end function
// BIGINT FUNCTIONS
FoxLib.Int={}
FoxLib.Int.base=function()
out={}
out.int=[]
out.dec=[]
out.neg=0
out.classID="BigInt"
out.string=function()
st=""
if self.neg then st="-"
for i in self.int
st=st+str(i)
end for
if self.dec.len > 0 then
st=st+"."
for i in self.dec
st=st+str(i)
end for
end if
return st
end function
out.trim=function()
num=self.int[0:]
dec=self.dec[0:]
i=0
while num[i] == 0 and num[i:].len != 1
i=i+1
end while
num=num[i:]
if dec.len > 0 then
i=0
dec.reverse
while dec[i] == 0 and dec.len < i
i=i+1
end while
if dec[i] == 0 then dec=[] else dec=dec[i:]
dec.reverse
end if
self.int=num[0:]
self.dec=dec[0:]
end function
out.to_int=function()
return val(self.string)
end function
return out
end function
FoxLib.Int.copy=function(num=0)
if typeof(num) != "BigInt" then return 0
out=FoxLib.Int.base
out.neg=num.neg
out.int=num.int[0:]
out.dec=num.dec[0:]
return out
end function
FoxLib.Int.zero=function(length=1)
newint=FoxLib.Int.base
while newint.int.len < length
newint.int.push(0)
end while
return newint
end function
FoxLib.Int.one=function(length=1)
newint=FoxLib.Int.base
while newint.int.len < length
if newint.int.len+1 == length then newint.int.push(1) else newint.int.push(0)
end while
return newint
end function
FoxLib.Int.rnd=function(length=1)
newint=FoxLib.Int.base
while newint.int.len < length
n=floor(rnd*10)
if n > 9 or n < 0 then continue
newint.int.push(n)
end while
return newint
end function
FoxLib.Int.fromint=function(num=0)
newint=FoxLib.Int.base
if not num isa string and not num isa number then return 0
if not num isa string then num=str(num)
if not val(num) isa number then return 0
if num[0] == "-" then
newint.neg=1
num=num[1:]
end if
for i in num
if "0123456789".indexOf(i) == null then break
newint.int.push(val(i))
end for
if num.hasIndex(__i_idx) and num[__i_idx] == "." then
num=num[__i_idx+1]
for i in num
if "0123456789".indexOf(i) == null then break
newint.dec.push(val(i))
end for
end if
return newint
end function
FoxLib.Int.math={}
FoxLib.Int.math.add=function(num1=1,num2=1)
if typeof(num1) != "BigInt" then
num1=FoxLib.Int.fromint(num1)
if not num1 then return 0
end if
if typeof(num2) != "BigInt" then
num2=FoxLib.Int.fromint(num2)
if not num2 then return 0
end if
negAdd=0
if num1.neg and num2.neg then negAdd=1
if not negAdd then
if num1.neg then
num1.neg=0
return FoxLib.Int.math.sub(num2,num1)
else if num2.neg then
num2.neg=0
return FoxLib.Int.math.sub(num1,num2)
end if
end if
A=num1.int[0:]+num1.dec[0:]
Aintlen=num1.int.len
Adeclen=num1.dec.len
B=num2.int[0:]+num2.dec[0:]
Bintlen=num2.int.len
Bdeclen=num2.dec.len
while Adeclen < Bdeclen
A.push(0)
Adeclen=Adeclen+1
end while
while Bdeclen < Adeclen
B.push(0)
Bdeclen=Bdeclen+1
end while
A.reverse
B.reverse
while Aintlen < Bintlen
A.push(0)
Aintlen=Aintlen+1
end while
while Bintlen < Aintlen
B.push(0)
Bintlen=Bintlen+1
end while
outnum=[]
i=0
while 1
n=[]
if not A.indexes.hasIndex(i) and not B.indexes.hasIndex(i) then break
calc=A[i]+B[i]
if calc > 9 then
c=i+1
added=0
while A.indexes.hasIndex(c)
if A[c] < 9 then
A[c]=A[c]+1
added=1
break
end if
if A[c] == 9 then A[c]=0
c=c+1
end while
if not A.hasIndex(c) and not added then A.push(1)
calc=calc-10
end if
for c in str(calc)
n.push(c)
end for
n.reverse
for c in n
outnum.push(val(c))
end for
i=i+1
end while
out=FoxLib.Int.base
out.int=outnum[Adeclen:]
out.dec=outnum[:Adeclen]
out.neg=negAdd
out.int.reverse
out.dec.reverse
//if FoxLib.Int.math.equalto(FoxLib.Int.math.abs(out),0) then out.neg=0
return out
end function
// HACKING FUNCTIONS
FoxLib.VulnV={}
FoxLib.VulnV.Decipher=function(cp=null,hash=null)
if not (cp or hash) then return
if hash.len < 32 then return
hash=hash.split(":")[-1]
if hash.len < 32 then return
hash=hash[:32]
pass=cp.decipher(hash)
return pass
end function
FoxLib.VulnV.Exploit=function(mx=null,ml=null,args=null)
if not (mx or ml) then return
scan=mx.scan(ml)
out={}
out.db={}
out.db.name=ml.lib_name
out.db.ver=ml.version
out.db.exploits=[]
for mem in scan
ex={}
ex.mem=mem
ex.vulns=[]
mems=mx.scan_address(ml,mem).split("Unsafe check: ")
for ent in mems
if ent == mems[0] then continue
exp=ent[ent.indexOf("<b>")+3:ent.indexOf("</b>")]
if not args then result=ml.overflow(mem,exp) else result=ml.overflow(mem,exp,args)
v={}
v.vuln=exp
v.result=result
ex.vulns.push(v)
end for
out.db.exploits.push(ex)
end for
return out
end function