-
Notifications
You must be signed in to change notification settings - Fork 6
/
wall_of_sheep.pl
executable file
·103 lines (85 loc) · 2.57 KB
/
wall_of_sheep.pl
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
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Term::ANSIColor;
use constant REVEAL_DIVISOR => 30;
use constant PASS_LENGTH => 20;
use constant PASS_SUFFIX => '*' x PASS_LENGTH;
use constant WHITELIST_FILE => '.whitelist';
my (%idiots, @whitelist);
# Newline delimited list of hostnames
if ( -f WHITELIST_FILE) {
open (my $fh, WHITELIST_FILE);
@whitelist = <$fh>;
map { chomp } @whitelist;
close $fh;
}
#Attempt to prevent screen blanking
printf ("\033[9;%ld]", 0);
#Reset colors to normal white on black
print color("reset");
#super legit cross-platform screen clear
system(($^O eq 'MSWin32') ? 'cls' : 'clear');
while(my $line = <>){
#Hope you like regexp.
if ($line =~ /^(\w+) : (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}):(\d{1,10}) -> USER: (.+) PASS: (.*)/){
my $protocol = $1;
my $ip = "$2.$3.$4.$5";
my $port = $6;
my $user = $7;
my $pass = $8;
my $ip_addr = pack("C4", $2,$3,$4,$5);
my ($hostname) = (gethostbyaddr($ip_addr, 2))[0];
next if ($hostname ~~ @whitelist);
next if ($ip ~~ @whitelist);
$idiots{$ip}++;
my $scrubbed_pass = "";
if(length($pass) > 1){
$scrubbed_pass=substr($pass,0,($idiots{$ip} / REVEAL_DIVISOR) + 1).PASS_SUFFIX;
$scrubbed_pass = $pass if ($scrubbed_pass =~ /$pass/);
}
else{
# What the hell, this user is an idiot. Let him suffer.
$scrubbed_pass = $pass;
}
pick_color($protocol);
$protocol = sprintf '%9s', $protocol;
$ip = sprintf '%15s', $ip;
if(defined($hostname)){
$hostname = sprintf '(%.*s)', 26, $hostname;
}
else{
$hostname = "";
}
$user = sprintf '%.*s', 16, $user;
$pass = sprintf '%.*s', PASS_LENGTH, $scrubbed_pass;
print pack("A10 A16 A29 A17 A".PASS_LENGTH, $protocol, $ip, $hostname, $user, $pass);
print "\n";
print color("reset");
}
}
sub pick_color{
my $protocol = shift;
given ($protocol) {
when (/TELNET/) { print color("red") }
when (/RLOGIN/) { print color("red") }
when (/SSH/) { print color("red") }
when (/VNC/) { print color("red") }
when (/SMB/) { print color("magenta") }
when (/LDAP/) { print color("magenta") }
when (/ICQ/) { print color("green") }
when (/MSN/) { print color("green") }
when (/YMSG/) { print color("green") }
when (/IRC/) { print color("green") }
when (/HTTP/) { print color("blue") }
when (/FTP/) { print color("blue") }
when (/MYSQL/) { print color("blue") }
when (/POP/) { print color("yellow") }
when (/IMAP/) { print color("yellow") }
when (/SMTP/) { print color("yellow") }
when (/NNTP/) { print color("yellow") }
when (/SOCKS5/) {print color("cyan") }
when (/CVS/) {print color("cyan") }
}
}