Mostrando entradas con la etiqueta github. Mostrar todas las entradas
Mostrando entradas con la etiqueta github. Mostrar todas las entradas

lunes, 11 de julio de 2016

DoS con Slowloris.pl

Buenas hackers en esta PoC, os muestro esta genial herramienta que permite realizar un ataque de denegación de servicio a un servidor Linux. Esto genera que ese servicio sea inaccesible a los usuarios legítimos. En este caso mantiene conexiones abiertas el máximo tiempo posible a base del envío de peticiones http a una tasa de datos muy baja.. Para esta prueba de concepto se realizará en un entorno virtualizado controlado, usando una máquina atacante Kali Linux y un servidor Ubuntu como víctima.


Slowloris.pl esta escrita en perl y disponible en Github


Requirimientos y los pasos a seguir

 
How use Slowloris

Requirements:
# sudo apt-get update  
# sudo apt-get install perl
# sudo apt-get install libwww-mechanize-shell-perl
# sudo apt-get install perl-mechanize


1)Download slowloris.pl
2)Open Terminal
2)# cd /thePathToYourSlowloris.plFile
3)# ./slowloris.pl
4)# perl slowloris.pl -dns (Victim URL or IP) -options



Done


Laera Loris"

Documento de ayuda

 
TITLE
    Slowloris

VERSION
    Version 0.7 Beta

DATE
    06/17/2009

AUTHOR
    RSnake <h@ckers.org> with threading from John Kinsella

ABSTRACT
    Slowloris both helps identify the timeout windows of a HTTP server or
    Proxy server, can bypass httpready protection and ultimately performs a
    fairly low bandwidth denial of service. It has the added benefit of
    allowing the server to come back at any time (once the program is killed),
    and not spamming the logs excessively. It also keeps the load nice and low
    on the target server, so other vital processes don't die unexpectedly, or
    cause alarm to anyone who is logged into the server for other reasons.

AFFECTS
    Apache 1.x, Apache 2.x, dhttpd, GoAhead WebServer, others...?

NOT AFFECTED
    IIS6.0, IIS7.0, lighttpd, nginx, Cherokee, Squid, others...?

