Contenido principal

B-Sides Vancouver CTF 2015 - garbage file

Marzo 18, 2015

Description

Your buddy Joey left a USB key with some data he needs your help with. He pulled it from the firewall logs at a 'secure file format'-as-a-Service provider, so he's pretty sure it might be protected or obfuscated somehow.

garbagefile.pcapng.gz

Solution

A PCAPNG file is provided, there we can see some UDP packets where the data is located:

We need to get all the data sent over UDP, we can do it by using tshark:

$ tshark -r garbagefile.pcapng -Y "udp" -T fields -e data
00026163636f756e742d646174612e62696e006f6374657400
00040000
0003000100004edf00002e77789c0173018cfe4435d00b168b...
00040001
00030002803434680f53d41a3d4068007a801a1ea0341a1ea7...
00040002
00030003142dfea2fb389f6ded40c310f8dcc905034127d07f...

Each message is composed by two short integers (first one to indicate which is sending the message + second one an incremental ID), and the data itself. I used this script on PHP to separate data from metadata and create bzip files (based on bzip headers found on the dump):

<?php

$file = file('data.txt');

$out = '';
for ($i = 2; $i < count($file); $i += 2) { // ignore first and second line, then each two
    $out .= hex2bin(substr(trim($file[$i]), 8)); // strip metadata
}

$i = 0;
$bzs = explode('BZh', $out);
foreach ($bzs as $bz) {
    file_put_contents('bzips/' . $i++, 'BZh' . $bz);
}
?>

Twenty two files are created, it is time to decompress them using python:

import bz2
import sys

for i in xrange(0,22):
    try:
        file = bz2.BZ2File(str(i), "r")
        print file.read()
    except:
        sys.stderr.write('file '+ str(i) + ' invalid\n')

There are only three "corrupted" files:

file 0 invalid
file 8 invalid
file 21 invalid

First file does not contain a bzip header, so it was skipped. Second file is the heaviest (20.8KB) and it is possible the file we are looking for. We are making a guess now, the file seems to have a Zlib header:

It is decompressed properly giving us a base64 encoded file:

iVBgMA0KNH0AAC56SUhqJQAALO0AAC4TCAIudwCpR3DoAC53AXN8MEIAgLkc6S53AAleP1lzLncL
Ey53CxMvd5qcNncAQC4+REF6DwHt83C8BWsCMPB7xwsIBH9SBQojRUGjPbH3OPolxPZlTYIDJj8T
Y3saExvhmNgfMRMLBOHERp5W2MAofwgoM9MqKqxXWL7RyXlvwZnM7FMM997V/ez88Ji+2ffuM2fg
... (cropped)
a0ANOm8oMH4XoMBu9tWlbty/38TVNdQQJ2Cg7jeBgSx0BQYkA6fAjrm700S/OVBO18BAr/YCAyuh
KAUoAr5GFRFAa463QIGvdQMFKH10p+7Xzrv9Hcg5fhegwG72gQItctYoK3F1vmhMZkBF18BAr/YC
AytxCnSJt6DOlaRqyBcnYKDuN4GBLHQF1gZyBnWQMTtmbhygwG72gQItcgYKWtDA/ymC2qJiimhr
73cAAC4+RU5q2UJgrA==

Final result is a PNG file encrypted with XOR using "00 00 2E 77" as key:

Flag

key{03087-08351-27H}

Archivado en: Miscelaneo, Retos informáticos, Seguridad | Comentarios (0)

FREAK on Colombian domain names and Heartbleed one year later

Marzo 4, 2015

I am here writing again about some statistics, this time is for the new vulnerability found on SSL/TLS (FREAK Attack) against critical Colombian domain names. Same methogolody of Overview of OpenSSL security bug (CVE-2014-0160) on critical Colombian domain names is used in this post.



FREAK Attack on restricted colombian domain names

Identifying vulnerable domains

A python script was used to identify in a non-intrusive way the affected Colombian domain names (gov.co, edu.co, mil.co, and org.co):

    for domain in domains:
        result = ''
        IP = domain_exists(domain)
        if IP != False:
            if check_connectivity(IP):
                if check_FREAK(IP):
                    result = 'VULNERABLE'
                else:
                    result = 'NOT-VULNERABLE'
            else:
                result = 'SECURE-CHANNEL-UNSUPPORTED'
        else:
            result = 'NON-EXISTENT'

