use Irssi 20020300; use strict; use Socket; use Data::Dumper; use Shell; use vars qw($VERSION %IRSSI); $VERSION = "0.01"; %IRSSI = ( authors => "Vasya Pupkin", contact => "zion-at-x96.org", name => "dns_ban", description => "bans fosgate", license => "w/e", changed => "Wed Feb 14 19:46:44 2007" ); sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } sub msg_join { my ($server, $channame, $nick, $host) = @_; my @domains = Irssi::settings_get_str("fosgate_domain"); my @ips = Irssi::settings_get_str("fosgate_ipv4"); my @ipv6s = Irssi::settings_get_str("fosgate_ipv6"); my ($hostname, $ip, $ipv6, $arg); if ($host =~ m/\@(.*)/) { $arg = $1; } return if ($channame ne '#x96' || !defined $arg); if ($arg =~ /^[0-9\.]*$/) { #IPV4 detected # ip -> host $hostname = gethostbyaddr(inet_aton($arg), AF_INET); $ip = $arg; } elsif ($arg =~ /:/) { #IPV6 detected $ipv6 = $arg; $ip = undef; $hostname = undef; } elsif ($arg =~ /\//) { #MASKED HOSTNAME detected, doubt any spamer will spam using that return 0; } else { # PTR hostname detected $ip = trim(dig("A", "$arg", "+short")); $ipv6 = trim(dig("AAAA", "$arg", "+short")); $hostname = $arg; } if (defined $hostname) { foreach (@domains) { if ( $hostname =~ /$_$/ ) { $server->send_raw("KICK $channame $nick :thanks for passing by"); $server->send_raw("MODE $channame +b *!*@*$hostname"); return 0; } } } if (defined $ip) { foreach (@ips) { if ( $ip =~ /$_/ ) { $server->send_raw("KICK $channame $nick :thanks for passing by"); $server->send_raw("MODE $channame +b *!*@$arg"); return 0; } } } if (defined $ipv6) { foreach (@ipv6s) { if ( $ipv6 =~ /$_/ ) { $server->send_raw("KICK $channame $nick :thanks for passing by"); $server->send_raw("MODE $channame +b *!*@$arg"); return 0; } } } }; Irssi::signal_add("message join","msg_join"); Irssi::settings_add_str("misc", "fosgate_domain", "irc.su stbur.ru orts.ru lowtech.se intec.edu"); Irssi::settings_add_str("misc", "fosgate_ipv4", "69.69.69.69"); Irssi::settings_add_str("misc", "fosgate_ipv6", "2001:618:400:dc26");