/usr/share/Crack/scripts/netcrack is in crack-common 5.0a-11.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | #!/usr/bin/perl
###
# This program was written by and is copyright Alec Muffett 1991,
# 1992, 1993, 1994, 1995, and 1996, and is provided as part of the
# Crack v5.0 Password Cracking package.
#
# The copyright holder disclaims all responsibility or liability with
# respect to its usage or its effect upon hardware or computer
# systems, and maintains copyright as set out in the "LICENCE"
# document which accompanies distributions of Crack v5.0 and upwards.
###
eval 'exec perl -S $0 "$@"'
if $runnning_under_some_shell;
# I know it's possible to recode this in awk/sh, in fact it was done
# so for Crack v4.1. I just can't face re-doing it. - alecm
$| = 1;
$nfsdicts = "run/dict/gecos.* run/dict/gcperm.*";
###
# host : relative power : nfs mounted [y/n] : username [optional] : crack dir
###
# foo:30:y:user1:~alecm/crack/c50/
# bar:20:y::~alecm/crack/c50/
# baz:10:n::/usr/local/c50/
#
sub bypower
{
$powerof{$b} <=> $powerof{$a};
}
###
# read the config file and build the lists
###
# use a cookie-based scheme in order to permit multiple instances of
# the same hostname in one file...
$counter = 0;
$cf = "conf/network.conf";
die "netcrack: $cf: $!\n" unless (open(CONFIG, $cf)) ;
while (<CONFIG>)
{
s/\s+$//o;
next if /^\s*\#/o;
next if /^\s*$/o;
$counter++;
($host, $power, $nfs, $user, $path) = split(/:/, $_, 5);
$cookie = "$counter-$host";
$hostof{$cookie} = $host;
$powerof{$cookie} = $power;
$nfsof{$cookie} = $nfs;
$userof{$cookie} = $user if ($user ne "");
$pathof{$cookie} = $path;
$totalpower += $power;
}
close(CONFIG);
$stats{"power"} = $totalpower;
###
# slurp all data into memory for dividing up manually
###
$lastsortkey = ":"; # Ha!
$drossfile = "run/D.network$$";
$killfile = "run/K.network$$";
@data = ();
unless (open(DROSS, ">$drossfile"))
{
die "netcrack: $drossfile: $!\n";
}
while (<STDIN>)
{
unless (/^D:/o)
{
print DROSS $_;
next;
}
$stats{"users"}++;
$sortkey = (split(/:/))[1];
if ($sortkey eq $lastsortkey)
{
$data[$#data] .= $_;
} else
{
$totalkeys++;
$lastsortkey = $sortkey;
push(@data, $_);
}
}
close(DROSS);
$stats{"sortkeys"} = $totalkeys;
###
# print statistics
###
foreach $stat (sort keys %stats)
{
print "netcrack: $stat: $stats{$stat}\n";
}
###
# split the data up proportionately and dispatch
###
$datasize = $#data + 1;
@cookielist = sort bypower keys %hostof;
unless (open(KILL, ">$killfile"))
{
die "netcrack: $killfile: $!\n";
}
print KILL "PATH=$ENV{PATH}\nexport PATH\n";
while (@cookielist)
{
$cookie = shift(@cookielist);
if ($#cookielist >= 0)
{
$slicesize = int(($powerof{$cookie} / $totalpower) * $datasize);
$totalpower -= $powerof{$cookie};
$datasize -= $slicesize;
@slice = splice(@data, 0, $slicesize);
}
else
{
@slice = @data;
}
$slicesize = $#slice + 1;
if ($slicesize)
{
$rshpfx = sprintf("crack-rsh %s %s %s",
(defined($userof{$cookie}) ? "-l $userof{$cookie}" : ""),
$hostof{$cookie},
$pathof{$cookie});
printf("netcrack: %s: power=%d sortkeys=%d (%2.1f%%)\n",
$hostof{$cookie},
$powerof{$cookie},
$slicesize,
($slicesize / $totalkeys) * 100);
if ($nfsof{$cookie} =~ /^n/oi)
{
$cmd = "$rshpfx/Crack -makedict";
printf("netcrack: $cmd\n");
system $cmd;
$cmd = sprintf("crack-rcp %s %s%s:%s/run/dict",
$nfsdicts,
(defined($userof{$cookie}) ? "$userof{$cookie}\@" : ""),
$hostof{$cookie},
$pathof{$cookie});
printf("netcrack: $cmd\n");
system $cmd;
}
$remkillfile = "run/RK$cookie";
$cmd = "$rshpfx/Crack -remote -kill $remkillfile @ARGV";
printf("netcrack: $cmd\n");
unless(open(PIPE, "|$cmd"))
{
warn "netcrack: popen(): $!\n";
}
print PIPE @slice;
close(PIPE);
printf(KILL "crack-rsh %s %s sh -x %s/%s\n",
(defined($userof{$cookie}) ? "-l $userof{$cookie}" : ""),
$hostof{$cookie},
$pathof{$cookie},
$remkillfile);
$slicebytes = 0;
foreach (@slice)
{
$slicebytes += length;
}
printf("netcrack: sent %d sortkeys, %d bytes\n\n",
$slicesize, $slicebytes);
}
}
print KILL "rm -f \$0\n";
print KILL "exit 0\n";
close(KILL);
exit 0;
|