Warning: This challenge is still active and therefore should not be resolved using this information.
Aviso: Este reto sigue en activo y por lo tanto no se debería resolver utilizando esta información.

Intro

This crackme is for the crack challenge 6 of canyouhack.it.

In this crackme the goal is to turn on all the lights. Note that a light off to the next, so if we interrupt this, we win.

Tools

Exeinfo (For crackme info)

Delphi Decompiler (For decompile)

 OllyDbg (For debug)

Decompiling

With Delphi Decompiler we can found easy the buttons and his offsets.
Go to the offset 401A64 in OllyDbg and analyze the code.
We view two jumps, one turn ON the light and the other Turn OFF the next light. Patching the call from offset 401A8B we get the serial.

Links


Primeras impresiones El crackme es el típico de usuario y número de serie. Si no introduces un nombre te salta
Hemos interceptado un mensaje secreto, pero ninguno de nuestros traductores lo sabe interpretar, ¿sabrías interpretarlo tú? Lo único que hemos
Warning: This challenge is still active and therefore should not be resolved using this information. Aviso: Este reto sigue en
Un error que habitualmente cometo cuando me enfrento a todo tipo de retos (especialmente en CTFs) es empezar a procesar

Aquí tenemos un crackme fuera de lo común, más que nada por que está programado en Brainfuck, un lenguaje de programación esotérico bastante complejo.

[-]>[-]<>++++++++[<++++++++++>-]<.+++++++++++++++++.>+++[<++++++>-]<..++++.-
-------.+++.--------------.>++++++[<------>-]<-.>+++++[<------>-]<-.,>,>,>,>
>>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++>>>>+++++++++++++++++++++++++++++++++++++++++
+++++++++++>>>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++>>>>++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<
<<<<<<<<<<<<<<<<[>>>>>>>-<<<<<<<-]>>>>>>><<+>>[[-]++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++.<]<[>]<<<<<[>>>>>>>>>>-<<<<<<<<
<<-]>>>>>>>>>><<+>>[[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++.<]<[>]<<<<<<<<[>>>>>>>>>>>>>-<<<<<<<<<<<<<-]>>>>>>>>>>>>><<+>>[
[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.<]<[>]<<<<<<<<<<<[>>>>>>>>>>>>>>>>-<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>><<+>>[
[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++.<]<[>]>>>[-]>[-]<+++++++++++++.---.>+++++++[<++++++++++++>-]<.>+++++++[<
--------->-]<+.>+++++[<++++++++>-]<+.>++++[<+++++++>-]<+.>+++++++[<---------
->-]<.>++++++++[<+++++++++>-]<+.+++++++++++.>+++++++[<----------->-]<.>+++++
++[<+++++++++++>-]<-.>+++++++[<------------>-]<+.>++++++++[<+++++++++++>-]<-
.-----.---------.+++++++++++..---------------.+++++++++.>++++++[<-----------
-->-]<.+++++++.>+++++[<++++++>-]<+.-----.++++++++.+++.>++++++[<------>-]<-.-
------.>++++++++[<++++++++++>-]<-.+++.>+++++++++[<--------->-]<-.+++++++.>++
+++[<++++++>-]<+.-----.+++++++++++.>++++++[<------>-]<-.-------.>++++++++[<+
+++++++++>-]<-.+++.>+++++++++[<--------->-]<-.+++++++.>+++++[<+++++>-]<+.+++
+++++.+++.>++++++[<------>-]<-.+++++++...--------------.>++++++++[<+++++++++
++>-]<+.----------.++++++.>+++++++[<------------>-]<-.>++++++++[<+++++++++>-
]<.-------.>+++[<+++++++>-]<.-----------------.>+++++++[<---------->-]<+.>++
+++++[<++++++++++>-]<.-----.++++++++.+++.-------.-.>++++++[<--------->-]<.--
------------.>+++++[<++++++++>-]<+.>++++[<+++++++>-]<+.>+++++++[<---------->
-]<.>+++++++[<++++++++++++>-]<.------------.---.+++++++++++++.-------------.
>+++++++[<---------->-]<+.>++++++++[<+++++++++>-]<+.++++++++++.>+++++++[<---
--------->-]<+.>++++++[<+++++++++++++>-]<.+.+++++.------------.+.+++++.-----
--.>++++++[<---------->-]<+.------------.>++++++++[<+++++++++++>-]<+.-------
---.++++++.>+++++++[<------------>-]<-.>++++++++[<+++++++++>-]<.-------.>+++
[<+++++++>-]<.-----------------.>+++++++[<---------->-]<+.>++++++++[<+++++++
++++>-]<-.--------------.+++++.>++++++[<------------->-]<.+.

La solución que he encontrado yo, es convertir el código brainfuck a algo más amigable y depurarlo hasta encontrar la solución. La conversión la he realizado con VBBrainFNET y luego la depuración con Visual Studio. El crackme te pide una clave de cuatro cifras para darte la solución, pero si no quieres volverte loco puedes amañar los bucles para encontrar la solución.

¡SUERTE!

Enlaces

 

Se nos entrega el siguiente ELF:

/* This file was generated by the Hex-Rays decompiler version 8.4.0.240320.
   Copyright (c) 2007-2021 Hex-Rays <info@hex-rays.com>

   Detected compiler: GNU C++
*/

#include <defs.h>


//-------------------------------------------------------------------------
// Function declarations

__int64 (**init_proc())(void);
void sub_1020();
// int printf(const char *format, ...);
// int getchar(void);
// int fflush(FILE *stream);
// __int64 __isoc99_scanf(const char *, ...); weak
// void __noreturn exit(int status);
// int __fastcall _cxa_finalize(void *);
void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void));
FILE **deregister_tm_clones();
__int64 register_tm_clones(); // weak
FILE **_do_global_dtors_aux();
__int64 __fastcall frame_dummy(_QWORD, _QWORD, _QWORD); // weak
int __fastcall main(int argc, const char **argv, const char **envp);
_BOOL8 __fastcall comprobacion(char a1, char a2, int a3);
void _libc_csu_fini(void); // idb
void term_proc();
// int __fastcall _libc_start_main(int (__fastcall *main)(int, char **, char **), int argc, char **ubp_av, void (*init)(void), void (*fini)(void), void (*rtld_fini)(void), void *stack_end);
// int __fastcall __cxa_finalize(void *);
// __int64 _gmon_start__(void); weak

//-------------------------------------------------------------------------
// Data declarations

_UNKNOWN _libc_csu_init;
__int64 (__fastcall *_frame_dummy_init_array_entry)() = &frame_dummy; // weak
__int64 (__fastcall *_do_global_dtors_aux_fini_array_entry)() = &_do_global_dtors_aux; // weak
void *_dso_handle = &_dso_handle; // idb
char *a = "MdfnJk"; // weak
char *b = "jYx}"; // weak
char *c = "gWmfk"; // weak
char *d = "mlvpc"; // weak
char *f = "neU++w"; // weak
FILE *_bss_start; // idb
char completed_0; // weak


//----- (0000000000001000) ----------------------------------------------------
__int64 (**init_proc())(void)
{
  __int64 (**result)(void); // rax

  result = &_gmon_start__;
  if ( &_gmon_start__ )
    return (__int64 (**)(void))_gmon_start__();
  return result;
}
// 40D0: using guessed type __int64 _gmon_start__(void);

//----- (0000000000001020) ----------------------------------------------------
void sub_1020()
{
  JUMPOUT(0LL);
}
// 1026: control flows out of bounds to 0

//----- (0000000000001090) ----------------------------------------------------
// positive sp value has been detected, the output may be wrong!
void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void))
{
  __int64 v3; // rax
  int v4; // esi
  __int64 v5; // [rsp-8h] [rbp-8h] BYREF
  char *retaddr; // [rsp+0h] [rbp+0h] BYREF

  v4 = v5;
  v5 = v3;
  _libc_start_main(
    (int (__fastcall *)(int, char **, char **))main,
    v4,
    &retaddr,
    (void (*)(void))_libc_csu_init,
    _libc_csu_fini,
    a3,
    &v5);
  __halt();
}
// 1096: positive sp value 8 has been found
// 109D: variable 'v3' is possibly undefined

