Skip to content

Doge-Clan/FreeExecutor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

FreeExecutor

This is the source code for a JavaScript web-based shell. It can be embedded in an HTML5 page, or can be used as a bookmarklet to run over any website you desire.

(C) 2021-2022 Doge Clan, Licensed under the LGPL 2.1 License

Bookmarklet Source Code

Bookmarklet Code: javascript:!function(){for(let a in window.page={url:window.location.href,isGoGuardian:window.location.href.includes("blocked.goguardian.com"),isLocal:window.location.href.includes("C:")||0===window.location.href.indexOf("/")},window.fe={},window.fe.isTextMode=localStorage.getItem("fe_textmode")||!0,window.fe.isGraphicsMode=localStorage.getItem("fe_graphicsmode")||!1,window.fe.hostname=localStorage.getItem("fe_hostname")||"system",window.fe.version="0.3",window.fe.startupMsg=localStorage.getItem("fe_startupmsg")||"FreeExecutor "+window.fe.version+"<br>(C) 2022 Doge Clan, Licensed under LGPL 2.1 License",window.fe.execGUI=function(){alert("Nothing installed at fe.execGUI()! Please use libnix to patch the GUI."),window.fe.isTextMode=!0,window.fe.isGraphicsMode=!1},window.fepkg={installedPackages:["base_fe-"+window.fe.version],installedCommands:["clear","eval","fepkg","unset","savelibnix","set"],loadAnonymousScript:function(e,t,s=!1){let o=document.createElement("script");o.src=t,s&&(o.type="module"),document.body.appendChild(o),window.fepkg.installedPackages.push(e),console.debug(`Sucessfully pushed anymous package ${e}`)},addCommand:function(e,t){window.fepkg.installedCommands.push(e),window.fepkg[e]=t}},window.Math.HALF_PI=Math.PI/2,window.Math.Vector=class NVector{constructor(e){this.dimensions=e.length,this.v=new Int32Array(e)}add(e){for(let t=0;t<this.dimensions;t++)this.v[t]+=e}sub(e){for(let t=0;t<this.dimensions;t++)this.v[t]-=e}scale(e){for(let t=0;t<this.dimensions;t++)this.v[t]*=e}multi(e){let t=e.v,s=t.length;for(let o=0;o<s;o++)this.v[o]=this.v[o]*t[o]}get x(){return this.v[0]}get y(){return this.v[1]}get z(){return this.v[2]}get w(){return this.v[3]}},window.thread=class WindowThread{constructor(e){if(!e)return console.error("<br>@thread/constructor: No source given to create thread."),null;{let t=window.URL.createObjectURL(e);this.worker=new Worker(t)}}setEvent(e,t){if("onData"===e)this.worker.onmessage=t;else throw Error('@thread: Unknown event "'+e+'" passed.')}kill(){this.worker.terminate()}},window.onerror=function(e){console.error("<br>"+e),window.fe.isTextMode&&(cmd_string="",document.body.innerHTML+=`root@${window.fe.hostname}>`)},console.log("@system/libnix: Loading Startup Libraries..."),localStorage)(a=a.toUpperCase()).includes("OS:/USR/LIB/")&&a.includes(".FBL")&&eval(localStorage[a]);console.defaultLog=console.log.bind(console),console.logs=[],console.log=function(){console.defaultLog.apply(console,arguments),console.logs.push(Array.from(arguments)),window.fe.isTextMode&&(document.body.innerHTML+=console.logs[console.logs.length-1]+"<br>",window.scrollTo(0,document.body.scrollHeight))},console.defaultWarn=console.warn.bind(console),console.warn=function(){console.defaultWarn.apply(console,arguments),console.logs.push(Array.from(arguments)),window.fe.isTextMode&&(document.body.innerHTML+="<span style='color:yellow;'>"+console.logs[console.logs.length-1]+"</span><br>",window.scrollTo(0,document.body.scrollHeight))},console.defaultError=console.error.bind(console),console.error=function(){console.defaultError.apply(console,arguments),console.logs.push(Array.from(arguments)),window.fe.isTextMode&&(document.body.innerHTML+="<span style='color:red;'>"+console.logs[console.logs.length-1]+"</span><br>",window.scrollTo(0,document.body.scrollHeight))},console.debug=console.log,console.oldClear=console.clear,console.clear=function(){console.oldClear(),console.logs=[],window.fe.isTextMode&&(document.body.innerHTML="")},console.newLine=function(){window.fe.isTextMode&&(document.body.innerHTML+="<br>")},document.head.innerHTML='<meta charset="UTF-8"><title>FreeExecutor '+window.fe.version+"</title>",document.body.innerHTML="";let style=document.body.style;style.margin="0px",style.padding="0px",style.userSelect="none",style.background="rgb(20, 20, 20)",style.color="rgb(255, 255, 255)",style.fontFamily="monospace",style.fontSize="12px",style.overflowX="hidden";let fe_setup;localStorage.getItem("fe_setup")||(console.log("Welcome to FreeExecutor "+window.fe.version),console.log("(C) 2022 Doge Clan, Licensed under the LGPL 2.1 License"),console.newLine(),console.log("Setting Up Default Flags..."),localStorage.setItem("fe_textmode",!0),localStorage.setItem("fe_graphicsmode",!1),console.log("Finishing Setup..."),localStorage.setItem("fe_setup",!0),console.log("Done!"),console.clear()),window.fe.commandHistory=[],window.fe.parseCommand=function(cmd){let attrib=cmd;switch(" "===attrib.charAt(0)&&((attrib=[...attrib]).shift(),attrib=attrib.join("")),attrib=attrib.split(" "),window.fe.commandHistory.push(cmd),attrib[0]){case"":console.newLine();break;case"clear":console.clear();break;case"unset":let dl=attrib;dl.shift(),(dl=attrib.toString()).replaceAll(","," "),localStorage.removeItem("fe_"+dl),console.log("<br>Unset "+dl);break;case"eval":let evalStr=attrib;evalStr.shift(),eval(evalStr=(evalStr=evalStr.toString()).replaceAll(","," ")),console.newLine();break;case"fepkg":let flags=attrib;flags.shift();let flags_ln=flags.length;if(0===flags_ln)console.error("<br>Fatal! No Attributes defined! (Hint: Try --help to see possible options)");else{console.newLine();for(let i=0;i<flags_ln;i++)switch(flags[i]){case"--help":console.log("Options:"),console.log("&ensp;&ensp;--help: Show this menu"),console.log("&ensp;&ensp;--install-anonymous [name] [source] [isES6](default=false): Install an anonymous script to the page (Not persistant yet)"),console.log("&ensp;&ensp;--list-installed: List installed packages"),console.log("&ensp;&ensp;--list-commands: List installed commands");break;case"--install-anonymous":let packageName=flags[i+1]||"unknown-injected-"+window.fe.installedPackages.length,srcStr=flags[i+2];if(!srcStr){console.error("Error! No Script Source was defined!");break}let isES6=flags[i+3]||!1,xhttp=new XMLHttpRequest;xhttp.onreadystatechange=function(){if(4==this.readyState)switch(this.status){case 0:case 404:case 500:console.error("Failed to install "+packageName+"(anonymous)");break;case 200:window.fepkg.loadAnonymousScript(packageName,srcStr,isES6),console.log("Installed new package "+packageName+"(anonymous) ")}},xhttp.open("GET",srcStr,!0),xhttp.send(),i=flags_ln;break;case"--list-installed":let pkg_ln=window.fepkg.installedPackages.length;console.log("Installed Packages:");for(let j=0;j<pkg_ln;j++)console.log("&ensp;&ensp;"+window.fepkg.installedPackages[j]);i=flags_ln;break;case"--list-commands":let cmd_ln=window.fepkg.installedCommands.length;console.log("Installed Commands:");for(let j=0;j<cmd_ln;j++)console.log("&ensp;&ensp;"+window.fepkg.installedCommands[j]);i=flags_ln;break;default:console.error("Unknown attribute: "+flags[i])}}break;case"set":let str=attrib;str.shift();let data=(str=str.toString()).substring(str.indexOf("=")+1);data.includes(",")&&str.replaceAll(","," ");let dataAsArr=[...str];if("f"===dataAsArr[0]&&"e"===dataAsArr[1]&&"_"===dataAsArr[2]){for(let i=0;i<2;i++)data.shift();str=dataAsArr.toString()}let toSet=str.slice(0,str.indexOf("="));localStorage.setItem("fe_"+toSet,data),console.log("<br>Set "+toSet+" to value "+data);break;case"savelibnix":let prm=prompt("What should this libnix library be called?");(prm=prm.toUpperCase()).includes(".FBL")||(prm+=".FBL"),prm.includes("OS:/USR/LIB/")||(prm="OS:/USR/LIB/"+prm);let src=prompt("Insert source code below:");src?localStorage.setItem(prm,src):alert("You need to add source code to the library in order for it to work.");break;default:let index;if(-1===fepkg.installedCommands.indexOf(attrib[0]))console.error(`<br>${attrib[0]} is not a known command or program.`);else{let passedOn=attrib;window.fepkg[attrib[0]](passedOn)}}};let cmd_string="";function parseKeyInput_textMode(e){switch(e.key){case"Backspace":case"Delete":document.body.innerHTML=document.body.innerHTML.substring(0,document.body.innerHTML.length-1),cmd_string=cmd_string.substring(0,cmd_string.length-1);break;case"Enter":window.fe.parseCommand(cmd_string),document.body.innerHTML+=`root@${window.fe.hostname}>`,cmd_string="",window.scrollTo(0,document.body.scrollHeight);break;case"Shift":case"Control":case"Escape":case"Meta":case"Alt":case"Tab":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case">":case"<":case"&":break;default:document.body.innerHTML+=e.key,cmd_string+=e.key}}window.fe.isTextMode?(window.addEventListener("keydown",parseKeyInput_textMode),console.log(window.fe.startupMsg),document.body.innerHTML+=`<br>root@${window.fe.hostname}>`):window.fe.isGraphicsMode&&(style.overflow="hidden",window.fe.execGUI())}();

How to Use

Currently to see all commands, run fepkg --list-commands to see all currently installed commands.

Limitations

  • No Cross-Origin Scripts
  • Limitations that websites enforce still exist (It is just injected JS).
  • No VFS implementation (0.3.1/0.4 should add this)
  • Text UI is not fully done and prompt/alert are still used and not patched