Saltar al contenido
Underc0de /foro

[Python][PHP] Shell Finder

Iniciado por blackdrake, Julio 10, 2015, 07:12:23 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Avatar de blackdrake
Julio 10, 2015, 07:12:23 AM Ultima modificación: Julio 10, 2015, 07:13:55 AM por blackdrake

[Python][PHP] Shell Finder

Hola @Underc0de, he hecho un script en python para que se encarga de buscar todo tipo de backdoors en el directorio que le indiquemos (por defecto será /var/www/), no he podido dedicarle todo el tiempo que me gustaría, pero creo que funciona bastante bien y es muy sencillo añadirle más valores de búsqueda.

Soy consciente de que el código no es el idóneo para realizar este tipo de búsquedas, pero como dije arriba, por falta de tiempo no puedo reestructurarlo.

Usar sudo, si se van a escanear directorios que no pertenecen al usuario que lo ejecuta.

[Python][PHP] Shell Finder


Código: python
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: @alvarodh5 | Blackdrake

    #########################################################################################################
    #                                            Shell Finder Python                                        #
    #                                                                                                       #
    #                                        coded by Blackdrake for Underc0de                              #
    #                                                                                                       #
    #                                                05/06/2015                                             #
    #                                                                                                       #
    #                                Underc0de.org | twitter.com/alvarodh5        #
    #                                                                                                       #
    #                                      Run this tool as root                                #
    #########################################################################################################

import os

class color:
   PURPLE = '\033[95m'
   CYAN = '\033[96m'
   DARKCYAN = '\033[36m'
   BLUE = '\033[94m'
   GREEN = '\033[92m'
   YELLOW = '\033[93m'
   RED = '\033[91m'
   BOLD = '\033[1m'
   UNDERLINE = '\033[4m'
   END = '\033[0m'

print color.BLUE + " __ _          _ _     ___ _           _" + color.END       
print color.BLUE + "/ _\ |__   ___| | |   / __( )_ __   __| | ___ _ __ "+ color.END
print color.BLUE + "\ \| '_ \ / _ \ | |  / _\ | | '_ \ / _` |/ _ \ '__|"+ color.END
print color.BLUE + "_\ \ | | |  __/ | | / /   | | | | | (_| |  __/ | "+ color.END
print color.BLUE + "\__/_| |_|\___|_|_| \/    |_|_| |_|\__,_|\___|_| "+ color.END 
print ""
print color.YELLOW + "By Blackdrake (@alvarodh5) para Underc0de" + color.END
print ""
print color.GREEN + "Asegurese que los ficheros que detecta son ilegitimos antes de eliminarlos" + color.END
print color.GREEN + "Tenga en cuenta, que dependiendo de la cantidad de ficheros que tenga en su servidor, el script tardara mas o menos" + color.END                                           
raw_input("[Pulse INTRO para continuar]")
print color.GREEN + "Introduzca ruta del directorio donde aloja sus ficheros (Pulsa Intro para utilizar por defecto, /var/www/)" + color.END
directorio = raw_input ("")
if (directorio == ""):
directorio = "/var/www/"
else:
longitud = len(directorio) - 1
if not(directorio[longitud] == "/"):
directorio += "/"

print color.BLUE + "Buscando Shells conocidas" + color.END + "" + color.RED
os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep r57 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible R57 [PHP] --> rm -rf " $2}\'| uniq')

os.system('find ' + directorio + ' -name "*".txt  -type f -print0  | xargs -0 grep r57 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible R57 [TXT] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep c99 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C99 [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".txt  -type f -print0  | xargs -0 grep c99 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C99 [TXT] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep c100 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C100 [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".txt  -type f -print0  | xargs -0 grep c100 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C100 [TXT] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep c98 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C98 [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".txt  -type f -print0  | xargs -0 grep c98 | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible C98 [TXT] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep SE3lRVER | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible WEEVELY SHELL [PHP] --> rm -rf " $2}\' | uniq')

print color.END + color.BLUE + "Otros posibles casos de Shell" + color.END + "" + color.YELLOW

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep shell | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep backdoor | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep stealth | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep exec | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep popen | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep proc_open | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep symlink | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep passthru | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep system | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

os.system('find ' + directorio + ' -name "*".php  -type f -print0  | xargs -0 grep milw0rm | uniq -c  | sort -u  | cut -d":" -f1  | awk \'{print "Posible Shell [PHP] --> rm -rf " $2}\' | uniq')

print color.END + color.GREEN + "Escaner finalizado, siguenos! @underc0de @alvarodh5 " + color.END


Espero que os guste y si alguien lo termina, por favor, que me lo comunique.

Un saludo.
WhatsApp Telegram


5 respuestas

Avatar de Decode
No has probado hacer un shell finder en php? sería muy bueno..

Saludos.

Avatar de blackdrake
Cita de: Decode en Julio 10, 2015, 01:35:36 PM
No has probado hacer un shell finder en php? sería muy bueno..

Saludos.

Se podría hacer, pero creo que consumiría más recursos, igualmente cuando tenga un hueco lo haré :D


Saludos.


Avatar de BigBear
yo hice algo asi en perl creo que se llamaba "destroyer shell" , pero este script buscaba mediante un array predeterminado , lo tuyo parece mas preciso.

Avatar de Baxtar
Me da este error en la linea 17 en la de import
Código: text
 File "shel.py", line 17
    import os
    ^
IndentationError: unexpected indent
[kiev@ft ~]$

Avatar de Jimeno
Has hecho mal el copia y pega, elimina las tabulaciones y espacios sobrantes al inicio de cada línea
Cita de: Baxtar en Julio 22, 2015, 02:49:57 AM
Me da este error en la linea 17 en la de import
Código: text
 File "shel.py", line 17
    import os
    ^ :)
IndentationError: unexpected indent
[kiev@ft ~]$

Contacto: @migueljimeno96 -

¿Te quedó una duda sobre Seguridad web y en servidores?

Preguntala y te responde la comunidad (y el asistente Underc0de IA si nadie llega antes). Es gratis y tarda un minuto.

Ya tengo cuenta
Guardamos tu pregunta en este navegador: después de entrar la publicás con un clic.
Grupo de WhatsApp