Results

2975 domain names were tested against the vulnerability, the results are impressive, from 1815 domains that support HTTPS only 46 are affected (it is possible to make a man in the middle attack while the domains is using SSL/TLS):



This is the detail of the results classified by each Third-level domain:

:arrow: gov.co, 662 not vulnerable, 18 vulnerable.
:arrow: edu.co, 689 not vulnerable, 15 vulnerable.
:arrow: mil.co, 58 not vulnerable, 1 vulnerable.
:arrow: org.co, 360 not vulnerable, 12 vulnerable.



Finally, we got the distribution of the vulnerable Colombian third-level domains:



Heartbleed a year later

One year later the same script and data were used to test the heartbleed vulnerability (Overview of OpenSSL security bug (CVE-2014-0160) on critical Colombian domain names), this is what I found:

:arrow: Only 2 domain names were found to be free of the Heartbleed vulnerability, 16 are still vulnerable.
:arrow: 177 domain names have implemented HTTPS.
:arrow: 115 domain names were deleted (or DNS A record does not exist).
:arrow: 86 domain names dropped HTTPS support.

Archivado en: Seguridad | Comentarios (0)

Overview of OpenSSL security bug (CVE-2014-0160) on critical Colombian domain names

Abril 10, 2014

* Update on methodology and results: Statistical sample
* Update on methodology and results: Retest

The TLS heartbeat read overrun (CVE-2014-0160) (also known as The Heartbleed Bug) is the hot topic right now on the information security field. While this publication is not about the technical detail of the bug but some statistics of critical affected Colombian domains, I will show you a big picture of the vulnerability and the results of my research.

If you would like to know more about it, please take a look at the following resources: The Heartbleed Bug, Sean Cassidy's technical analysis, Robert Erbes' technical analysis.

Vulnerability summary

The Heartbleed Bug allows an attacker to read sensitive information contained in the memory of the process which depends on the OpenSSL implementation (OpenSSL from version 1.0.1 to 1.0.1f).

Sensitive information such as user credentials, session IDs, data sent to the server and received by the client, private keys, and anything you can imagine could be found by exploiting this vulnerability.

Affected users are recommended to fix the issue as soon as possible by updating to the latest version of OpenSSL (1.0.1g).

Methodology and results

Restricted Colombian domain names

Using domain name searching methods I was able to get a long-enough list of third-level domains (the list does not include subdomains) which are classified by NIC.CO as restricted user domains, this is, the person who register the domain have to meet certain legal requirements to be able to get a restricted domain name (gov.co, edu.co, mil.co, and org.co).

These domains are used by Colombian government agencies or institutions, Colombian educational sector institutions recognized by the Ministry of National Education, Agencies or institutions of the Colombian Armed Forces, and Companies or nonprofit institutions resident in Colombia.

Update note about the statistical sample

Through this methodology, a sample of 2612 domain names were found which is a 99% representative sample for a hypothetical case of 10000 (*) valid and functional domain names.
* Approximate data provided by NIC.CO

Evaluation date

Start time: 08/04/2014 - 22:48
Finish time: 08/04/2014 - 23:30

Identifying vulnerable domains

A modified version of the Jared Stafford's python script was used to identify in a non-intrusive way the affected domains (no data was stored or viewed on the test, the script just only show the status of the server).

    for domain in domains:
        result = ''
        ip = domain_exists(domain)
        if ip != False:
            if check_connectivity(domain):
                try:
                    if check_heartbleed(domain):
                        result = 'VULNERABLE'
                    else:
                        result = 'NOT-VULNERABLE'
                except Exception:
                    result = 'SECURE-CHANNEL-UNSUPPORTED'
            else:
                result = 'SECURE-CHANNEL-UNSUPPORTED'
        else:
            result = 'NON-EXISTENT'

Results

2612 restricted domain names were tested against the vulnerability (perhaps this is not the total number of valid domain names). There are 1592 domains that are not vulnerable and 252 that are (a total of 1844 domains with HTTPS support distributed on 985 different IPs, and 768 not applicable):



This is the detail of the results classified by each Third-level domain:

