Crunch, générateur de dictionnaire.

Guypaul1 Messages postés 1 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 23 mai 2009 - 23 mai 2009 à 12:15
 Lastwissh - 12 déc. 2012 à 10:57
Bonjour à tous!

j'ai un probléme que j'aimerai vous soumettre.

j'ai récupéré la source de Crunch qui est un petit programme, qui génére une suite de chaîne de caractéres, avec la possibilité de choisir au départ le nombre mini, maxi, nom de fichier txt et mot ou chiffres de départ. Le probléme c'est qu'il va générer à l'infini! Ce qui créait un fichier de 100 Go et plus, dans le cas d'une trentaine de codes hexa !

La souce est libre. Donc j'ai eu l'idée que si on peut intégrer une valeur de départ (StartBlock) on devrait pouvoir intégrer une valeur de fin ? Une fois la valeur de fin trouvée, il y a sortie du fichier.

Mais voilà j'ai les idées, mais pas la pratique! J'ai bien essayé en créant un (Endblock) avec strcmp,
mais si la compil était correcte, le résultat était nul..

C'est pour cette raison que je demande votre aide.

Merci.

Guypaul1

La souce : crunch.cpp

/*
 *  character-set based brute-forcing algorithm
 *
 *  usage: ./crunch <from-len> <to-len> [charset] [-t [FIXED]@@@@] [-s startblock]
 *
 *  e.g: ./crunch 3 7 abcdef
 *
 *  This example will compute all passwords between 3 and 7 chars
 *  using 'abcdef' as the character set and dump it to stdout.
 *
 *  Options:
 *
 *  -t [FIXED]@@@@  :  allows you to specify a pattern, eg: @@god@@@@
 *                     where the only the @'s will change
 *
 *  -s              :  allows you to specify the starting string, eg: 03god22fs
 *
 *
 *  This code can be easily adapted for use in brute-force attacks
 *  against network services or cryptography.
 *
 *  Compiles on: linux, c++, freebsd
 *
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define TRUE 1
#define FALSE 0


char def_charset[] = "abcdefghijklmnopqrstuvwxyz";


unsigned int inc[128];


int finished(char *block, char *charset, char *templ)
{
    unsigned int i;


    if (templ[0]==0)
    {
        for (i=0;i<strlen(block);i++)
            if (inc[i] < strlen(charset)-1) return FALSE;
    }
    else
    {
        for (i=0;i<strlen(block);i++)
            if (templ[i]=='@' && (inc[i] < strlen(charset)-1)) return FALSE;
    }


    return TRUE;
}


void increment(char *block, int len, char *charset, char *templ)
{
    int i;


    for (i=strlen(block)-1;i>-1;i--)
    {
        if (templ[0]==0 || templ[i]=='@')
        {
            if (inc[i] < strlen(charset)-1)
            {
                inc[i]++;
                block[i] = charset[inc[i]];
                i=-1;
            }
            else
            {
                block[i] = charset[0];
                inc[i] = 0;
            }
        }
        else
        {
        }
    }
}


void chunk(int start, int end, char *charset, char *templ, char *startblock)
{
    int i,j,k,t;
    char block[128];


    if (end-start <0) return;


    if (templ[0]==0) t=0;
    else  t=1;


    for (i=start;i<=end;i++)
    {
        memset(block,0,sizeof(block));


        for (j=0;j <to-len> [charset] [-t [FIXED]@@@@] [-s startblock]\n",argv[0]);
        return 0;
    }


    memset(charset,0,sizeof(charset));
    memset(templ,0,sizeof(templ));
    memset(startblock,0,sizeof(startblock));


    /* remove duplicate characters from charset */
    if (argc>3)
    {
        for (i=0;i<strlen(argv[3]);i++)
        {
            flag = 0;
            for (j=0;j<strlen(charset);j++)
                if (argv[3][i] == charset[j]) flag = 1;


            if (flag==0) strncat(charset,&argv[3][i],1);
        }
    }
    else  strncpy(charset,def_charset,strlen(def_charset));


    min = atoi(argv[1]);
    max = atoi(argv[2]);


    for (i=1;imin)
            {
                printf("Warning: starting length increased to %d.\n",strlen(argv[i+1]));
                min = strlen(argv[i+1]);
            }
            if (strlen(argv[i+1]) <min)
            {
                printf("Warning: minimum length decreased to %d.\n",strlen(argv[i+1]));
                min = strlen(argv[i+1]);
            }


            strncpy(startblock,argv[i+1],strlen(argv[i+1]));


             if (strcmp(startblock, block) == 0)
               {
               printf("les chaines sont identiques %d. \n",block);
             }
         }
    }


    chunk(min,max,charset,templ,startblock);


    return 0;
}

 

1 réponse

Petit Up!

Actuellement je taff sur un générateur de WordList en C, pour définir le nombre de clefs à générer j'utilise une boucle.
tout d'abord je créer deux variables, par exemple : unsigned long nombreDeClefs 0, compteur 0;

puis j'utilise un scanf pour que l'utilisateur renseigne la variable nombreDeClefs

et dans ma boucle while je mets : while(compteur != nombreDeClefs) // TANT QUE compteur est différent de nombreDeClef on continue la boucle
{
//code
compteur++ //J'incrémente une variable nommé compteur à chaque génération de clef
//code
}


Voila le principe, j’espère que ça aideras quelqu'un :)
0
Rejoignez-nous