//----- (00000000000010C0) ----------------------------------------------------
FILE **deregister_tm_clones()
{
  return &_bss_start;
}

//----- (00000000000010F0) ----------------------------------------------------
__int64 register_tm_clones()
{
  return 0LL;
}
// 10F0: using guessed type __int64 register_tm_clones();

//----- (0000000000001130) ----------------------------------------------------
FILE **_do_global_dtors_aux()
{
  FILE **result; // rax

  if ( !completed_0 )
  {
    if ( &__cxa_finalize )
      _cxa_finalize(_dso_handle);
    result = deregister_tm_clones();
    completed_0 = 1;
  }
  return result;
}
// 4080: using guessed type char completed_0;

//----- (0000000000001175) ----------------------------------------------------
int __fastcall main(int argc, const char **argv, const char **envp)
{
  char v4; // [rsp+7h] [rbp-9h] BYREF
  int v5; // [rsp+8h] [rbp-8h]
  bool v6; // [rsp+Fh] [rbp-1h]

  v6 = 1;
  v5 = 0;
  while ( v6 )
  {
    fflush(_bss_start);
    printf("\nIntroduce la letra correcta:\t");
    __isoc99_scanf("%c", &v4);
    getchar();
    if ( v5 > 5 )
    {
      if ( v5 > 9 )
      {
        if ( v5 > 14 )
        {
          if ( v5 > 19 )
            v6 = comprobacion(v4, f[v5 - 20], 10);
          else
            v6 = comprobacion(v4, d[v5 - 15], 2);
        }
        else
        {
          v6 = comprobacion(v4, c[v5 - 10], 8);
        }
      }
      else
      {
        v6 = comprobacion(v4, b[v5 - 6], 17);
      }
    }
    else
    {
      v6 = comprobacion(v4, a[v5], 5);
    }
    if ( !v6 )
    {
      printf("Incorrecta");
      exit(1);
    }
    printf("\n%c\n", (unsigned int)v4);
    if ( v5 == 25 )
    {
      printf("Ya tienes la flag!!");
      exit(1);
    }
    ++v5;
  }
  return 0;
}
// 1060: using guessed type __int64 __isoc99_scanf(const char *, ...);
// 4050: using guessed type char *a;
// 4058: using guessed type char *b;
// 4060: using guessed type char *c;
// 4068: using guessed type char *d;
// 4070: using guessed type char *f;