:arrow: gov.co, 602 not vulnerable (51.99%), 70 vulnerable (6.04%), 486 not applicable (41.97%).
:arrow: edu.co, 639 not vulnerable (68.34%), 104 vulnerable (11.12%), 192 not applicable (20.53%).
:arrow: mil.co, 17 not vulnerable (25.76%), 42 vulnerable (63.64%), 7 not applicable (10.61%).
:arrow: org.co, 334 not vulnerable (73.73%), 36 vulnerable (7.95%), 83 not applicable (18.32%).



Finally, we got the distribution of the vulnerable Colombian third-level domains:



Retest

One month later 252 domains have been tested against the vulnerability, the results are shown:

:arrow: 228 (90.48%) domains do not have the bug anymore.
:arrow: 5 (1.98%) domains turn off their HTTPS support.
:arrow: 6 (2.38%) domains do not have an A record associated on the DNS.
:arrow: 18 (7.14%) domains on 16 IPs are still vulnerable.

Comparison of vulnerable domains one month later:


Final overview of the OpenSSL security bug on Colombian third-level domain names:


Incident handling

:arrow: 08/04/2014 - Start of the security test.
:arrow: 09/04/2014 - colCERT was contacted to coordinate the incident handling and communicate the issue to the affected domains.
:arrow: 10/04/2014 - First contact with colCERT (list of 252 affected domain names was provided), they are taking now all necessary steps to solve the issue on the affected domains.
:arrow: 11/04/2014 - First contact with NIC.CO, they are working together with colCERT to solve the issue on all the affected domains.
:arrow: 08/05/2014 - Start of the security retest.
:arrow: 10/05/2014 - Final update.

Archivado en: Seguridad | Comentarios (1)

Campus Party Colombia 2013

Octubre 13, 2013

Esta semana, del 7 al 13 de Octubre, se llevó a cabo la sexta edición de Campus Party Colombia en la ciudad de Medellín. En el área de seguridad se encontraba la propuesta de la competencia para este año, en total fueron 30 retos, de los cuales se solucionaron 23.

En el siguiente enlace puede encontrar la solución para cada uno de lo 23 retos resueltos:

:arrow: Solución retos de seguridad Campus Party Colombia 2013

En el sitio principal de NULL Life puede encontrar solucionarios a otros eventos organizados a nivel nacional e internacional.

El tablero "final" de puntuación es el siguiente:
Scoreboard Campus Party Colombia 2013

Tanto en el juego presencial como en la gráfica se puede evidenciar el juego no limpio, la gráfica con los valores reales queda a consideración de los organizadores.

Debido a esto, y a otros sucesos, el equipo NULL Life, anuncia públicamente que no volverá a participar en este tipo de eventos, a menos que reglas claras y concisas sean establecidas antes del juego, y estas se respeten.

Archivado en: Criptografía, Ingeniería Inversa, Retos informáticos, Seguridad | Comentarios (0)

One-time pad challenge

Julio 13, 2013

El día 7 de Marzo de 2013 publiqué en el grupo de Sinfocol en Facebook un mini reto relacionado con el cifrado One-time pad, cuyo funcionamiento constituye el esquema perfecto de cifrado si es usado correctamente:

Los tres ganadores fueron:
1. Everth Gallegos (PerverthsO)
2. Manuel Suárez (Blackubay)
3. Juan Escobar

La descripción del reto todavía se encuentra en el grupo:



El contenido del archivo dota2.txt es el siguiente:

