first commit
This commit is contained in:
+275
@@ -0,0 +1,275 @@
|
||||
servers = (
|
||||
{ address = "eu.irc6.net"; chatnet = "IRCnet"; port = "6667"; },
|
||||
{ address = "open.ircnet.net"; chatnet = "IRCnet"; port = "6667"; },
|
||||
{ address = "irc.efnet.org"; chatnet = "EFNet"; port = "6667"; },
|
||||
{
|
||||
address = "irc.undernet.org";
|
||||
chatnet = "Undernet";
|
||||
port = "6667";
|
||||
},
|
||||
{ address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
|
||||
{
|
||||
address = "irc.quakenet.org";
|
||||
chatnet = "QuakeNet";
|
||||
port = "6667";
|
||||
},
|
||||
{ address = "irc.oftc.net"; chatnet = "OFTC"; port = "6667"; },
|
||||
{
|
||||
address = "irc.gamesurge.net";
|
||||
chatnet = "GameSurge";
|
||||
port = "6667";
|
||||
},
|
||||
{ address = "irc.webchat.org"; chatnet = "WebChat"; port = "6667"; },
|
||||
{ address = "irc.rizon.net"; chatnet = "Rizon"; port = "6667"; },
|
||||
{ address = "irc.link-net.org"; chatnet = "LinkNet"; port = "6667"; },
|
||||
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
|
||||
{
|
||||
address = "irc.freenode.net";
|
||||
chatnet = "Freenode";
|
||||
port = "6697";
|
||||
use_ssl = "yes";
|
||||
ssl_verify = "no";
|
||||
autoconnect = "yes";
|
||||
}
|
||||
);
|
||||
|
||||
chatnets = {
|
||||
IRCnet = {
|
||||
type = "IRC";
|
||||
max_kicks = "4";
|
||||
max_msgs = "5";
|
||||
max_whois = "4";
|
||||
max_query_chans = "5";
|
||||
};
|
||||
EFNet = {
|
||||
type = "IRC";
|
||||
max_kicks = "4";
|
||||
max_msgs = "3";
|
||||
max_whois = "1";
|
||||
};
|
||||
Undernet = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
DALnet = {
|
||||
type = "IRC";
|
||||
max_kicks = "4";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
QuakeNet = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
OFTC = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
GameSurge = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
WebChat = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
Rizon = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
LinkNet = {
|
||||
type = "IRC";
|
||||
max_kicks = "1";
|
||||
max_msgs = "3";
|
||||
max_whois = "30";
|
||||
};
|
||||
SILC = { type = "SILC"; };
|
||||
Freenode = { type = "IRC"; };
|
||||
};
|
||||
|
||||
channels = (
|
||||
{ name = "#irssi"; chatnet = "ircnet"; autojoin = "No"; },
|
||||
{ name = "silc"; chatnet = "silc"; autojoin = "No"; }
|
||||
);
|
||||
|
||||
aliases = {
|
||||
J = "join";
|
||||
WJOIN = "join -window";
|
||||
WQUERY = "query -window";
|
||||
LEAVE = "part";
|
||||
BYE = "quit";
|
||||
EXIT = "quit";
|
||||
SIGNOFF = "quit";
|
||||
DESCRIBE = "action";
|
||||
DATE = "time";
|
||||
HOST = "userhost";
|
||||
LAST = "lastlog";
|
||||
SAY = "msg *";
|
||||
WI = "whois";
|
||||
WII = "whois $0 $0";
|
||||
WW = "whowas";
|
||||
W = "who";
|
||||
N = "names";
|
||||
M = "msg";
|
||||
T = "topic";
|
||||
C = "clear";
|
||||
CL = "clear";
|
||||
K = "kick";
|
||||
KB = "kickban";
|
||||
KN = "knockout";
|
||||
BANS = "ban";
|
||||
B = "ban";
|
||||
MUB = "unban *";
|
||||
UB = "unban";
|
||||
IG = "ignore";
|
||||
UNIG = "unignore";
|
||||
SB = "scrollback";
|
||||
UMODE = "mode $N";
|
||||
WC = "window close";
|
||||
WN = "window new hide";
|
||||
SV = "say Irssi $J ($V) - http://irssi.org/";
|
||||
GOTO = "sb goto";
|
||||
CHAT = "dcc chat";
|
||||
RUN = "SCRIPT LOAD";
|
||||
CALC = "exec - if command -v bc >/dev/null 2>&1\\; then printf '%s=' '$*'\\; echo '$*' | bc -l\\; else echo bc was not found\\; fi";
|
||||
SBAR = "STATUSBAR";
|
||||
INVITELIST = "mode $C +I";
|
||||
Q = "QUERY";
|
||||
"MANUAL-WINDOWS" = "set use_status_window off;set autocreate_windows off;set autocreate_query_level none;set autoclose_windows off;set reuse_unused_windows on;save";
|
||||
EXEMPTLIST = "mode $C +e";
|
||||
ATAG = "WINDOW SERVER";
|
||||
UNSET = "set -clear";
|
||||
RESET = "set -default";
|
||||
};
|
||||
|
||||
statusbar = {
|
||||
# formats:
|
||||
# when using {templates}, the template is shown only if it's argument isn't
|
||||
# empty unless no argument is given. for example {sb} is printed always,
|
||||
# but {sb $T} is printed only if $T isn't empty.
|
||||
|
||||
items = {
|
||||
# start/end text in statusbars
|
||||
barstart = "{sbstart}";
|
||||
barend = "{sbend}";
|
||||
|
||||
topicbarstart = "{topicsbstart}";
|
||||
topicbarend = "{topicsbend}";
|
||||
|
||||
# treated "normally", you could change the time/user name to whatever
|
||||
time = "{sb $Z}";
|
||||
user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
|
||||
|
||||
# treated specially .. window is printed with non-empty windows,
|
||||
# window_empty is printed with empty windows
|
||||
window = "{sb $winref:$tag/$itemname{sbmode $M}}";
|
||||
window_empty = "{sb $winref{sbservertag $tag}}";
|
||||
prompt = "{prompt $[.15]itemname}";
|
||||
prompt_empty = "{prompt $winname}";
|
||||
topic = " $topic";
|
||||
topic_empty = " Irssi v$J - http://www.irssi.org";
|
||||
|
||||
# all of these treated specially, they're only displayed when needed
|
||||
lag = "{sb Lag: $0-}";
|
||||
act = "{sb Act: $0-}";
|
||||
more = "-- more --";
|
||||
};
|
||||
|
||||
# there's two type of statusbars. root statusbars are either at the top
|
||||
# of the screen or at the bottom of the screen. window statusbars are at
|
||||
# the top/bottom of each split window in screen.
|
||||
default = {
|
||||
# the "default statusbar" to be displayed at the bottom of the window.
|
||||
# contains all the normal items.
|
||||
window = {
|
||||
disabled = "no";
|
||||
|
||||
# window, root
|
||||
type = "window";
|
||||
# top, bottom
|
||||
placement = "bottom";
|
||||
# number
|
||||
position = "1";
|
||||
# active, inactive, always
|
||||
visible = "active";
|
||||
|
||||
# list of items in statusbar in the display order
|
||||
items = {
|
||||
barstart = { priority = "100"; };
|
||||
time = { };
|
||||
user = { };
|
||||
window = { };
|
||||
window_empty = { };
|
||||
lag = { priority = "-1"; };
|
||||
act = { priority = "10"; };
|
||||
more = { priority = "-1"; alignment = "right"; };
|
||||
barend = { priority = "100"; alignment = "right"; };
|
||||
};
|
||||
};
|
||||
|
||||
# statusbar to use in inactive split windows
|
||||
window_inact = {
|
||||
type = "window";
|
||||
placement = "bottom";
|
||||
position = "1";
|
||||
visible = "inactive";
|
||||
items = {
|
||||
barstart = { priority = "100"; };
|
||||
window = { };
|
||||
window_empty = { };
|
||||
more = { priority = "-1"; alignment = "right"; };
|
||||
barend = { priority = "100"; alignment = "right"; };
|
||||
};
|
||||
};
|
||||
|
||||
# we treat input line as yet another statusbar :) It's possible to
|
||||
# add other items before or after the input line item.
|
||||
prompt = {
|
||||
type = "root";
|
||||
placement = "bottom";
|
||||
# we want to be at the bottom always
|
||||
position = "100";
|
||||
visible = "always";
|
||||
items = {
|
||||
prompt = { priority = "-1"; };
|
||||
prompt_empty = { priority = "-1"; };
|
||||
# treated specially, this is the real input line.
|
||||
input = { priority = "10"; };
|
||||
};
|
||||
};
|
||||
|
||||
# topicbar
|
||||
topic = {
|
||||
type = "root";
|
||||
placement = "top";
|
||||
position = "1";
|
||||
visible = "always";
|
||||
items = {
|
||||
topicbarstart = { priority = "100"; };
|
||||
topic = { };
|
||||
topic_empty = { };
|
||||
topicbarend = { priority = "100"; alignment = "right"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
settings = {
|
||||
core = {
|
||||
real_name = "Unknown";
|
||||
user_name = "ewpt3ch";
|
||||
nick = "ewpt3ch";
|
||||
};
|
||||
"fe-text" = { actlist_sort = "refnum"; };
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
Freenode ewpt3ch sGaZmkSOLb9zqzWFG9u8 PLAIN
|
||||
@@ -0,0 +1,272 @@
|
||||
use strict;
|
||||
use Irssi;
|
||||
use vars qw($VERSION %IRSSI);
|
||||
# $Id$
|
||||
|
||||
use MIME::Base64;
|
||||
|
||||
$VERSION = "1.3";
|
||||
|
||||
%IRSSI = (
|
||||
authors => 'Michael Tharp and Jilles Tjoelker',
|
||||
contact => 'gxti@partiallystapled.com',
|
||||
name => 'cap_sasl.pl',
|
||||
description => 'Implements PLAIN SASL authentication mechanism for use with charybdis ircds, and enables CAP MULTI-PREFIX',
|
||||
license => 'GNU General Public License',
|
||||
url => 'http://ircv3.atheme.org/extensions/sasl-3.1',
|
||||
);
|
||||
|
||||
my %sasl_auth = ();
|
||||
my %mech = ();
|
||||
|
||||
sub timeout;
|
||||
|
||||
sub server_connected {
|
||||
my $server = shift;
|
||||
$server->send_raw_now("CAP LS");
|
||||
}
|
||||
|
||||
sub event_cap {
|
||||
my ($server, $args, $nick, $address) = @_;
|
||||
my ($subcmd, $caps, $tosend);
|
||||
|
||||
$tosend = '';
|
||||
if ($args =~ /^\S+ (\S+) :(.*)$/) {
|
||||
$subcmd = uc $1;
|
||||
$caps = ' '.$2.' ';
|
||||
if ($subcmd eq 'LS') {
|
||||
$tosend .= ' multi-prefix' if $caps =~ / multi-prefix /i;
|
||||
$tosend .= ' sasl' if $caps =~ / sasl /i && defined($sasl_auth{$server->{tag}});
|
||||
$tosend =~ s/^ //;
|
||||
$server->print('', "CLICAP: supported by server:$caps");
|
||||
if (!$server->{connected}) {
|
||||
if ($tosend eq '') {
|
||||
$server->send_raw_now("CAP END");
|
||||
} else {
|
||||
$server->print('', "CLICAP: requesting: $tosend");
|
||||
$server->send_raw_now("CAP REQ :$tosend");
|
||||
}
|
||||
}
|
||||
Irssi::signal_stop();
|
||||
} elsif ($subcmd eq 'ACK') {
|
||||
$server->print('', "CLICAP: now enabled:$caps");
|
||||
if ($caps =~ / sasl /i) {
|
||||
$sasl_auth{$server->{tag}}{buffer} = '';
|
||||
if($mech{$sasl_auth{$server->{tag}}{mech}}) {
|
||||
$server->send_raw_now("AUTHENTICATE " . $sasl_auth{$server->{tag}}{mech});
|
||||
Irssi::timeout_add_once(5000, \&timeout, $server->{tag});
|
||||
}else{
|
||||
$server->print('', 'SASL: attempted to start unknown mechanism "' . $sasl_auth{$server->{tag}}{mech} . '"');
|
||||
}
|
||||
}
|
||||
elsif (!$server->{connected}) {
|
||||
$server->send_raw_now("CAP END");
|
||||
}
|
||||
Irssi::signal_stop();
|
||||
} elsif ($subcmd eq 'NAK') {
|
||||
$server->print('', "CLICAP: refused:$caps");
|
||||
if (!$server->{connected}) {
|
||||
$server->send_raw_now("CAP END");
|
||||
}
|
||||
Irssi::signal_stop();
|
||||
} elsif ($subcmd eq 'LIST') {
|
||||
$server->print('', "CLICAP: currently enabled:$caps");
|
||||
Irssi::signal_stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub event_authenticate {
|
||||
my ($server, $args, $nick, $address) = @_;
|
||||
my $sasl = $sasl_auth{$server->{tag}};
|
||||
return unless $sasl && $mech{$sasl->{mech}};
|
||||
|
||||
$sasl->{buffer} .= $args;
|
||||
return if length($args) == 400;
|
||||
|
||||
my $data = $sasl->{buffer} eq '+' ? '' : decode_base64($sasl->{buffer});
|
||||
my $out = $mech{$sasl->{mech}}($sasl, $data);
|
||||
$out = '' unless defined $out;
|
||||
$out = $out eq '' ? '+' : encode_base64($out, '');
|
||||
|
||||
while(length $out >= 400) {
|
||||
my $subout = substr($out, 0, 400, '');
|
||||
$server->send_raw_now("AUTHENTICATE $subout");
|
||||
}
|
||||
if(length $out) {
|
||||
$server->send_raw_now("AUTHENTICATE $out");
|
||||
}else{ # Last piece was exactly 400 bytes, we have to send some padding to indicate we're done
|
||||
$server->send_raw_now("AUTHENTICATE +");
|
||||
}
|
||||
|
||||
$sasl->{buffer} = '';
|
||||
Irssi::signal_stop();
|
||||
}
|
||||
|
||||
sub event_saslend {
|
||||
my ($server, $args, $nick, $address) = @_;
|
||||
|
||||
my $data = $args;
|
||||
$data =~ s/^\S+ :?//;
|
||||
# need this to see it, ?? -- jilles
|
||||
$server->print('', $data);
|
||||
if (!$server->{connected}) {
|
||||
$server->send_raw_now("CAP END");
|
||||
}
|
||||
}
|
||||
|
||||
sub timeout {
|
||||
my $tag = shift;
|
||||
my $server = Irssi::server_find_tag($tag);
|
||||
if(!$server->{connected}) {
|
||||
$server->print('', "SASL: authentication timed out");
|
||||
$server->send_raw_now("CAP END");
|
||||
}
|
||||
}
|
||||
|
||||
sub cmd_sasl {
|
||||
my ($data, $server, $item) = @_;
|
||||
|
||||
if ($data ne '') {
|
||||
Irssi::command_runsub ('sasl', $data, $server, $item);
|
||||
} else {
|
||||
cmd_sasl_show(@_);
|
||||
}
|
||||
}
|
||||
|
||||
sub cmd_sasl_set {
|
||||
my ($data, $server, $item) = @_;
|
||||
|
||||
if (my($net, $u, $p, $m) = $data =~ /^(\S+) (\S+) (\S+) (\S+)$/) {
|
||||
if($mech{uc $m}) {
|
||||
$sasl_auth{$net}{user} = $u;
|
||||
$sasl_auth{$net}{password} = $p;
|
||||
$sasl_auth{$net}{mech} = uc $m;
|
||||
Irssi::print("SASL: added $net: [$m] $sasl_auth{$net}{user} *");
|
||||
}else{
|
||||
Irssi::print("SASL: unknown mechanism $m");
|
||||
}
|
||||
} elsif ($data =~ /^(\S+)$/) {
|
||||
$net = $1;
|
||||
if (defined($sasl_auth{$net})) {
|
||||
delete $sasl_auth{$net};
|
||||
Irssi::print("SASL: deleted $net");
|
||||
} else {
|
||||
Irssi::print("SASL: no entry for $net");
|
||||
}
|
||||
} else {
|
||||
Irssi::print("SASL: usage: /sasl set <net> <user> <password or keyfile> <mechanism>");
|
||||
}
|
||||
}
|
||||
|
||||
sub cmd_sasl_show {
|
||||
#my ($data, $server, $item) = @_;
|
||||
my $net;
|
||||
my $count = 0;
|
||||
|
||||
foreach $net (keys %sasl_auth) {
|
||||
Irssi::print("SASL: $net: [$sasl_auth{$net}{mech}] $sasl_auth{$net}{user} *");
|
||||
$count++;
|
||||
}
|
||||
Irssi::print("SASL: no networks defined") if !$count;
|
||||
}
|
||||
|
||||
sub cmd_sasl_save {
|
||||
#my ($data, $server, $item) = @_;
|
||||
my $file = Irssi::get_irssi_dir()."/sasl.auth";
|
||||
open FILE, "> $file" or return;
|
||||
foreach my $net (keys %sasl_auth) {
|
||||
printf FILE ("%s\t%s\t%s\t%s\n", $net, $sasl_auth{$net}{user}, $sasl_auth{$net}{password}, $sasl_auth{$net}{mech});
|
||||
}
|
||||
close FILE;
|
||||
Irssi::print("SASL: auth saved to $file");
|
||||
}
|
||||
|
||||
sub cmd_sasl_load {
|
||||
#my ($data, $server, $item) = @_;
|
||||
my $file = Irssi::get_irssi_dir()."/sasl.auth";
|
||||
|
||||
open FILE, "< $file" or return;
|
||||
%sasl_auth = ();
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
my ($net, $u, $p, $m) = split (/\t/, $_, 4);
|
||||
$m ||= "PLAIN";
|
||||
if($mech{uc $m}) {
|
||||
$sasl_auth{$net}{user} = $u;
|
||||
$sasl_auth{$net}{password} = $p;
|
||||
$sasl_auth{$net}{mech} = uc $m;
|
||||
}else{
|
||||
Irssi::print("SASL: unknown mechanism $m");
|
||||
}
|
||||
}
|
||||
close FILE;
|
||||
Irssi::print("SASL: auth loaded from $file");
|
||||
}
|
||||
|
||||
sub cmd_sasl_mechanisms {
|
||||
Irssi::print("SASL: mechanisms supported: " . join(" ", keys %mech));
|
||||
}
|
||||
|
||||
Irssi::signal_add_first('server connected', \&server_connected);
|
||||
Irssi::signal_add('event cap', \&event_cap);
|
||||
Irssi::signal_add('event authenticate', \&event_authenticate);
|
||||
Irssi::signal_add('event 903', 'event_saslend');
|
||||
Irssi::signal_add('event 904', 'event_saslend');
|
||||
Irssi::signal_add('event 905', 'event_saslend');
|
||||
Irssi::signal_add('event 906', 'event_saslend');
|
||||
Irssi::signal_add('event 907', 'event_saslend');
|
||||
|
||||
Irssi::command_bind('sasl', \&cmd_sasl);
|
||||
Irssi::command_bind('sasl load', \&cmd_sasl_load);
|
||||
Irssi::command_bind('sasl save', \&cmd_sasl_save);
|
||||
Irssi::command_bind('sasl set', \&cmd_sasl_set);
|
||||
Irssi::command_bind('sasl show', \&cmd_sasl_show);
|
||||
Irssi::command_bind('sasl mechanisms', \&cmd_sasl_mechanisms);
|
||||
|
||||
$mech{PLAIN} = sub {
|
||||
my($sasl, $data) = @_;
|
||||
my $u = $sasl->{user};
|
||||
my $p = $sasl->{password};
|
||||
|
||||
join("\0", $u, $u, $p);
|
||||
};
|
||||
|
||||
eval {
|
||||
require Crypt::OpenSSL::Bignum;
|
||||
require Crypt::DH;
|
||||
require Crypt::Blowfish;
|
||||
require Math::BigInt;
|
||||
sub bin2bi { return Crypt::OpenSSL::Bignum->new_from_bin(shift)->to_decimal } # binary to BigInt
|
||||
sub bi2bin { return Crypt::OpenSSL::Bignum->new_from_decimal((shift)->bstr)->to_bin } # BigInt to binary
|
||||
$mech{'DH-BLOWFISH'} = sub {
|
||||
my($sasl, $data) = @_;
|
||||
my $u = $sasl->{user};
|
||||
my $pass = $sasl->{password};
|
||||
|
||||
# Generate private key and compute secret key
|
||||
my($p, $g, $y) = unpack("(n/a*)3", $data);
|
||||
my $dh = Crypt::DH->new(p => bin2bi($p), g => bin2bi($g));
|
||||
$dh->generate_keys;
|
||||
|
||||
my $secret = bi2bin($dh->compute_secret(bin2bi($y)));
|
||||
my $pubkey = bi2bin($dh->pub_key);
|
||||
|
||||
# Pad the password to the nearest multiple of blocksize and encrypt
|
||||
$pass .= "\0";
|
||||
$pass .= chr(rand(256)) while length($pass) % 8;
|
||||
|
||||
my $cipher = Crypt::Blowfish->new($secret);
|
||||
my $crypted = '';
|
||||
while(length $pass) {
|
||||
my $clear = substr($pass, 0, 8, '');
|
||||
$crypted .= $cipher->encrypt($clear);
|
||||
}
|
||||
|
||||
pack("n/a*Z*a*", $pubkey, $u, $crypted);
|
||||
};
|
||||
};
|
||||
|
||||
cmd_sasl_load();
|
||||
|
||||
# vim: ts=4
|
||||
Reference in New Issue
Block a user