descambles cisco IOS type-7 passwords

 cha88将要更新的功能,记录一下

C++代码
  1.   
  2. /*  
  3. * * descambles cisco IOS type-7 passwords  
  4. * * found somewhere on the internet, slightly modified, anonymous@segfault.net  
  5. * *  
  6. * * gcc -Wall -o ciscocrack ciscocrack.c  
  7. * * ./ciscocrack 080949420516 
  8. * *  
  9. * */  
  10.   
  11. #include <stdio.h>   
  12. #include <ctype.h>   
  13.   
  14. char xlat[] = {   
  15.         0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f,   
  16.         0x41, 0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72,   
  17.         0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53,    
  18.         0x55, 0x42    
  19. };   
  20.   
  21.   
  22. int  
  23. cdecrypt(char *enc_pw, char *dec_pw)   
  24. {   
  25.         unsigned int seed, i, val = 0;   
  26.   
  27.         if(strlen(enc_pw) & 1)   
  28.                 return(-1);   
  29.   
  30.         seed = (enc_pw[0] - '0') * 10 + enc_pw[1] - '0';   
  31.   
  32.         if (seed > 15 || !isdigit(enc_pw[0]) || !isdigit(enc_pw[1]))   
  33.                 return(-1);   
  34.   
  35.         for (i = 2 ; i <= strlen(enc_pw); i++) {   
  36.                 if(i !=2 && !(i & 1)) {   
  37.                         dec_pw[i / 2 - 2] = val ^ xlat[seed++];   
  38.                         val = 0;   
  39.                 }   
  40.   
  41.                 val *= 16;   
  42.   
  43.                 if(isdigit(enc_pw[i] = toupper(enc_pw[i]))) {   
  44.                         val += enc_pw[i] - '0';   
  45.                         continue;   
  46.                 }   
  47.   
  48.                 if(enc_pw[i] >= 'A' && enc_pw[i] <= 'F') {   
  49.                         val += enc_pw[i] - 'A' + 10;   
  50.                         continue;   
  51.                 }   
  52.   
  53.                 if(strlen(enc_pw) != i)   
  54.                         return(-1);   
  55.         }   
  56.   
  57.         dec_pw[++i / 2] = 0;   
  58.   
  59.         return(0);   
  60. }   
  61.   
  62. void  
  63. usage()   
  64. {   
  65.         fprintf(stdout, "Usage: ciscocrack <encrypted password>\n");   
  66. }   
  67.   
  68. int  
  69. main(int argc, char *argv[])   
  70. {   
  71.     char passwd[65];   
  72.   
  73.     memset(passwd, 0, sizeof(passwd));   
  74.   
  75.     if(argc != 2)   
  76.     {   
  77.           usage();   
  78.           exit(1);   
  79.     }   
  80.   
  81.     if(cdecrypt(argv[1], passwd)) {   
  82.           fprintf(stderr, "Error\n");   
  83.           exit(1);   
  84.     }   
  85.     printf("Passwd: %s\n", passwd);   
  86.   
  87.     return 0;   
  88. }   

Tags: cisco, password

« 上一篇 | 下一篇 »

相关文章

访客评论

  1. #1 QQ游戏 2009, February 18, 9:08 AM
    好长的代码!!

发表评论

评论内容 (必填):

点击获得Trackback地址