![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
1. #!/usr/bin/perl
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
2.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
3. # crack.pl
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
4.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
5. use English;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
6. use FileHandle;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
7.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
8. #Set ALL USER s pictures
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
9. #$FORMAT_NAME =
"AUSER";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
10. #$FORMAT_TOP_NAME =
"AUSER_TOP";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
11. $~ =
"AUSER";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
12. $^ =
"AUSER_TOP";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
13.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
14. # Step 1:
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
15. # Get all account list,and genarate a report.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
16. # In the mean time get system users names and
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
17. # passwords,get ready
for cracking.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
18.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
19. my $allcount = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
20. my $syscount = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
21. my $lockcount = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
22. my $unknown = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
23. my @encrypt = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
24. my @users = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
25.
while (($account,$passwd,$uid,$gid,$quota,$coment,$gcos,$home,$shell) = getpwent())
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
26. {
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
27. write;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
28. $allcount ++;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
29.
if ($passwd =~ /\$/){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
30. $users[$syscount] = $account;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
31. $encrypt[$syscount] = $passwd;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
32. $syscount++;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
33. }elsif($passwd =~ /\*/ || $passwd =~ /\!/ || $passwd =~ /x/){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
34. $lockcount++;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
35. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
36. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
37. $unknown = $allcount - $syscount - $lockcount;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
38.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
39. # Print table Header.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
40. format AUSER_TOP =
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
41. =========================================================================================
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
42. Name Password UID GID Home Shell
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
43. =========================================================================================
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
44. .
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
45. # Print table Body.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
46. format AUSER =
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
47. @<<<@<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<@<<<<<@<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
48. $allcount+1,$account,$passwd,$uid,$gid,$home,$shell
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
49. .
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
50. # Print some statistics on footer.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
51. print
"\n=====================================================================================\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
52. print $allcount.
" accounts, ".$syscount.
" systems user(s), ".$lockcount.
"accounts locked, ".$unknown.
" accounts unknown.\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
53. print
"=====================================================================================\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
54.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
55. # Step 1 ends...
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
56.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
57. # Step 2:
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
58. # Get all system user salt.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
59.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
60. my $i = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
61. my $escstring;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
62. my @salt = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
63.
foreach $user(@users){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
64. $escstring = (getpwnam($user))[1];
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
65. $salt[$i] = substr($escstring,0,12);
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
66. $i++;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
67. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
68. # Step 2 ends...
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
69.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
70. # Step 3:
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
71. # Read password from list,crypt them with
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
72. # each salt.Compare the crypted password from list
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
73. # with /etc/shadow
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
74.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
75. my $word_count = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
76. my $j = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
77. my $n = 0;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
78. my @word = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
79. my $encstring;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
80. my @baduser = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
81. my @badpasswd = ();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
82. # Open file to read word list.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
83. open (DICT,
"password.lst") or die
"file error:$!\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
84. @words = <DICT>;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
85. chomp @words;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
86. $word_count = @words;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
87. # Crack begins....
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
88.
for ($i = 0; $i < $syscount; $i++){ # Crack The $i`th user's password.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
89. print
"Testing $users[$i] password\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
90.
for ($j = 0; $j < $word_count; $j++){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
91. $encstring = crypt($words[$j],$salt[$i]);
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
92.
if ($encstring eq $encrypt[$i]){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
93. $baduser[$n] = $users[$i];
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
94. $badpasswd[$n] = $words[$j];
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
95. $n++;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
96. print
"Password cracked.\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
97. last;
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
98. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
99. } # Continue the crack process.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
100. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
101. # Crack ends.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
102.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
103. # Display result.
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
104.
if ($n != 0){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
105. print
"$n bad account(s).\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
106. print
"The following is list:\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
107.
for ($i = 0; $i < $n; $i++){
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
108. print
"$baduser[$i] : $badpasswd[$i]\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
109. }
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
110. print
"The password(s) is(are) based on dictory,please change it immdiately.\n";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
111. }
else{
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
112. print
"No password cracked";
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
113. }