ekFAEUFdTRFQU05RFV9VWEEeE3oTW1VcGFhSF3BHXVdYRR4UWEMXXVJTRl5eXhNC
UVwZRklQUldRU0UZWVEWX04XU1dTQkVTQUMfFXoVV1ZbV1tBF0VWVF4KF1pARhV4
Fl1aXUAURl9VQhZHUVRQQRJAVUFDQFhKW0ddEUBbQ1dGGVdaX1ZDQBNYVlZcEF1W
E1JdS1JXQhBCUVoWehBAUksRHhJAR1teEkBYRxNAUVUXU1VUVlBMElZeGERfUF4K
GVRcURFJVE0QRVlQThNQUkJUGF9YQVRbSRJCRVtbXVcRVRlOXEZcGFtXFkNHRU1a
GhR1Q0UUW1FYTxhRSxJGXlFRQhBXV1RHUl9bXlVLFURSRlcfFEFcUUBRE0BQQxda
XVwQWFEXQFxcVBJHXlBWXRFGRVtDUxFZXllMVVISW1QIExwTcRRYXVJeEEdfUFwQ
QFxcShNMXVpRFkldTBdCXxZVVhdEQVxcEElYRUsTVU1WQl0dElZaUBNZW0MQQFgS
X1VCGU9WQkVBVVVFVEMRVlQWXVdbVl9OVF0QUEwVRV1UEF5ZR1RRFlxRF19IEVRe
WkNGXVdUXRoUZl1VTBZWQFReTRZDWBBfWUNRFFtcU1cZV0RRVVtdUhRbUxRKUUxQ
VlAZR1lfQBoYWlxRUkVDXBhDUVZIEkBSQVMRRE1AVBVAXRRbXBlWV01QVEJWURFV
SxJBX1dcFlhLGXwRVkNTWF1UE15IGF5cQksYV1dXGVxdSkZYV0xUVBVVSxBdVl9b
UFBdXFpNAxhDUVZKElNWREZUWVdYTRNVWFMTUUFCVllDGUNfFlpREVteR0QTSl9R
XFxUVkRFF1BdEkNXQVpcXxJHX19HGhRNXlhXSkYTU0gYRFpWEl5YSlFQEFZeEVxY
WkRNVFtQVRFDXVNOEVpWV18TR1pVFl9XQ1JXFV9fGUJDTUVQAxFTVkEQQFlTVxB6
FVVaGVFWXF1QVRlSUFhRRBdGX1JMFn8XUlUVXVVbQ0ddWU0cEnpBTRlRVxJYV0EY
VFxeVFBFUVdGF1gWRlFNGFJDVlUUQFxWX0FHFw==

Las pistas proporcionadas durante el transcurso de cada día en la semana fueron:
:arrow: Base64.
:arrow: Esquema de cifrado perfecto, indestructible, inquebrantable, inmejorable, irrompible, etc... en ciertos casos, cuando es usado de forma correcta.
:arrow: La primera palabra del texto plano es: "How".
:arrow: La última pista es: Número E!
:arrow: Texto plano = b64.decode(dota2.txt) ^ Número E

La última verdadera pista contenía la forma de resolver el acertijo, acertijo que puede ser encontrado en forma de código fuente (Gracias a Juan Escobar por permitirme publicar su código):

# Reto Sinfocol
# https://www.facebook.com/groups/107415515957353/422375584461343/
# Juan M. Escobar T. @itsecurityco

import base64

ciphertext = base64.b64decode("ekFAEUFdTRFQU05RFV9VWEEeE3oTW1VcGFhSF3B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669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531952510190115738341879307021540891499348841675092447614606680822648001684774118537423454424371075390777449920695517027618386062613313845830007520449338265602976067371132007093287091274437470472306969772093101416928368190255151086574637721112523897844250569536967707854499699679468644549059879316368892300987931277361782154249992295763514822082698951936680331825288693984964651058209392398294887933203625094431173012381970684161403970198376793206832823764648042953118023287825098194558153017567173613320698112509961818815930416903515988885193458072738667385894228792284998920868058257492796104841984443634632449684875602336248270419786232090021609902353043699418491463140934317381436405462531520961836908887070167683964243781405927145635490613031072085103837505101157477041718986106873969655212671546889570350354";
# http://www.greatplay.net/uselessia/articles/e2-1000.html

plaintext = ''
for i in range(0,len(ciphertext)):
    plaintext += unichr(ord(ciphertext[i]) ^ ord(key[i]))

print plaintext

El texto plano es el siguiente:

How you have felt, O men of Athens, at hearing the speeches of my accusers, I cannot tell; but I know that their persuasive words almost made me forget who I was - such was the effect of them; and yet they have hardly spoken a word of truth. But many as their falsehoods were, there was one of them which quite amazed me; - I mean when they told you to be upon your guard, and not to let yourselves be deceived by the force of my eloquence. They ought to have been ashamed of saying this, because they were sure to be detected as soon as I opened my lips and displayed my deficiency; they certainly did appear to be most shameless in saying this, unless by the force of eloquence they mean the force of truth; for then I do indeed admit that I am eloquent. But in how different a way from theirs!

Felicitaciones a los ganadores!

Archivado en: Criptografía, Retos informáticos | Comentarios (2)