[ Avaa Bypassed ]




Upload:

Command:

www-data@13.58.229.23: ~ $
#!/usr/bin/perl
#
# moncmd - send a command to the mon server
#
# original file is modified to suit for the operation in this webmin module of msclinux--dt 09 Sept 2001
#
# Jim Trocki, trockij@transmeta.com
#
# $Id: moncmd 1.2 Fri, 12 Jan 2001 08:13:31 -0800 trockij $
#
#    Copyright (C) 1998, Jim Trocki
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
use Getopt::Std;
use Socket;
use English;

getopts ("ahf:l:s:p:rd");

sub usage;
sub do_cmd;

$MONSERVER = $ENV{"MONHOST"}
    if (defined ($ENV{"MONHOST"}));
$MONSERVER = $opt_s if ($opt_s);
$MONPORT   = $opt_p || getservbyname ("mon", "tcp") || 2583;

if ($opt_h) {
    usage;
}

if (!defined ($MONSERVER)) {
    die "No host specified or found in MONHOST\n";
}

$SIG{INT} = \&handle_sig;
$SIG{TERM} = \&handle_sig;

#
# does the input come from stdin or a file?
#
if ($opt_f) {
    if ($opt_f eq "-") {
    	$H = STDIN;
#print LOG "READING H from STDIN<br>";
    } else {
    	open (IN, $opt_f) ||
	    die "could not open input file: $!\n";
	$H = IN;
#print LOG "READING H from IN<br>";
    }

} elsif (!@ARGV) {
    if (-t STDIN) {
      print <<EOF
You did not give a command on the command line nor a -f flag and
the program is running interactively (e.g. reading from terminal).
This is not supported.  Exiting
EOF
    ;
        exit 1;
    }

    $H = STDIN;
}

#
# get auth info
#
if ($opt_a) {
#open (LOG,">/tmp/monlog");
    if ($opt_l) {
    	$USER = $opt_l;
#print LOG "USER READ FROM -l OPTION =$USER\n";
    } else {
	die "could not determine username\n"
	    unless defined ($USER = getpwuid($EUID));
#print LOG "USER DEFAULT TAKEN=$USER\n";
    }

    if (-t STDIN) {
#print LOG "READING PASSWD FROM STDIN\n";
	system "stty -echo";
	print "Password: ";
	chop ($PASS = <STDIN>);
	print "\n";
	system "stty echo";
	die "invalid password\n" if ($PASS =~ /^\s*$/);

    } elsif (!@ARGV) {
	$cmd = <$H>;
#print LOG "READING CMD FROM $H\n";
#print LOG "CMD:$cmd\n";
	while (defined ($cmd) && $cmd =~ /user=|pass=/i) {
	#while (defined ($cmd) && $cmd =~ /user|pass/i) {
	    chomp $cmd;
#print LOG "CMD AFTER CHOMP:$cmd\n";
	    if ($cmd =~ /^user=(\S+)$/i) {
		$USER=$1 if (!defined ($USER));
#print LOG "READING USER FROM $H:$USER\n";
	    } elsif ($cmd =~ /^pass=(\S+)$/i) {
		$PASS=$1;
#print LOG "READING PASSWD FROM $H:$PASS\n";
	    }
	    
	    $cmd = <$H>;
	    $cmd1=$cmd;	
#print LOG "FINAL CMD: $cmd\n";
	}

    }
     
    die "inadequate authentication information supplied\n"
    	if ($USER eq "" || $PASS eq "");
}

#
# set up TCP socket
#
$iaddr = inet_aton ($MONSERVER) ||
	die "Unable to find server '$MONSERVER'\n";

if ($MONPORT =~ /\D/) { $MONPORT = getservbyname ($MONPORT, 'tcp') }
$paddr = pack_sockaddr_in ($MONPORT, $iaddr);
$proto = getprotobyname ('tcp');

socket (MON, PF_INET, SOCK_STREAM, $proto) ||
    die "could not create socket: $!\n";
connect (MON, $paddr) ||
    die "could not connect: $!\n";

select (MON); $| = 1; select (STDOUT);

#if( defined(my $line = <MON>)) {
#    chomp $line;
#    unless( $line =~ /^220\s/) {
#	die "didn't receive expected welcome message\n";
#    }
#} else {
#    die "error communicating with mon server: $!\n";
#}

#
# authenticate self to the server if necessary
#
if ($opt_a) {
    ($l, @out) = do_cmd(MON, "login $USER $PASS");
    die "Could not authenticate\n"
	if ($l =~ /^530/);
}


if ($opt_f or !@ARGV) {
    #$cmd = <$H> if ($opt_f || !@ARGV);
    $cmd = (<$H>||$cmd1) if ($opt_f || !@ARGV);
    $l = "";
#print LOG "ENTERING TO SEND THE CMD:$cmd\n";
    while (defined ($cmd) && defined ($l)) {
	#
	# send the command
	#
	chomp $cmd;
#print LOG "SENDING THE CMD:$cmd\n";
	($l, @out) = do_cmd (MON, $cmd);
	last if (!defined ($l));
	for (@out) {
	    print "$_\n";
	}
	print "$l\n";

	$cmd = <$H>;
    }
    close ($H);

} else {
    ($l, @out) = do_cmd (MON, "@ARGV");
    for (@out) {
	print "$_\n";
    }
    print "$l\n";
}

