From 6183cf13e3b5a1801b2908308974b724426c6482 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 24 Sep 2015 05:44:15 +0200 Subject: [PATCH] Proper implementation for a reverse shell --- scripts/shell.coffee | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/shell.coffee b/scripts/shell.coffee index 84d0fb0..8a2f585 100644 --- a/scripts/shell.coffee +++ b/scripts/shell.coffee @@ -67,9 +67,23 @@ module.exports = (robot) -> return res.send res.random nope unless isFromAdmin(res) process.exit 0 - robot.respond /emergency-shell/i, (res) -> + robot.respond /(emergency|reverse) shell|phone home/i, (res) -> return res.send res.random nope unless isFromAdmin(res) - runCmd "ssh -R 2200:localhost:22 -p 221 rnhmjoj@rnhmjoj.ydns.eu", res + rhost = process.env.REV_REMOTE_HOST + rport = process.env.REV_REMOTE_PORT || 22 + rtport = process.env.REV_REMOTE_TUNNEL_PORT || 2200 + host = process.env.REV_LOCAL_HOST || "localhost" + port = process.env.REV_LOCAL_PORT || 22 + key = process.env.REV_KEY + return res.send 'non รจ impostato nessun host' unless rhost? + return res.send 'manca una chiave ssh' unless key? + + ssh = "ssh -R #{rtport}:#{host}:#{port} -i #{key} -p #{rport} #{rhost}" + + res.send "ok, apro una reverse shell #{rhost}:#{rtport} -> #{host}:#{port}" + res.send "connettiti entro 10s" + runCmd ssh, res, -> + res.send "connessione chiusa. reverse shell terminata" robot.on 'githubhook', (data,params) -> if data.ref is 'refs/heads/master' and process.env.AUTO_KILL_ON_UPDATE