Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 17. október 2026

Rozdiely pre libplaton/utils/md5scan/md5scan.c medzi verziami 1.4 a 1.5

verzia 1.4, 2007/07/16 22:37:26 verzia 1.5, 2007/07/17 00:40:07
Riadok 4 
Riadok 4 
   
 #include <platon/hash/md5.h>  #include <platon/hash/md5.h>
 #include <platon/str/strplus.h>  #include <platon/str/strplus.h>
   #include <platon/str/strctype.h>
   
 /* Compilation agains libplaton library:  /* Compilation agains libplaton library:
    gcc -pedantic -L ../../platon/ -I ../../ -o md5scan md5scan.c -lplaton     gcc -pedantic -L ../../platon/ -I ../../ -o md5scan md5scan.c -lplaton
Riadok 12 
Riadok 13 
 #define BUFSIZE                 1000  #define BUFSIZE                 1000
 #define MAX_PASSWORDS    200  #define MAX_PASSWORDS    200
   
   #define compute_and_check(__buf) \
                           compute_md5(md5str, __buf); \
                           check_passwords(md5str, __buf);
   
   #define compute_md5(__md5, __buf) \
                           MD5Init(&context); \
                           MD5Update(&context, __buf, pw_len); \
                           MD5Final(__md5, &context);
   
   #define check_passwords(__md5, __plain) \
                           for (j = 0; j < pw_cnt; j++) { \
                                   if (! memcmp(passwords[j], __md5, 16)) { \
                                           printf("Found: MD5('%s') = '", __plain); \
                                           for (k  = 0; k < 16; k++) { \
                                                   printf("%02x", (unsigned char ) md5str[k]); \
                                           } \
                                           printf("', username: %s\n", usernames[j]); \
                                   } \
                           }
   
 int main(int argc, char **argv) /* {{{ */  int main(int argc, char **argv) /* {{{ */
 {  {
         MD5_CTX context;          MD5_CTX context;
         char *usernames[MAX_PASSWORDS][32];          char usernames[MAX_PASSWORDS][32];
         char *passwords[MAX_PASSWORDS][16];          char passwords[MAX_PASSWORDS][16];
         char *hash;          char buf[BUFSIZE], buf2[BUFSIZE];
         char buf[BUFSIZE];  
         char *ptr, md5str[16];          char *ptr, md5str[16];
   
         FILE *f;          FILE *f;
         int pw_len, buf_base;          int pw_len, buf_base;
         register int i, j, pw_cnt, line;          register int i, j, k, pw_cnt, line, feature;
         long int cnt;          long int cnt;
   
           int feature_have_some_uppercase;
   
         if (argc <= 2) {          if (argc <= 2) {
                 printf("Usage: %s <password_file> <word-list-file_1> ... <word-list-file_N>\n", argv[0]);                  printf("Usage: %s <password_file> <word-list-file_1> ... <word-list-file_N>\n", argv[0]);
                 return 1;                  return 1;
Riadok 77  int main(int argc, char **argv) /* {{{ *
Riadok 99  int main(int argc, char **argv) /* {{{ *
                         continue;                          continue;
                 }                  }
   
                 for (cnt = 0; fgets(buf, 20, f) != NULL; ) {                  for (cnt = 0; fgets(buf, BUFSIZE - 1, f) != NULL; ) {
                         for (pw_len = strlen(buf) - 1;                          pw_len = strlen(buf);
                                         pw_len >= 0 && isspace(buf[pw_len]); pw_len--) {                          if (pw_len >= BUFSIZE) {
                                 buf[pw_len] = '\0';                                  printf("WARNING: too long password on the input (%d)\n", pw_len);
                                   continue;
                         }                          }
                         pw_len++;                          str_trim(buf);
                           pw_len = strlen(buf);
                         if (! pw_len) {                          if (! pw_len) {
                                 continue;                                  continue;
                         }                          }
                         cnt++;                          cnt++;
   
                         MD5Init (&context);                          /* Features:
                         MD5Update (&context, buf, pw_len);                           * - plain
                         MD5Final (md5str, &context);                           * - reverse string
                            * - lowercase
                         for (j = 0; j < pw_cnt; j++) {                           * - lowercase capitalize first
                                 if (! memcmp(passwords[j], md5str, 16)) {                           * - capitalize first
                                         register int k;                           * - append 1 digit
                                         printf("Found: MD5('%s') = '", buf);                           * - append 1 digits
                                         for (k  = 0; k < 16; k++) {                           */
                                                 printf("%02x", (unsigned char ) md5str[k]);  
                                         }                          for (feature_have_some_uppercase = 0, j = 0; j < pw_len; j++) {
                                         printf("', username: %s\n", usernames[j]);                                  if (isupper(buf[j])) {
                                           feature_have_some_uppercase = 1;
                                           break;
                                   }
                           }
   
                           /* Feature: plain */
                           compute_and_check(buf);
   
                           if (islower(buf[0])) { /* Feature: ucfirst */
                                   k = buf[0];
                                   buf[0] = toupper(buf[0]);
                                   compute_and_check(buf);
                                   buf[0] = k;
                           }
   
                           if (feature_have_some_uppercase) { /* Feature: lowercase */
                                   strncpy(buf2, buf, BUFSIZE);
                                   strtolower(buf2);
                                   compute_and_check(buf2);
                                   if (islower(buf2[0])) { /* Feature: lowercase & ucfirst */
                                           buf2[0] = toupper(buf2[0]);
                                           compute_and_check(buf2);
                                   }
                           }
   
                           /* Feature: reverse */
                           strncpy(buf2, buf, BUFSIZE);
                           strrev(buf2);
                           compute_and_check(buf2);
   
                           if (islower(buf2[0])) { /* Feature: reverse & ucfirst */
                                   k = buf2[0];
                                   buf2[0] = toupper(buf2[0]);
                                   compute_and_check(buf2);
                                   buf2[0] = k;
                           }
   
                           if (feature_have_some_uppercase) { /* Feature: reverse & lowercase */
                                   strtolower(buf2);
                                   compute_and_check(buf2);
                                   if (islower(buf2[0])) { /* Feature: reverse & lowercase & ucfirst */
                                           buf2[0] = toupper(buf2[0]);
                                           compute_and_check(buf2);
                                 }                                  }
                         }                          }
   
                 }                  }
   
                 printf("        %ld passwords checked.\n", cnt);                  printf("        %ld passwords checked.\n", cnt);

Legend:
Odstranené z verzie1.4  
zmenené riadky
  Pridané vo verzii1.5

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok