Simple Honeypot en Python

Iniciado por ???????, Mayo 06, 2019, 06:28:04 PM

Tema anterior - Siguiente tema

0 Miembros y 2 Visitantes están viendo este tema.

Mayo 06, 2019, 06:28:04 PM Ultima modificación: Mayo 07, 2019, 12:04:04 PM por ANTRAX
Buenas a todos! Quería compartirles una herramienta que hice en Python. Se tratá de un Honeypot (un sistema trampa para los atacantes). Como verán es de baja interacción, un script demasiado fácil de hacer. Permite abrir puertos de la maquina para simular un servicio (pj: ssh,ftp,etc). Aunque es más parecido a un IDS, sirve también como un señuelo. Acá les link para clonar el repositorio:

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Y acá el código, para que lo vean mejor:

Código: python
#!/usr/bin/python

# Honeypot de baja interaccion

# Creado por Kirari

import os
import sys
import datetime
import socket

def banner():
os.system('clear')

print("\n          ___    __  __        ___  ___  _____ ")
print("   /\  /\/___\/\ \ \/__\/\_/\ / _ \/___\/__   \ ")
print("  / /_/ //  //  \/ /_\  \_ _// /_)//  //  / /\/")
print(" / __  / \_// /\  //__   / \/ ___/ \_//  / /   ")
print(" \/ /_/\___/\_\ \/\__/   \_/\/   \___/   \/    ")
print("\n Creado por Kirari")

print("\n\n[+] Honeypot Activado!")
print("[!] Te avisare si ocurre algo sospechoso.")
                                           

def configuracion():
os.system('clear')
print('\a')
print("\n(CONFIGURAR HONEYPOT)")

direccion = raw_input('\n\n[-] Ingrese IP address: ')
try:
puerto = input('[-] Ingrese puerto a emular (1-65535): ')

if (puerto>=1 and puerto<=65535):
mensaje = raw_input("[-] Ingrese mensaje a enviar: ")
nombre_archivo = raw_input('[-] Nombre del log (Por default: Activity): ')
if(nombre_archivo==""): nombre_archivo = "Activity"
return (direccion,puerto,mensaje,nombre_archivo)
else:
print("[x] Numero de puerto incorrecto")
except ValueError:
print("[x] El puerto ingresado debe ser un entero")


def honeypot(ip,port,msg,register):
servidor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
servidor.bind((ip, port))

servidor.listen(5)

alive = True


while(alive):
conexion, intruder = servidor.accept()
string = "\n[+] Intruso detectado desde {} en {}\n[+] Tiempo: {}\n".format(str(intruder[0]),intruder[1],datetime.datetime.now().strftime("%c"))
print(string)

try:
conexion.send("%s\n"%(msg))
activity = conexion.recv(2048)
register.write(string + '[+] Datos de paquetes: ' + activity + "\n\n")
#print(activity)
conexion.close()
except socket.error:
pass




if __name__ == '__main__':
try:
data = configuracion()
logs = open(data[3]+".log",'w')
if(data!=None): banner(); honeypot(data[0],data[1], data[2],logs);
else: print("[x] No hay suficiente datos proporcionados.")
except KeyboardInterrupt:
logs.close()
print("Sesion honeypot terminada")


Poco a poco, iré mejorandolo. Espero que les guste, saludos!