html/remote.pl
1 #!/usr/bin/perl -w
2 use Irssi 20010120.0250 ();
3 $VERSION = "1";
4 %IRSSI = (
5 authors => 'David Leadbeater',
6 contact => 'dgl@dgl.cx',
7 name => 'remote',
8 description => 'Lets you run commands remotely via /msg and a password',
9 license => 'GNU GPLv2 or later',
10 url => 'http://irssi.dgl.yi.org/',
11 );
12
13
14 # Usage:
15 # as your user /remote on (uncomment the $remote = 1 line below if you want it
16 # on by default)
17 # /msg user remote login password
18 # then /msg user remote command
19 # it will execute the command on the same server...
20 # so you can do mode #channel +o whoever
21 # but it will allow any command, yes it's dangerous if someone knows the
22 # password they can access just about anything your user account can....
23 use strict;
24 # put a crypted password here
25 my $password = "pp00000000";
26 my($login,$remote);
27 # $remote = 1;
28
29 sub event{
30 my($server,$text,$nick,$hostmask)=@_;
31 # if you're really paranoid change this....
32 if($text =~ s/^remote\s+//i){
33 my $ok;
34 $ok = 1 if $login eq $nick."!".$hostmask;
35 $ok = 0 if !defined $remote;
36 my($command,$options) = split(/ /,$text,2);
37 if($command eq "login"){
38 if(crypt($options,substr($password,0,2)) eq $password){
39 $login = $nick."!".$hostmask;
40 }else{
41 Irssi::print("Invaild login attempt from $nick ($hostmask): $text");
42 }
43 }elsif(!$ok){
44 Irssi::print("Invaild remote use from $nick ($hostmask): $text");
45 }elsif($ok){
46 Irssi::command("/".$text);
47 }
48 }
49 }
50
51 sub remote{
52 my($args) = shift;
53 if($args eq "enable" or $args eq "on"){
54 $remote = 1;
55 }else{
56 $remote = undef;
57 }
58 }
59
60 Irssi::signal_add_last("message private", "event");
61 Irssi::command_bind("remote", "remote");
62