//----- (0000000000001352) ----------------------------------------------------
_BOOL8 __fastcall comprobacion(char a1, char a2, int a3)
{
  return a1 == (a3 ^ a2);
}

//----- (0000000000001390) ----------------------------------------------------
void __fastcall _libc_csu_init(unsigned int a1, __int64 a2, __int64 a3)
{
  signed __int64 v4; // rbp
  __int64 i; // rbx

  init_proc();
  v4 = &_do_global_dtors_aux_fini_array_entry - &_frame_dummy_init_array_entry;
  if ( v4 )
  {
    for ( i = 0LL; i != v4; ++i )
      ((void (__fastcall *)(_QWORD, __int64, __int64))*(&_frame_dummy_init_array_entry + i))(a1, a2, a3);
  }
}
// 1170: using guessed type __int64 __fastcall frame_dummy(_QWORD, _QWORD, _QWORD);
// 3DE8: using guessed type __int64 (__fastcall *_frame_dummy_init_array_entry)();
// 3DF0: using guessed type __int64 (__fastcall *_do_global_dtors_aux_fini_array_entry)();

//----- (00000000000013F4) ----------------------------------------------------
void term_proc()
{
  ;
}

Extracción de la Flag

Si nos fijamos en las líneas 41 a la 45 vemos las siguientes cadenas:

a = «MdfnJk»
b = «jYx}»
c = «gWmfk»
d = «mlvpc»
f = «neU++w»

Usaremos las cadenas y los valores XOR especificados para cada rango de v5 en el main (líneas 123 a 182) para determinar los caracteres correctos.

Para v5 de 0 a 5: v6 = comprobacion(v4, a[v5], 5);
Significa que: v4 debe ser igual a a[v5] ^ 5

Para v5 de 6 a 9: v6 = comprobacion(v4, b[v5 – 6], 17);
Significa que: v4 debe ser igual a b[v5 – 6] ^ 17

Para v5 de 10 a 14: v6 = comprobacion(v4, c[v5 – 10], 8);
Significa que: v4 debe ser igual a c[v5 – 10] ^ 8

Para v5 de 15 a 19: v6 = comprobacion(v4, d[v5 – 15], 2);
Significa que: v4 debe ser igual a d[v5 – 15] ^ 2

Para v5 de 20 a 25: v6 = comprobacion(v4, f[v5 – 20], 10);
Significa que: v4 debe ser igual a f[v5 – 20] ^ 10

Cálculo de los caracteres correctos:
Para v5 de 0 a 5:
a[0] = ‘M’, M ^ 5 = 0x4D ^ 0x05 = 0x48 -> ‘H’
a[1] = ‘d’, d ^ 5 = 0x64 ^ 0x05 = 0x61 -> ‘a’
a[2] = ‘f’, f ^ 5 = 0x66 ^ 0x05 = 0x63 -> ‘c’
a[3] = ‘n’, n ^ 5 = 0x6E ^ 0x05 = 0x6B -> ‘k’
a[4] = ‘J’, J ^ 5 = 0x4A ^ 0x05 = 0x4F -> ‘O’
a[5] = ‘k’, k ^ 5 = 0x6B ^ 0x05 = 0x6E -> ‘n’
Resulta en la cadena: HackOn

Para v5 de 6 a 9:
b[0] = ‘j’, j ^ 17 = 0x6A ^ 0x11 = 0x7B -> ‘{‘
b[1] = ‘Y’, Y ^ 17 = 0x59 ^ 0x11 = 0x48 -> ‘H’
b[2] = ‘x’, x ^ 17 = 0x78 ^ 0x11 = 0x69 -> ‘i’
b[3] = ‘}’, } ^ 17 = 0x7D ^ 0x11 = 0x6C -> ‘l’
Resulta en la cadena: {Hil

Para v5 de 10 a 14:
c[0] = ‘g’, g ^ 8 = 0x67 ^ 0x08 = 0x6F -> ‘o’
c[1] = ‘W’, W ^ 8 = 0x57 ^ 0x08 = 0x5F -> ‘_’
c[2] = ‘m’, m ^ 8 = 0x6D ^ 0x08 = 0x65 -> ‘e’
c[3] = ‘f’, f ^ 8 = 0x66 ^ 0x08 = 0x6E -> ‘n’
c[4] = ‘k’, k ^ 8 = 0x6B ^ 0x08 = 0x63 -> ‘c’
Resulta en la cadena: o_enc

Para v5 de 15 a 19:
d[0] = ‘m’, m ^ 2 = 0x6D ^ 0x02 = 0x6F -> ‘o’
d[1] = ‘l’, l ^ 2 = 0x6C ^ 0x02 = 0x6E -> ‘n’
d[2] = ‘v’, v ^ 2 = 0x76 ^ 0x02 = 0x74 -> ‘t’
d[3] = ‘p’, p ^ 2 = 0x70 ^ 0x02 = 0x72 -> ‘r’
d[4] = ‘c’, c ^ 2 = 0x63 ^ 0x02 = 0x61 -> ‘a’
Resulta en la cadena: ontra

Para v5 de 20 a 25:
f[0] = ‘n’, n ^ 10 = 0x6E ^ 0x0A = 0x64 -> ‘d’
f[1] = ‘e’, e ^ 10 = 0x65 ^ 0x0A = 0x6F -> ‘o’
f[2] = ‘U’, U ^ 10 = 0x55 ^ 0x0A = 0x5F -> ‘_
f[3] = ‘+’, + ^ 10 = 0x2B ^ 0x0A = 0x21 -> ‘!’
f[4] = ‘+’, + ^ 10 = 0x2B ^ 0x0A = 0x21 -> ‘!’
f[5] = ‘w’, w ^ 10 = 0x77 ^ 0x0A = 0x7D -> ‘}’
Resulta en la cadena: do_!!}

