Skip to content

Commit ff9290b

Browse files
committed
initial
0 parents  commit ff9290b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+5890
-0
lines changed

files/DuplicateAccs.pl

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/perl
2+
use strict;
3+
use warnings;
4+
5+
my $usersdir = "/home/diablo/var/users";
6+
my $ignore = "admin|public-gate|public-mule";
7+
my %data;
8+
9+
sub error {
10+
my $msg = shift;
11+
print STDERR "Error: $msg\n";
12+
}
13+
14+
# Read the accountfile and save the passhash1, lastlogin_ip and lastlogin_owner
15+
# in a hash of hashes: $data{username}->{$key} = $value
16+
foreach my $accountfile (<$usersdir/*>) {
17+
18+
my $username = $accountfile;
19+
$username =~ s|^.*/||g;
20+
21+
next if($username =~ /($ignore)/);
22+
23+
unless(-f $accountfile) {
24+
error("Skipping $accountfile. Not a regular file.");
25+
next;
26+
}
27+
28+
unless(-r $accountfile) {
29+
error("Skipping $accountfile. Not readable.");
30+
next;
31+
}
32+
33+
open(FILE, "$accountfile") or error($!);
34+
my @filecontent = grep {/BNET\\\\acct\\\\/} <FILE>;
35+
close(FILE) or error($!);
36+
37+
foreach(@filecontent) {
38+
chomp();
39+
if(/^\"BNET\\\\acct\\\\(.*)\"=\"(.*)\"$/) {
40+
my $hashkey = $1;
41+
my $hashval = $2;
42+
next unless($hashkey =~ m/passhash1|lastlogin_ip|lastlogin_owner/);
43+
$data{$username}->{$hashkey} = $hashval;
44+
}
45+
}
46+
}
47+
48+
sub warning {
49+
my $type = shift;
50+
my $acc = shift;
51+
my $compareacc = shift;
52+
my $value = shift;
53+
54+
if($type eq "PASS") {
55+
print "$type: $acc and $compareacc have the same password ($value)\n";
56+
} elsif($type eq "IP") {
57+
print "$type: $acc and $compareacc have the same lastlogin IP address ($value)\n";
58+
} elsif($type eq "USER") {
59+
print "$type: $acc and $compareacc have the same lastlogin windows user ($value)\n";
60+
}
61+
}
62+
63+
# Yes, this looks a bit weird. Why not use foreach(keys(...)). This is faster because it
64+
# compares every pair only once. foreach(...) { foreach(..) } would compare a lot more
65+
# already compared pairs.
66+
my @keys = sort keys %data;
67+
for(my $i=0; $i<=$#keys; $i++) {
68+
69+
for(my $j=$i+1; $j<=$#keys; $j++) {
70+
71+
if($data{$keys[$i]}->{'passhash1'} eq $data{$keys[$j]}->{'passhash1'}) {
72+
warning("PASS", $keys[$i], $keys[$j], $data{$keys[$i]}->{'passhash1'});
73+
}
74+
75+
if($data{$keys[$i]}->{'lastlogin_ip'} eq $data{$keys[$j]}->{'lastlogin_ip'}) {
76+
warning("IP", $keys[$i], $keys[$j], $data{$keys[$i]}->{'lastlogin_ip'});
77+
}
78+
79+
if($data{$keys[$i]}->{'lastlogin_owner'} eq $data{$keys[$j]}->{'lastlogin_owner'}) {
80+
warning("USER", $keys[$i], $keys[$j], $data{$keys[$i]}->{'lastlogin_owner'});
81+
}
82+
}
83+
84+
}
85+

files/EmptyAccounts.pl

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/perl
2+
use warnings;
3+
use strict;
4+
5+
my $charinfodir = "/home/diablo/var/charinfo";
6+
7+
foreach my $account(<$charinfodir/*>) {
8+
9+
my $chars=0;
10+
next unless(-d $account);
11+
12+
foreach my $char(<$account/*>) {
13+
next unless(-f $char);
14+
$chars++;
15+
}
16+
17+
unless($chars) {
18+
my $path = $account;
19+
$account =~ s|^.*/||g;
20+
print "User account *$account does not contain any characters ($path)\n";
21+
}
22+
23+
}

files/FindChar.pl

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/perl
2+
use strict;
3+
use warnings;
4+
5+
my $charinfodir = "/home/diablo/var/charinfo";;
6+
7+
if(scalar @ARGV == 0) {
8+
print "Usage: $0 <charnames1> [charname2] [charname3] ...\n";
9+
exit -1;
10+
}
11+
12+
foreach(@ARGV) {
13+
char_to_acc($_);
14+
}
15+
16+
sub char_to_acc {
17+
my $search = shift;
18+
my $count = 0;
19+
foreach my $dir(<$charinfodir/*>) {
20+
next unless(-d $dir);
21+
foreach my $char(<$dir/*>) {
22+
next unless(-f $char);
23+
24+
if(cuttoslash($char) eq "\L$search") {
25+
print "Found $search on user account *" . cuttoslash($dir) . " ($char)\n";
26+
$count++;
27+
}
28+
29+
if($count > 1) {
30+
print "Huh!? Duplicate character found!\n";
31+
}
32+
}
33+
}
34+
print "$search not found\n" if(!$count);
35+
}
36+
37+
sub cuttoslash {
38+
my $s = shift;
39+
$s =~ s|^.*/||g;
40+
return $s;
41+
}

0 commit comments

Comments
 (0)