【asp精品源码栏目提醒】:网学会员在asp精品源码频道为大家收集整理了“穷举破解shadow的简单程序 - 计算机教材“提供大家参考,希望对大家有所帮助!
穷举破解shadow的简单
程序C 效率一点也不好。
。
。
/ ID: icymoon Date: 2006.05.13. Just a practise Complie: gcc mcrack.c -o mcrack -lcrypt / include include include include define MAX_DIC 26 define MAX_PASS 16 define MIN_PASS 6 //char dic_charMAX_DIC 1234567890 abcdefghijklmn opqrstuvwxyz //define MAX_DIC 10 //define MAX_PASS 10 //define MIN_PASS 3 //char dic_charMAX_DIC 1234567890 char dic_charMAX_DIC abcdefghijklmn opqrstuvwxyz char sh_file256 char shadow_line256 char salt12 char crypt_passwd35 char username32 FILE sh_fp //print message exit void myexitchar msg int quit printfsn msg exitquit //Show usage void usagechar programme printfUsage: s -l -s n exit0 //Do crack int crackint length int i j curr_length int count 0 char guess long dic_indexMAX_DIC int flag char check char malloc35sizeofchar forcurr_length MIN_PASS curr_length 0 j -- dic_indexj ifdic_indexj MAX_DIC break else dic_indexj 0 ifj 0 flag 0 freeguess freecheck return 0 int mainint argc char argv int pass_long 0 int optline 0 ifargc 1 usageargv0 //get and check options whileopt getoptargc argv hs:l: -1 switchopt case l: pass_long atoioptarg ifpass_long 0 pass_long MAX_PASS myexitThe length of password is wrong 99 break case s: strncpysh_file optarg sizeofsh_file sh_filesizeofsh_file - 1 0 break case h: default: usageargv0 break ifpass_long 0 pass_long MIN_PASS ifsh_fp fopensh_file r NULL myexitOpen shadow file error 99 while1 memsetshadow_line 0 sizeofshadow_line iffgetsshadow_line sizeofshadow_line sh_fp NULL break else//get username crypted pass
word and salt char tmp strchrshadow_line char tmp1 char tmp2 memsetsalt 0 sizeofsalt memsetusername 0 sizeofusername line iftmp NULL printfError shadow format line d: sn line shadow_line continue tmp1 strchrshadow_line : tmp2 strchrtmp1 1 : tmp1 0 tmp2 0 ifstrlenshadow_line sizeofusername printfUsername too long line dn line continue strncpyusername shadow_line strlenshadow_line usernamestrlenshadow_line 0 strncpysalt tmp 12 strncpycrypt_passwd tmp 34 crypt_passwd34 0 crackpass_long