Uniendo todas las partes, obtenemos la flag completa: HackOn{Hilo_enc_ontrado_!!}

File carving is the process of reassembling computer files from fragments in the absence of filesystem metadata. Wikipedia.

«File carving», literalmente tallado de archivos aunque lo traduciremos como extracción, es el proceso de re-ensamblado de archivos extraídos de un conjunto de mayor tamaño.

Índice

  1. Image files / Archivos de imagen
  2. Microsoft Office >2007
  3. Open Office
  4. Autocad
  5. Others / Otros
  6. Links / Enlaces

List of headers and tails / Lista de cabeceras y pies

Header = Cabecera

Footer or tail = Pie

Image files / Archivos de imagen

  • JPEG
    • Header: FFD8
    • Footer: FFD9
  • GIF87a
    • Header: 47 49 46 38 37 61
    • Footer: 00 3B
  • GIF89a
    • Header: 47 49 46 38 39 61
    • Footer: 00 3B
  • BMP
    • Header: 42 4D
    • Footer: Don’t have footer, but size is in bytes 2,3,4,5 in little-endian order (low byte first).
      • Example: 00 00 C0 38 == 49208 bytes

bmpsize

  • PNG
    • Header: 89 50 4E 47 0D 0A 1A 0A
    • Footer: 49 45 4E 44 AE 42 60 82

Microsoft Office >2007

All this documents have the same header and footer, because of this, we need search the middle bytes. This type uses a ZIP file package.

Los documentos de Microsoft Office >2007 tienen la misma cabecera y pie, por lo que necesitamos bytes intermedios para distinguirlos. Usan encapsulado ZIP.

  • DOCX
    • Header: 50 4B 03 04 14 00 06 00
      • Middle: 77 6F 72 64 (word)
    • Footer: 50 4B 05 06 (PK..) followed by 18 additional bytes at the end of the file.
  • XLSX
    • Header: 50 4B 03 04 14 00 06 00
      • Middle: 77 6F 72 6B 73 68 65 65 74 73 (worksheets)
    • Footer: 50 4B 05 06 (PK..) followed by 18 additional bytes at the end of the file.
  • PPTX
    • Header: 50 4B 03 04 14 00 06 00
      • Middle: 70 72 65 73 65 6E 74 61 74 69 6F 6E (presentation)
    • Footer: 50 4B 05 06 (PK..) followed by 18 additional bytes at the end of the file.
  • MDB / ACCDB
    • Header: 00 01 00 00 53 74 61 6E 64 61 72 64 20 4A 65 74 20 44 42 (….Standard Jet DB)
    • Footer: Don’t have footer.

Open Office

All this documents have the same header and footer, because of this, we need some bytes to differentiate them. In this case we can do this jumping 73 bytes from header. This type uses a ZIP file package.

Los documentos de OpenOffice tienen la misma cabecera y pie, por lo que necesitamos bytes intermedios para distinguirlos. Usan encapsulado ZIP.

  • ODS
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 73 70 72 65 (spre)
    • Footer: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.
  • ODT
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 74 65 78 64 (text)
    • Footer: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.
  • ODB
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 62 61 73 65 (base)
    • Footer: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.
  • ODG
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 67 72 61 70 (grap)
    • Footer: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.
  • ODF
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 66 6F 72 6D (form)
    • Tail: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.
  • ODP
    • Header: 50 4B 03 04 14 (PK..) jump +73 (0x49) bytes and 70 72 65 73 (pres)
    • Footer: 6D 61 6E 69 66 65 73 74 2E 78 6D 6C 50 4B 05 06 (manifest.xmlPK) followed by 18 additional bytes.

Autocad

  • DWG (R11/R12 versions)
    • Header: 41 43 31 30 30 39
    • Footer: CD 06 B2 F5 1F E6
  • DWG (R14 version)
    • Header: 41 43 31 30 31 34
    • Footer: 62 A8 35 C0 62 BB EF D4
  • DWG (2000 version)
    • Header: 41 43 31 30 31 34
    • Footer: DB BF F6 ED C3 55 FE
  • DWG (>2007 versions)
    • Header: 41 43 31 30 XX XX
    • Footer: Don’t have

Note: >2007 versions have two patterns and the key is the position 0x80. If in this position we get the bytes «68 40 F8 F7 92», we need to search again for this bytes and displace 107 bytes to find the end of the file. If in the position 0x80 we get another different bytes, we need to search again this bytes and displace 1024 bytes to find the end of the file.

Nota: Las versiones >2007 siguen dos patrones y la clave está en la posición 0x80. Si en la posicion 0x80 obtenemos los bytes «68 40 F8 F7 92», los buscamos una segunda vez y ha 107 bytes encontramos el final del archivo. Si en la posición 0x80 obtenemos otros bytes diferentes a los del primer caso, los volvemos a buscar y a 1024 bytes hallaremos el final del archivo.

