-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff9290b
Showing
57 changed files
with
5,890 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
|
||
my $usersdir = "/home/diablo/var/users"; | ||
my $ignore = "admin|public-gate|public-mule"; | ||
my %data; | ||
|
||
sub error { | ||
my $msg = shift; | ||
print STDERR "Error: $msg\n"; | ||
} | ||
|
||
# Read the accountfile and save the passhash1, lastlogin_ip and lastlogin_owner | ||
# in a hash of hashes: $data{username}->{$key} = $value | ||
foreach my $accountfile (<$usersdir/*>) { | ||
|
||
my $username = $accountfile; | ||
$username =~ s|^.*/||g; | ||
|
||
next if($username =~ /($ignore)/); | ||
|
||
unless(-f $accountfile) { | ||
error("Skipping $accountfile. Not a regular file."); | ||
next; | ||
} | ||
|
||
unless(-r $accountfile) { | ||
error("Skipping $accountfile. Not readable."); | ||
next; | ||
} | ||
|
||
open(FILE, "$accountfile") or error($!); | ||
my @filecontent = grep {/BNET\\\\acct\\\\/} <FILE>; | ||
close(FILE) or error($!); | ||
|
||
foreach(@filecontent) { | ||
chomp(); | ||
if(/^\"BNET\\\\acct\\\\(.*)\"=\"(.*)\"$/) { | ||
my $hashkey = $1; | ||
my $hashval = $2; | ||
next unless($hashkey =~ m/passhash1|lastlogin_ip|lastlogin_owner/); | ||
$data{$username}->{$hashkey} = $hashval; | ||
} | ||
} | ||
} | ||
|
||
sub warning { | ||
my $type = shift; | ||
my $acc = shift; | ||
my $compareacc = shift; | ||
my $value = shift; | ||
|
||
if($type eq "PASS") { | ||
print "$type: $acc and $compareacc have the same password ($value)\n"; | ||
} elsif($type eq "IP") { | ||
print "$type: $acc and $compareacc have the same lastlogin IP address ($value)\n"; | ||
} elsif($type eq "USER") { | ||
print "$type: $acc and $compareacc have the same lastlogin windows user ($value)\n"; | ||
} | ||
} | ||
|
||
# Yes, this looks a bit weird. Why not use foreach(keys(...)). This is faster because it | ||
# compares every pair only once. foreach(...) { foreach(..) } would compare a lot more | ||
# already compared pairs. | ||
my @keys = sort keys %data; | ||
for(my $i=0; $i<=$#keys; $i++) { | ||
|
||
for(my $j=$i+1; $j<=$#keys; $j++) { | ||
|
||
if($data{$keys[$i]}->{'passhash1'} eq $data{$keys[$j]}->{'passhash1'}) { | ||
warning("PASS", $keys[$i], $keys[$j], $data{$keys[$i]}->{'passhash1'}); | ||
} | ||
|
||
if($data{$keys[$i]}->{'lastlogin_ip'} eq $data{$keys[$j]}->{'lastlogin_ip'}) { | ||
warning("IP", $keys[$i], $keys[$j], $data{$keys[$i]}->{'lastlogin_ip'}); | ||
} | ||
|
||
if($data{$keys[$i]}->{'lastlogin_owner'} eq $data{$keys[$j]}->{'lastlogin_owner'}) { | ||
warning("USER", $keys[$i], $keys[$j], $data{$keys[$i]}->{'lastlogin_owner'}); | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/perl | ||
use warnings; | ||
use strict; | ||
|
||
my $charinfodir = "/home/diablo/var/charinfo"; | ||
|
||
foreach my $account(<$charinfodir/*>) { | ||
|
||
my $chars=0; | ||
next unless(-d $account); | ||
|
||
foreach my $char(<$account/*>) { | ||
next unless(-f $char); | ||
$chars++; | ||
} | ||
|
||
unless($chars) { | ||
my $path = $account; | ||
$account =~ s|^.*/||g; | ||
print "User account *$account does not contain any characters ($path)\n"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
|
||
my $charinfodir = "/home/diablo/var/charinfo";; | ||
|
||
if(scalar @ARGV == 0) { | ||
print "Usage: $0 <charnames1> [charname2] [charname3] ...\n"; | ||
exit -1; | ||
} | ||
|
||
foreach(@ARGV) { | ||
char_to_acc($_); | ||
} | ||
|
||
sub char_to_acc { | ||
my $search = shift; | ||
my $count = 0; | ||
foreach my $dir(<$charinfodir/*>) { | ||
next unless(-d $dir); | ||
foreach my $char(<$dir/*>) { | ||
next unless(-f $char); | ||
|
||
if(cuttoslash($char) eq "\L$search") { | ||
print "Found $search on user account *" . cuttoslash($dir) . " ($char)\n"; | ||
$count++; | ||
} | ||
|
||
if($count > 1) { | ||
print "Huh!? Duplicate character found!\n"; | ||
} | ||
} | ||
} | ||
print "$search not found\n" if(!$count); | ||
} | ||
|
||
sub cuttoslash { | ||
my $s = shift; | ||
$s =~ s|^.*/||g; | ||
return $s; | ||
} |
Oops, something went wrong.