UP | HOME

Keyg3nM1#1

crackmes.one (Shad3)


This file is very easy. It's not striped, we can see a function named check_key in Ghidra. I'll look inside deeper.

The function is so easy that I can put it here (with some modifications on the names and whitout some comments of Ghidra).

undefined8 check_key(char *param_1)

{
  size_t string_len;
  int i;
  int total;

  total = 0;
  string_len = strlen(param_1);
  if (7 < string_len) {
    if (string_len < 0xb) {
      i = 0;
      while( true ) {
        if (string_len <= (ulong)(long)i) break;
        total = total + param_1[i];
        i = i + 1;
      }

      if (total < 1000) {
        printf("Nope <3");
        exit(0);
      }
      return 1;
    }
  }
  printf("Nope <3");
  exit(0);
}

The function is obvious. The key size must be between 8 and 10 and the sum of the ASCII value of its caracters must be at least 1000. Knowing that, it's very quick to write a keygen.

I don't think that my algorithm is the best, I think it's possible to writte a better one. The knapsack problem must be a way to solve it by starting the generation at space caracter in the ASCII table.

import random

key = ""
char = ''
total = 0

while total < 1000 and len(key) < 0xb:
    char = chr(random.randrange(84, 127))
    key += char
    total += ord(char)

print(key)

FunFact : my first guess was pouetpouet, which is a valid key.


Ce fichier est très simple. Il n'est pas striped, dès la décompilation dans Ghidra, on voit une fonction check_key sur laquelle je vais me pencher.

La fonction est si simple que je peux me permettre de la mettre ici (avec des noms légèrement modifiés et sans certains commentaires de Ghidra).

undefined8 check_key(char *param_1)

{
  size_t string_len;
  int i;
  int total;

  total = 0;
  string_len = strlen(param_1);
  if (7 < string_len) {
    if (string_len < 0xb) {
      i = 0;
      while( true ) {
        if (string_len <= (ulong)(long)i) break;
        total = total + param_1[i];
        i = i + 1;
      }

      if (total < 1000) {
        printf("Nope <3");
        exit(0);
      }
      return 1;
    }
  }
  printf("Nope <3");
  exit(0);
}

La fonction est claire comme de l'eau de roche. La taille de la clé doit être comprise entre 8 et 10 et la somme des valeurs ASCII de ses caractères doit faire au minimum 1000. En sachant ça, l'écriture d'un générateur de clés se fait très rapidement.

Mon approche n'est pas la meilleure, je pense qu'il est possible de faire un meilleur algo en regardant du côté du problème du sac à dos pour commencer au caractère espace dans la table ASCII.

import random

key = ""
char = ''
total = 0

while total < 1000 and len(key) < 0xb:
    char = chr(random.randrange(84, 127))
    key += char
    total += ord(char)

print(key)

FunFact : mon premier guess de clé a été pouetpouet, qui est une clé valide.

Author: rick

Email: rick@gnous.eu

Created: 2024-05-16 jeu. 20:32

Validate