Others / Otros

  • PDF
    • Header: 25 50 44 46 (%PDF)
    • Footers:
      • 0A 25 25 45 4F 46 (.%%EOF) or
      • 0A 25 25 45 4F 46 0A (.%%EOF.) or
      • 0D 0A 25 25 45 4F 46 0D 0A (..%%EOF..) or
      • 0D 25 25 45 4F 46 0D (.%%EOF.)
  • ZIP
    • Header: 50 4B 03 04
    • Footer: 50 4B 05 06 (PK..) followed by 18 additional bytes at the end of the file.
  • RAR (< 4.x version)
    • Header: 52 61 72 21 1A 07 00
    • Tail: C4 3D 7B 00 40 07 00
  • 7ZIP
    • Header: 37 7A BC AF 27 1C 00 03  (7z¼¯’…)
    • Footer: 01 15 06 01 00 20 followed by 5 additional bytes at the end of the file.
  • RTF
    • Header: 7B 5C 72 74 66 31
    • Footer: 5C 70 61 72 20 7D

Links / Enlaces

Introducción

Esta vez vamos a analizar los CrackMes de un antiguo colaborador de Karpoff Spanish Tutor, CrkViZ. En estas cinco soluciones vamos a pelearnos con Visual Basic 5/6 nativo y Pcode, con el registro de Windows y tendremos que parchear algúna rutina antidebug. Los CrackMes son del año 2000 y aunque algunos estaban ya solucionados, los analizaremos igualmente para ver la diferencia que existe con los análisis realizados en aquellos años, sí, estamos hablando del Softice.

Herramientas disponibles

Cuando hablamos de Visual Basic 5/6, podemos destacar 3 herramientas que nos facilitan mucho la vida, VB Decompiler, VB Reformer y ExDec. Las dos primeras se defienden bien tanto con código nativo como pcode y ExDec solamente nos sirve para pcode. Aún así, si todo lo demás falla, Ollydbg nos sacará de apuros.

CrkViz-1

03-03-2015 13-16-27

03-03-2015 13-16-17

Este primer crackme está compilado en Pcode y hoy día, con las herramientas de que disponemos no supone ninguna dificultad. Tan solo debemos abrirlo con VB Decompiler y ya nos encontramos con el serial válido.

03-03-2015 13-14-18

Los opcodes obtenidos con ExDec se ven de la siguiente manera.

......
402F14: 04 FLdRfVar                local_008C
402F17: 21 FLdPrThis              
402F18: 0f VCallAd                 7b3fc340
402F1B: 19 FStAdFunc               local_0088
402F1E: 08 FLdPr                   local_0088
402F21: 0d VCallHresult            7b3fbe88
402F26: 6c ILdRf                   local_008C
402F29: 1b LitStr:                 57230198        <--------------
402F2C: Lead0/30 EqStr            
402F2E: 2f FFree1Str               local_008C
402F31: 1a FFree1Ad                local_0088
402F34: 1c BranchF:                403012
402F37: 21 FLdPrThis              
402F38: 0d VCallHresult            7b3fc2b0
402F3D: 3a LitVarStr:              ( local_00AC )  Gracias por Registrar!!      
402F42: Lead2/00 FStVarCopy       
402F46: 27 LitVar_Missing         
402F49: 27 LitVar_Missing         
402F4C: 3a LitVarStr:              ( local_00AC ) CrkViz
402F51: 4e FStVarCopyObj           local_00BC
402F54: 04 FLdRfVar                local_00BC
402F57: f5 LitI4:                  0x40  64  (...@)
402F5C: 04 FLdRfVar                local_009C
402F5F: 0a ImpAdCallFPR4:          _rtcMsgBox
402F64: 36 FFreeVar
402F6D: 27 LitVar_Missing         
402F70: 25 PopAdLdVar             
402F71: 27 LitVar_Missing
......

CrkViz-2

03-03-2015 13-18-32

Este segundo crackme también está compilado en pcode. La rutina del serial es muy sencilla pero al introducir un número aleatorio nos obliga a parchear. Cargamos el crackme en VB Decompiler y nos muestra esto:

03-03-2015 13-19-48

Básicamente vemos que genera un número aleatorio entre 1 y 999999999 y luego le suma 1. La forma de afrontar esto es parcheando. Nos fijamos en el offset aproximado (4037F2) y abrimos el crackme en un editor hexadecimal. La forma de convertir el offset que nos muestra VB Decompiler a lo que nos muestra un editor hexadecimal es la siguiente.

VBdec_offset - Image Base - VirtualOffset + RawOffset = Offset_Editor.H

4037F2 - 400000 - 1000 + 400 = 2BF2

03-03-2015 14-00-27

Una vez localizados los bytes, los cambiamos por ceros y guardamos.

01-03-2015 04-50-05 01-03-2015 04-52-10

Una vez parcheado, el serial correcto es 1.

CrkViz-3

11-03-2015 21-20-07

En esta tercera entrega, CrkViz aumentó la dificultad. El crackme está compilado en código nativo y nos enfrentamos a un serial asociado a un nombre y a una rutina antidebug que en realidad es una Nag, ya que se muestra siempre.

Afrontar la nag es muy sencillo, basta con localizarla y parchear la llamada.