DESCRIPTION
    Slowloris is designed so that a single machine (probably a Linux/UNIX
    machine since Windows appears to limit how many sockets you can have open
    at any given time) can easily tie up a typical web server or proxy server
    by locking up all of it's threads as they patiently wait for more data.
    Some servers may have a smaller tolerance for timeouts than others, but
    Slowloris can compensate for that by customizing the timeouts. There is an
    added function to help you get started with finding the right sized
    timeouts as well.

    As a side note, Slowloris does not consume a lot of resources so modern
    operating systems don't have a need to start shutting down sockets when
    they come under attack, which actually in turn makes Slowloris better than
    a typical flooder in certain circumstances. Think of Slowloris as the HTTP
    equivalent of a SYN flood.

  Testing
    If the timeouts are completely unknown, Slowloris comes with a mode to
    help you get started in your testing:

   Testing Example:
    ./slowloris.pl -dns www.example.com -port 80 -test

    This won't give you a perfect number, but it should give you a pretty good
    guess as to where to shoot for. If you really must know the exact number,
    you may want to mess with the @times array (although I wouldn't suggest
    that unless you know what you're doing).
 
 HTTP DoS
    Once you find a timeout window, you can tune Slowloris to use certain
    timeout windows. For instance, if you know that the server has a timeout
    of 3000 seconds, but the the connection is fairly latent you may want to
    make the timeout window 2000 seconds and increase the TCP timeout to 5
    seconds. The following example uses 500 sockets. Most average Apache
    servers, for instance, tend to fall down between 400-600 sockets with a
    default configuration. Some are less than 300. The smaller the timeout the
    faster you will consume all the available resources as other sockets that
    are in use become available - this would be solved by threading, but
    that's for a future revision. The closer you can get to the exact number
    of sockets, the better, because that will reduce the amount of tries (and
    associated bandwidth) that Slowloris will make to be successful. Slowloris
    has no way to identify if it's successful or not though.

   HTTP DoS Example:
    ./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto
    5

  HTTPReady Bypass
    HTTPReady only follows certain rules so with a switch Slowloris can bypass
    HTTPReady by sending the attack as a POST verses a GET or HEAD request
    with the -httpready switch.

   HTTPReady Bypass Example
    ./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto
    5 -httpready
 
  Stealth Host DoS
    If you know the server has multiple webservers running on it in virtual
    hosts, you can send the attack to a seperate virtual host using the -shost
    variable. This way the logs that are created will go to a different
    virtual host log file, but only if they are kept separately.

   Stealth Host DoS Example:
    ./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -tcpto 1
    -shost www.virtualhost.com

  HTTPS DoS
    Slowloris does support SSL/TLS on an experimental basis with the -https
    switch. The usefulness of this particular option has not been thoroughly
    tested, and in fact has not proved to be particularly effective in the
    very few tests I performed during the early phases of development. Your
    mileage may vary.

   HTTPS DoS Example:
    ./slowloris.pl -dns www.example.com -port 443 -timeout 30 -num 500 -https

  HTTP Cache
    Slowloris does support cache avoidance on an experimental basis with the
    -cache switch. Some caching servers may look at the request path part of
    the header, but by sending different requests each time you can abuse more
    resources. The usefulness of this particular option has not been
    thoroughly tested. Your mileage may vary.

   HTTP Cache Example:
    ./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -cache

Issues
    Slowloris is known to not work on several servers found in the NOT
    AFFECTED section above and through Netscalar devices, in it's current
    incarnation. They may be ways around this, but not in this version at this
    time. Most likely most anti-DDoS and load balancers won't be thwarted by
    Slowloris, unless Slowloris is extremely distrubted, although only
    Netscalar has been tested.

    Slowloris isn't completely quiet either, because it can't be. Firstly, it
    does send out quite a few packets (although far far less than a typical
    GET request flooder). So it's not invisible if the traffic to the site is
    typically fairly low. On higher traffic sites it will unlikely that it is
    noticed in the log files - although you may have trouble taking down a
    larger site with just one machine, depending on their architecture.

    For some reason Slowloris works way better if run from a *Nix box than
    from Windows. I would guess that it's probably to do with the fact that
    Windows limits the amount of open sockets you can have at once to a fairly
    small number. If you find that you can't open any more ports than ~130 or
    so on any server you test - you're probably running into this "feature" of
    modern operating systems. Either way, this program seems to work best if
    run from FreeBSD.

    Once you stop the DoS all the sockets will naturally close with a flurry
    of RST and FIN packets, at which time the web server or proxy server will
    write to it's logs with a lot of 400 (Bad Request) errors. So while the
    sockets remain open, you won't be in the logs, but once the sockets close
    you'll have quite a few entries all lined up next to one another. You will
    probably be easy to find if anyone is looking at their logs at that point
    - although the DoS will be over by that point too.

What is a slow loris?
    What exactly is a slow loris? It's an extremely cute but endangered mammal
    that happens to also be poisonous. Check this out:

    http://www.youtube.com/watch?v=rLdQ3UhLoD4
 

Proof of concept 


Un saludo Naivenom

sábado, 14 de mayo de 2016

Lynis: Auditando la seguridad de tu Linux

Buenas compañeros,

En la entrada de hoy quería describir el uso de Lynis. Lynis es una herramienta de seguridad para auditar la seguridad de tu Linux.

Tan importante es conocer las vulnerabilidades de un sistema como llevar a cabo una configuración importante de la configuración por defecto que presenta la mayoría de aplicaciones una vez son instaladas.

Analiza el software instalado en el sistema para detectar problemas de seguridad. Junto a la información relacionada con la seguridad también buscará información general del sistema, los paquetes instalados y los errores de configuración.

A su vez, analiza y muestra información adicional como boot, criptografía, SSL, Kernel, base de datos,… A medida que analiza el software muestra los resultados que obtiene.
Finalmente, reporta un informe de conclusiones sobre los problemas encontrados, así como las sugerencias y recomendaciones para solucionar los problemas detectados.

En primer lugar, ¿De dónde lo descargamos? Se encuentra en Github, así que con la instrucción git clone:

https://github.com/CISOfy/lynis.git. 

Para su ejecución basta con el siguiente comando:

𝑠𝑢𝑑𝑜 𝑙𝑦𝑛𝑖𝑠 –𝑐

Comienza un análisis completo sobre la securización del sistema operativo:



Lynis analiza los diferentes apartados del sistema y visualizando información de ellos durante la ejecución:


Finalmente se visualiza un reporte final:



En este caso, analizando los avisos que ha detectado se puede observar dos registros de PHP que anteriormente en las recomendaciones básicas se deberían deshabilitar.

En el apartado de sugerencias, se recomienda emplear mecanismos para forzar al usuario a cambiar la contraseña periódicamente, separar ficheros importantes en diferentes particiones, emplear programas para chequear actualizaciones de software empleado, entre las más destacables.


Para un informe más completo Lynis facilita un reporte:





Adicionalmente sugiere securizar Apache con la instalación de módulos (mod_evasive, mod_qos,mod_spamhaus y mod_security) para prevenir ataques de DOS y fuerza bruta contra el mecanismos de autenticación, protección contra spammers y ataques contra aplicaciones web.

Finalmente muestra una estadística sobre la auditoría de securización en relación al número de test realizados y plugins activos.

Como se ha podido ver una herramienta más que recomendable para auditar nuestro Linux y conocer su estado, con fines muy aplicables a aplicar hardening.

Saludos.

NaxHack5

La mejor defensa es un buen ataque

jueves, 17 de marzo de 2016

Troyano Hacoder y el source code

Buenos dias!
En el dia de hoy os mostrare una herramienta realizada por LukaSiki/HaCoder.py. Podeis localizar el repositorio en GitHub.



Parte 1:
Primero analizaremos el código fuente para aquellos entusiastas en la programación con Python. La herramienta de administración remota (troyano), tiene un encriptado AES eligiendo valores aleatorios (random), haciendo su backdoor FUD eludiendo a los antivirus.


El archivo principal (Hacoder.py), es un script de igual modo que el anterior, conteniendo a su vez dentro de una función otro script que será la generación del backdoor. Se importan los modulos, clases de colores, el logo del programa y la encriptación AES.



Más adelante, cuando se finaliza de escribir las lineas de código correspondientes al script del backdoor, se define una función que corresponde a la generación del handler, es decir, las instrucciones correspodientes a la interacción con el cliente.



 Dentro de ella se definen funciones e interaciones como:
  • Enviar y recibir datos.
  • Subida y bajada de archivos.
  • Actualización de los clientes que se nos conecta a nuestro host, dada una dirección IP y puerto.
  • Uso de la instrucción "while" para repetir una serie de instrucciones mientras la condición sea verdadera (True)
Por último se crea el menu y una serie de condiciones con "if" dependiendo de la elección del usuario, realizando las correspodientes llamadas a las funciones creadas anteriormente.



Parte 2:
Ahora en esta parte, vamos a probar la herramienta en un entorno virtualizado en VMware. Para instalar la herramienta podemos clonar el repositorio ejecutando lo siguiente:
git clone  https://github.com/LukaSikic/HaCoder.py.git
Entramos en la carpeta generada, y damos permisos de ejecución con chmod
Es importante tener instalado Python para poder ejecutar el script, ya que es un lenguaje interpretado y necesita de una maquina virtual. El bytecode se utiliza y produce el resultado. 
Ejecutamos el script y generamos el backdoor, copiando la clave AES aleatoria e indicando nuestra IP y puerto a la escucha: 


Una vez creado el backdoor, generara un archivo .py, y como dijimos antes Python es un lenguaje interpretado, por tanto si queremos enviar este archivo a un cliente, tiene que tener Python instalado. Una opción interesante es compilar el archivo a un .exe. Entonces necesitaremos usar Pyinstaller:  https://github.com/pyinstaller/pyinstaller
Usamos la herramienta y ya tendriamos nuestro backdoor en .exe. Existen buenos tutoriales del uso de esta herramienta. 
Al elegir la opción 3 del menu del programa, automaticamente pasará al handler a la espera de conexiones, como se puede apreciar el cliente ejecuto el .exe y se nos conecto:





Hacemos Control + C para interactuar con el cliente, y obtenemos una shell del cliente: 


Una vez obtenido la shell, podemos según las funciones declaradas en el código fuente subir y descargar archivos, escalada de privilegios, keylogger y hacerlo persistente. 
Un saludo, naivenom

P.D No me hago responsable del mal uso de esta herramienta y probarlo siempre en un entorno virtualizado usando dos maquinas virtuales, una el cliente y otra de servidor a la escucha de conexiones. 







 









lunes, 15 de febrero de 2016

Veil-Evasion y metasploit



Buenas tardes hackers!

En esta prueba de concepto realizada en un entorno virtualizado, se conseguirá una sesión meterpreter a través de un exploit(multi/handler) y la vulnerabilidad crítica basada en la persona con un windows 7. Para ello se usara una herramienta llamada Veil-Framework, donde generaremos un payload que tiene como objetivo ejecutarse en la máquina víctima para realizar la acción maliciosa y bastante indetectable por la mayoría de los antivirus. Instalamos la herramienta en Kali clonando desde github.



Una vez tengamos la carpeta de Veil entramos y ejecutamos /Install.sh. Recomiendo la lectura en github de los pasos y las condiciones que se han de cumplir antes de instalar la herramienta, para que no exista ningún tipo error.





Una vez instalado nos situamos en la carpeta Veil-Evasion y ejecutamos previamente dando los permisos necesarios para la ejecución. Existen 49 payloads. El comando a usar es ./Veil-Evasion.py.



Podemos apreciar los distintos payload que existen, dependiendo del entorno en el que se ejecuten.



Configuramos uno de los payload más interesantes, llamado meterpreter con conexión inversa. El atacante lanzara el exploit y permanecerá a la escucha de conexiones hasta que la víctima ejecute el código malicioso y el payload se conectara a la dirección IP asociado a un puerto determinado.
IP--->172.16.22.133 (atacante)
Puerto--->4444 (atacante)
De esta forma ya tendríamos configurado nuestro payload que enviaremos a través de ingeniería social a nuestra víctima.



El archivo que genera es un .bat (backdor.bat) en la carpeta veil-output. Para que la victima pueda ejecutarlo sera necesario convertirlo en un .exe. Existen muchos programas para hacerlo, en esta PoC se usa el Bat To Exe Converter v2.4.



Una vez convertido el .exe lo analizamos con www.scan4you.net y nos da un resultado de detecciones de antivirus por firmas de 5/35, no esta nada mal.

Ahora ya creado una parte importante y fundamental que es la conexión, necesitamos abrir Metasploit (msfconsole) que será la parte que actuara como si de un servidor se tratase a la escucha de conexiones.
Ejecutamos el comando msfconsole, y usamos el exploit multi/handler que servirá con el fin de que la víctima ejecute el archivo y el payload realice la conexión inversa al atacante, dándole acceso a la maquina.
Una vez obtenido la sesión meterpreter, la maquina victima esta comprometida donde se puede realizar acciones de todo tipo, ya sea una linea de comandos como un keylogger.



P.D No me hago responsable del mal uso que se le de a esta PoC, es de carácter educativo y esta realizado en un entorno virtualizado. No seáis malos!!

Google Analytics