1
0

wraith.pl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. use Irssi 20020121.2020 ();
  2. $VERSION = "1.01";
  3. %IRSSI = (
  4. authors => 'bryan P38',
  5. contact => 'bryan@shatow.net, bryan on EFnet',
  6. name => 'wraith-auth',
  7. description => 'private auth script for botpack wraith',
  8. license => 'ALL?',
  9. url => 'https://github.com/wraith/wraith/wiki/AuthSystem',
  10. changed => '$Date$ ',
  11. );
  12. use Irssi::Irc; # for DCC object
  13. use Digest::MD5 qw(md5 md5_hex md5_base64);
  14. use Encode qw(encode_utf8);
  15. sub cmd_auth {
  16. my($data,$server,$witem) = @_;
  17. if (!$data) {
  18. Irssi:print "Usage: /auth hash\nbefore you can do that, type /set auth, then /set all of the variables that show.\n";
  19. } else {
  20. Irssi::print auth($data);
  21. }
  22. }
  23. sub auth($) {
  24. my($data,$server,$witem) = @_;
  25. my ($secpass,$authkey,$botdump,$hash);
  26. #lets use the right word for the hash.
  27. my @words = split " ", $data;
  28. if ($data =~ /^\-Auth/) {
  29. $hash = $words[1];
  30. } else {
  31. $hash = $words[0];
  32. }
  33. # Irssi::print "Authing: $hash";
  34. $secpass = Irssi::settings_get_str('auth_secpass');
  35. $authkey = Irssi::settings_get_str('auth_authkey');
  36. $botdump = $hash . $secpass . $authkey ;
  37. return md5_hex(encode_utf8($botdump));
  38. }
  39. #this must handle both auth. and -Auth
  40. Irssi::signal_add "message private", sub {
  41. my ($server, $text, $nick, $address, $target) = @_;
  42. my ($msg, $data, $password);
  43. my (@servers) = Irssi::servers();
  44. if ($msg =~ /^\255\251\001/) {
  45. $msg = substr($text,3);
  46. } else {
  47. $msg = $text;
  48. }
  49. # if ($nick =~ /^\(/) { #this is a psybnc dcc chat.
  50. # } else { #normal msg
  51. # $password = Irssi::settings_get_str('auth_password');
  52. # if ($msg =~ /^auth\./) { #msg back password
  53. # send auth $password;
  54. # }
  55. # }
  56. if ($msg =~ /^\-Auth/) {
  57. $server = $servers[0];
  58. my $cmd = "/MSG $nick +Auth " . auth($msg);
  59. $server->command("$cmd");
  60. }
  61. };
  62. #this must handle -Auth
  63. Irssi::signal_add "dcc chat message", sub {
  64. my ($dcc, $text) = @_;
  65. my ($msg,$data);
  66. my (@servers) = Irssi::servers();
  67. if ($msg =~ /^\255\251\001/) {
  68. $msg = substr($text,3);
  69. } else {
  70. $msg = $text;
  71. }
  72. if ($msg =~ /^\-Auth/) {
  73. # my $cmd = "/MSG =". $dcc->{nick} . " +Auth ". auth($msg);
  74. $server = $servers[0];
  75. my $cmd = "+Auth ". auth($msg);
  76. $server->command("/MSG =". $dcc->{nick} . " ". $cmd);
  77. # $dcc->send("$cmd");
  78. # send +Auth auth($msg);
  79. }
  80. };
  81. #Irssi::settings_add_str('auth', 'auth_password', '');
  82. Irssi::settings_add_str('auth', 'auth_secpass', '');
  83. Irssi::settings_add_str('auth', 'auth_authkey', '');
  84. Irssi::command_bind("auth", "cmd_auth");
  85. Irssi::print "Wraith authorization script loaded.";