CPU Disasm
Address   Hex dump          Command                                            Comments
004058E2    8D4D DC         LEA ECX,[EBP-24]
004058E5    C785 BCFDFFFF B MOV DWORD PTR SS:[EBP-244],CrkMeViz-3.004033B8     ; UNICODE "  Debugger detectado!!!   "
004058EF    C785 B4FDFFFF 0 MOV DWORD PTR SS:[EBP-24C],8
004058F9    FFD7            CALL EDI
004058FB    B9 04000280     MOV ECX,80020004
00405900    B8 0A000000     MOV EAX,0A
00405905    898D FCFDFFFF   MOV DWORD PTR SS:[EBP-204],ECX
0040590B    898D 0CFEFFFF   MOV DWORD PTR SS:[EBP-1F4],ECX
00405911    8D95 B4FDFFFF   LEA EDX,[EBP-24C]
00405917    8D8D 14FEFFFF   LEA ECX,[EBP-1EC]
0040591D    8985 F4FDFFFF   MOV DWORD PTR SS:[EBP-20C],EAX
00405923    8985 04FEFFFF   MOV DWORD PTR SS:[EBP-1FC],EAX
00405929    C785 BCFDFFFF 8 MOV DWORD PTR SS:[EBP-244],CrkMeViz-3.00403188     ; UNICODE "Error"
00405933    C785 B4FDFFFF 0 MOV DWORD PTR SS:[EBP-24C],8
0040593D    FF15 C8914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarDup>]
00405943    8D85 F4FDFFFF   LEA EAX,[EBP-20C]
00405949    8D8D 04FEFFFF   LEA ECX,[EBP-1FC]
0040594F    50              PUSH EAX
00405950    8D95 14FEFFFF   LEA EDX,[EBP-1EC]
00405956    51              PUSH ECX
00405957    52              PUSH EDX
00405958    8D45 DC         LEA EAX,[EBP-24]
0040595B    6A 10           PUSH 10
0040595D    50              PUSH EAX
0040595E    FF15 50914000   CALL DWORD PTR DS:[<&MSVBVM50.#595>]               ; rtcMsgBox - NOPear para evitar la NAG
00405964    8D8D F4FDFFFF   LEA ECX,[EBP-20C]

Antes de llegar al keygen vemos que realiza unas llamadas al registro de Windows, ponemos un breakpoint «bp RegOpenKeyW» y ejecutamos.

CPU Disasm
Address   Hex dump            Command                                  Comments
00405677  |.  8B8D B8FDFFFF   MOV ECX,DWORD PTR SS:[EBP-248]
0040567D  |.  B8 54334000     MOV EAX,CrkMeViz-3.00403354              ; UNICODE "<Unregister>"
00405682  |.  68 B4304000     PUSH CrkMeViz-3.004030B4                 ; UNICODE "Serial number"
00405687  |.  894A 04         MOV DWORD PTR DS:[EDX+4],ECX
0040568A  |.  8985 BCFDFFFF   MOV DWORD PTR SS:[EBP-244],EAX
00405690  |.  68 84304000     PUSH CrkMeViz-3.00403084                 ; UNICODE "Register"
00405695  |.  68 58304000     PUSH CrkMeViz-3.00403058                 ; UNICODE "CrkMeViz3"
0040569A  |.  8942 08         MOV DWORD PTR DS:[EDX+8],EAX
0040569D  |.  8B85 C0FDFFFF   MOV EAX,DWORD PTR SS:[EBP-240]
004056A3  |.  8942 0C         MOV DWORD PTR DS:[EDX+0C],EAX
004056A6  |.  FF15 C0914000   CALL DWORD PTR DS:[<&MSVBVM50.#689>] 	; rtcGetSetting - Lee el numero de serie del registro
........
0040574F  |.  68 9C304000     PUSH CrkMeViz-3.0040309C                  ; UNICODE "User Name"
00405754  |.  68 84304000     PUSH CrkMeViz-3.00403084                  ; UNICODE "Register"
00405759  |.  68 58304000     PUSH CrkMeViz-3.00403058                  ; UNICODE "CrkMeViz3"
0040575E  |.  8948 08         MOV DWORD PTR DS:[EAX+8],ECX
00405761  |.  8B8D C0FDFFFF   MOV ECX,DWORD PTR SS:[EBP-240]
00405767  |.  8948 0C         MOV DWORD PTR DS:[EAX+0C],ECX
0040576A  |.  FF15 C0914000   CALL DWORD PTR DS:[<&MSVBVM50.#689>]	; rtcGetSetting - Lee el Usuario del registro

 Reconstruyendo la llamada al registro vemos que lee de esta ruta: HKEY_CURRENT_USER\Software\VB and VBA Program Settings\CrkMeViz3\Register el contenido de User Name y del Serial number.

Quizá uno de los fallos de éste crackme, es que no comprueba la autenticidad de estos parámetros y si los modificas parece que estás registrado. Un ejemplo:

11-03-2015 22-23-28

La rutina de comprobación del serial no es para nada complicada pero recordemos que estamos tratando con VB y éste delega el trabajo duro en otras librerias de modo que tenemos que «meternos» a tracear las llamadas para ver los valores que multiplica y divide.

CPU Disasm
Address     Hex dump          Command                                            Comments
00405A86      FF15 3C914000   CALL DWORD PTR DS:[<&MSVBVM50.#518>]    ;MSVBVM50.rtcLowerCaseVar
00405A8C      8D95 14FEFFFF   LEA EDX,[EBP-1EC]
00405A92      8D8D ACFEFFFF   LEA ECX,[EBP-154]
00405A98      FFD6            CALL ESI
00405A9A      8D95 ACFEFFFF   LEA EDX,[EBP-154]
00405AA0      8D8D 4CFEFFFF   LEA ECX,[EBP-1B4]
00405AA6      FFD7            CALL EDI
00405AA8      8D95 4CFEFFFF   LEA EDX,[EBP-1B4]
00405AAE      8D8D 7CFFFFFF   LEA ECX,[EBP-84]
00405AB4      FFD7            CALL EDI
00405AB6      8D85 14FEFFFF   LEA EAX,[EBP-1EC]
00405ABC      8D8D 7CFFFFFF   LEA ECX,[EBP-84]
00405AC2      50              PUSH EAX
00405AC3      6A 01           PUSH 1
00405AC5      8D95 04FEFFFF   LEA EDX,[EBP-1FC]
00405ACB      51              PUSH ECX
00405ACC      52              PUSH EDX
00405ACD      C785 1CFEFFFF 0 MOV DWORD PTR SS:[EBP-1E4],1
00405AD7      C785 14FEFFFF 0 MOV DWORD PTR SS:[EBP-1EC],2
00405AE1      FF15 68914000   CALL DWORD PTR DS:[<&MSVBVM50.#632>]   ;MSVBVM50.rtcMidCharVar (Esto lo hace 6 veces, lo omito para abreviar.)
........
00405CE1      FF15 34914000   CALL DWORD PTR DS:[<&MSVBVM50.#516>]   ;MSVBVM50.rtcAnsiValueBstr (Lo mismo, otras 6)
........
00405E7C    C785 BCFDFFFF 2 MOV DWORD PTR SS:[EBP-244],52E
00405E86    C785 B4FDFFFF 0 MOV DWORD PTR SS:[EBP-24C],2
00405E90    50              PUSH EAX
00405E91    FF15 84914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
		|
		->MSVBVM50.__vbaVarMul
			........
			741C19D3      0FB745 FE       MOVZX EAX,WORD PTR SS:[EBP-2]       ;Valor1
			741C19D7      0FB74D F2       MOVZX ECX,WORD PTR SS:[EBP-0E]      ;Valor2
			741C19DB      6BC0 12         IMUL EAX,EAX,12                     ;Valor1*Valor2
			........
00405E97    8D8D 04FEFFFF   LEA ECX,[EBP-1FC]
00405E9D    50              PUSH EAX
00405E9E    51              PUSH ECX
00405E9F    FF15 84914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00405EA5    8D95 F4FDFFFF   LEA EDX,[EBP-20C]
00405EAB    50              PUSH EAX
00405EAC    52              PUSH EDX
00405EAD    FF15 84914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00405EB3    50              PUSH EAX
00405EB4    8D85 E4FDFFFF   LEA EAX,[EBP-21C]
00405EBA    50              PUSH EAX
00405EBB    FF15 84914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00405EC1    8D8D D4FDFFFF   LEA ECX,[EBP-22C]
00405EC7    50              PUSH EAX
00405EC8    51              PUSH ECX
00405EC9    FF15 84914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00405ECF    50              PUSH EAX
00405ED0    8D95 B4FDFFFF   LEA EDX,[EBP-24C]
00405ED6    8D85 C4FDFFFF   LEA EAX,[EBP-23C]
00405EDC    52              PUSH EDX
00405EDD    50              PUSH EAX
00405EDE    FF15 94914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarDiv>]
		|
		->MSVBVM50.__vbaVarDiv
			........
			741C8094      DD43 08         FLD QWORD PTR DS:[EBX+8]      ;Recupera el resultado de las multiplicaciones anteriores
			741C8097      0FBF47 08       MOVSX EAX,WORD PTR DS:[EDI+8] ;EAX = 1326 (52E)
			741C809B      8945 F8         MOV DWORD PTR SS:[EBP-8],EAX
			741C809E      DA75 F8         FIDIV DWORD PTR SS:[EBP-8]    ;Divide los dos resultados
			741C80A1      DD5E 08         FSTP QWORD PTR DS:[ESI+8]
			........
00405F44      FF15 24914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaLenBstr>]          ;Len(nombre)
........
00405F85      FF15 94914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarDiv>]           ;Resultado anterior / Len(nombre)
........

En resumen:

  • Pasa nuestro nombre a minúsculas.
  • Obtiene el valor ascii de los 6 primeros dígitos del nombre.
  • Los multiplica entre sí y divide el resultado acumulado entre 1326 (52E).
  • Divide el resultado anterior entre el tamaño del nombre.

Ejemplo para deurus

64*65*75*72*75*73 = 1A605D70EB8
1A605D70EB8 / 52E = 5179FBF4
5179FBF4 / 6 = D9454A9

11-03-2015 21-20-17

Al estar correctamente registrados desaparece el botón de registrar.

CrkViz-4

12-03-2015 23-09-07

El cuarto crackme es prácticamente igual que el tercero salvo que en vez de nag ahora contamos con limitación de ejecuciones. Del mismo modo utiliza el registro de Windows para guardar los datos de registro y las ejecuciones que llevamos.

Ponemos un breakpoint «bp RegOpenKeyW» y llegamos a la conclusión de que la ruta es HKEY_CURRENT_USER\Software\VB and VBA Program Settings\ODBC\Register y los valores se guardan en Counter, User Name y Serial number respectivamente. Este crackme hereda el fallo del anterior y si alteramos los valores el crackme nos muestra como usuarios autorizados, aunque sabemos que no estamos registrados ya que seguimos limitados por ejecuciones. Ni que decir tiene que lo mismo que modificamos el nombre y número de serie, podemos modificar el contador a nuestro favor. Crear un archivo «Reiniciar_contador.reg» con el siguiente contenido sería suficiente.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\ODBC]

[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\ODBC\Register]
"Counter"="0"
"User Name"="deurus"
"Serial number"="12345"

El keygen es prácticamente igual que en el crackme anterior, solo cambia el divisor.

CPU Disasm
Address   Hex dump          Command                                                   Comments
........
00404BD2    C785 BCFDFFFF C MOV DWORD PTR SS:[EBP-244],6C1
00404BDC    C785 B4FDFFFF 0 MOV DWORD PTR SS:[EBP-24C],2
00404BE6    FF15 A0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
   |
    ->MSVBVM50.__vbaVarMul
	741C19F9    0FBF4F 08       MOVSX ECX,WORD PTR DS:[EDI+8]      ;Valor1
	741C19FD    0FBF43 08       MOVSX EAX,WORD PTR DS:[EBX+8]      ;Valor2
	741C1A01    0FAFC8          IMUL ECX,EAX                       ;Valor1*Valor2
........
00404BEC    8D8D 04FEFFFF   LEA ECX,[EBP-1FC]
00404BF2    50              PUSH EAX
00404BF3    51              PUSH ECX
00404BF4    FF15 A0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00404BFA    8D95 F4FDFFFF   LEA EDX,[EBP-20C]
00404C00    50              PUSH EAX
00404C01    52              PUSH EDX
00404C02    FF15 A0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00404C08    50              PUSH EAX
00404C09    8D85 E4FDFFFF   LEA EAX,[EBP-21C]
00404C0F    50              PUSH EAX
00404C10    FF15 A0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00404C16    8D8D D4FDFFFF   LEA ECX,[EBP-22C]
00404C1C    50              PUSH EAX
00404C1D    51              PUSH ECX
00404C1E    FF15 A0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarMul>]
00404C24    50              PUSH EAX
00404C25    8D95 B4FDFFFF   LEA EDX,[EBP-24C]
00404C2B    8D85 C4FDFFFF   LEA EAX,[EBP-23C]
00404C31    52              PUSH EDX
00404C32    50              PUSH EAX
00404C33    FF15 B0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarDiv>]
   |
    ->MSVBVM50.__vbaVarDiv
	741C8094    DD43 08         FLD QWORD PTR DS:[EBX+8]              ; Recupera el resultado de las multiplicaciones anteriores
	741C8097    0FBF47 08       MOVSX EAX,WORD PTR DS:[EDI+8]         ; EAX = 1729 (6C1)
	741C809B    8945 F8         MOV DWORD PTR SS:[EBP-8],EAX
	741C809E    DA75 F8         FIDIV DWORD PTR SS:[EBP-8]