#
# log out
#
do_cmd (MON, "quit");

close(MON);

#close(LOG);

#
# submit a command to the server, wait for a response
#
sub do_cmd {
    my ($fd, $cmd) = @_;
    my ($l, @out);

    return ("", undef) if ($cmd =~ /^\s*$/);

    @out = ();
    print $fd "$cmd\n";
#print LOG "SUBMITTING CMD:$cmd\n";
    while (defined($l = <$fd>)) {
        chomp $l;
        if ($l =~ /^(\d{3}\s)/) {
            last;
        }
        push (@out, $l);
    }

    ($l, @out);
}


#
# usage
#
sub usage {
    print <<EOF;

usage: moncmd [-a] [-l login] [-s host] [-p port] [-f file] commands

Valid commands are:
    quit
    reset [stopped]
    term
    list group "groupname"
    list disabled
    list alerthist
    list failurehist
    list successes
    list failures
    list opstatus
    list pids
    list watch
    stop
    start
    loadstate
    savestate
    set "group" "service" "variable" "value"
    get "group" "service" "variable"
    disable service "group" "service"
    disable host "host" ["host"...]
    disable watch "watch"
    enable service "group" "service"
    enable host "host" ["host"...]
    enable watch "watch"
EOF
    exit 0;
}


#
# signal handler
#
sub handle_sig {
    system "stty echo";
    exit;
}

Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
CHANGELOG File 113 B 0644
README File 287 B 0644
backup_config.pl File 732 B 0755
config File 201 B 0644
config-Fedora-Linux File 189 B 0644
config.info File 362 B 0644
config.info.ca File 397 B 0644
config.info.cs File 375 B 0644
config.info.de File 429 B 0644
config.info.es File 399 B 0644
config.info.nl File 420 B 0644
config.info.no File 381 B 0644
config.info.ru File 506 B 0644
config.info.uk File 511 B 0644
create_watch.cgi File 281 B 0755
edit_auth.cgi File 1.43 KB 0755
edit_global.cgi File 2.01 KB 0755
edit_service.cgi File 8.05 KB 0755
edit_user.cgi File 1.38 KB 0755
edit_watch.cgi File 2.21 KB 0755
feedback_files.pl File 113 B 0755
index.cgi File 1.52 KB 0755
install_check.pl File 329 B 0755
list_groups.cgi File 832 B 0755
list_periods.cgi File 2.09 KB 0755
list_users.cgi File 1.03 KB 0755
list_watches.cgi File 1.26 KB 0755
module.info File 181 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 108 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 136 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 166 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 171 B 0644
module.info.ca File 117 B 0644
module.info.ca.auto File 13 B 0644
module.info.cs File 37 B 0644
module.info.cs.auto File 86 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 108 B 0644
module.info.de File 111 B 0644
module.info.de.auto File 12 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 192 B 0644
module.info.es File 32 B 0644
module.info.es.auto File 91 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 121 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 168 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 105 B 0644
module.info.fr File 0 B 0644
module.info.fr.auto File 126 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 136 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 119 B 0644
module.info.hu File 0 B 0644
module.info.hu.auto File 122 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 121 B 0644
module.info.ja File 0 B 0644
module.info.ja.auto File 160 B 0644
module.info.ko File 0 B 0644
module.info.ko.auto File 138 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 141 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 128 B 0644
module.info.ms File 105 B 0644
module.info.ms.auto File 12 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 132 B 0644
module.info.nl File 28 B 0644
module.info.nl.auto File 89 B 0644
module.info.no File 31 B 0644
module.info.no.auto File 82 B 0644
module.info.pl File 0 B 0644
module.info.pl.auto File 112 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 122 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 131 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 128 B 0644
module.info.ru File 38 B 0644
module.info.ru.auto File 154 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 122 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 113 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 117 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 255 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 123 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 214 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 158 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 155 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 121 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 130 B 0644
mon-lib.pl File 8.96 KB 0755
mon.cgi File 998 B 0755
mon_action.cgi File 415 B 0755
moncmd.diff File 2.52 KB 0644
moncmd.pl File 5.66 KB 0755
monshow.cgi File 564 B 0755
monshowrc File 166 B 0644
restart.cgi File 180 B 0755
save_auth.cgi File 625 B 0755
save_global.cgi File 1.7 KB 0755
save_groups.cgi File 656 B 0755
save_periods.cgi File 1.11 KB 0755
save_service.cgi File 4.71 KB 0755
save_user.cgi File 823 B 0755
save_watch.cgi File 370 B 0755
start.cgi File 226 B 0755
stop.cgi File 423 B 0755