00404C39    8BD0            MOV EDX,EAX
........
00404CA0    FF15 3C914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaLenBstr>]  ;Len(nombre)
........
00404CF1    FF15 B0914000   CALL DWORD PTR DS:[<&MSVBVM50.__vbaVarDiv>]   ;Resultado anterior / Len(nombre)

En resumen:

  • Pasa nuestro nombre a minúsculas.
  • Obtiene el valor ascii de los 6 primeros dígitos del nombre.
  • Los multiplica entre sí y divide el resultado acumulado entre 1729 (6C1).
  • Divide el resultado anterior entre el tamaño del nombre.

Ejemplo para deurus

64*65*75*72*75*73 = 1A605D70EB8
1A605D70EB8 / 6C1 = 3E7C594A
3E7C594A / 6 = A6A0EE2

CrkViz-5

11-03-2015 23-23-16

Este último crackme está compilado en código nativo y simplemente se trata de una comparación lineal. La única diferencia reside en que no hay botón de registro, la comprobación la gestiona un evento «On Change«, de modo que está comprobando el tamaño del serial que introducimos y cuando éste tiene 8 dígitos llegamos aquí.

........
0040A64F         .  C745 9C CDD4DD02    MOV DWORD PTR SS:[EBP-64],2DDD4CD      ;2DDD4CD = 48092365
0040A656         .  C745 94 03800000    MOV DWORD PTR SS:[EBP-6C],8003
0040A65D         .  FF15 08C14000       CALL DWORD PTR DS:[<&MSVBVM50.__vbaVa> ;MSVBVM50.__vbaVarTstEq
0040A663         .  66:85C0             TEST AX,AX
0040A666         .  0F84 BA000000       JE CrkMeViZ.0040A726                   ;Si salta BAD  BOY
........

Luego el serial correcto es 48092365.

Notas finales

¿Ha sido indoloro no?, claro que sí, Visual Basic es un coñazo de tracear pero hay que reconocer que con el tiempo las herramientas han mejorado mucho y nuestra vida es mucho más sencilla. Bueno, pués esto ha sido todo, como siempre os dejo todo el material utilizado y un Keygen.

12-03-2015 23-06-33

Enlaces