File: //scripts.20110531.215904.25158/ftpput
#!/usr/bin/perl
# cpanel - ftpput Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use strict;
use Socket;
use Cpanel::HttpRequest;
my $httpClient = Cpanel::HttpRequest->new( 'hideOutput' => 0 );
chdir "/scripts";
my $host = $ARGV[0];
my $user = $ARGV[1];
my $pass = <STDIN>;
$pass =~ s/\n//g;
alarm(200);
use Net::FTP;
open( STDERR, ">&STDOUT" );
my $ftp = Net::FTP->new( "$host", Debug => 1 );
$ftp->login( $user, $pass );
$ftp->put("pkgacct.static");
$ftp->site("chmod 755 pkgacct.static");
$ftp->mkdir( "public_html/cgi-bin/cpdownload", 1 );
$ftp->site("chmod 755 public_html/cgi-bin/cpdownload");
$ftp->cwd("public_html/cgi-bin/cpdownload");
$ftp->put("cpanelwrap.c");
$ftp->put("cpanelwrap.cgi");
$ftp->put("cpaneldownload.cgi");
$ftp->put("cpaneldownacct.cgi");
$ftp->site("chmod 755 cpanelwrap.cgi");
$ftp->site("chmod 755 cpaneldownacct.cgi");
$ftp->site("chmod 755 cpaneldownload.cgi");
my $uid;
my $odebug = '';
my $hassuexec = 0;
my $script = 'cpanelwrap.cgi';
my @OPTS = ( [ $host, "/~${user}/cgi-bin/cpdownload/${script}?${user}" ], [ $host, "/cgi-bin/cpdownload/${script}?${user}" ] );
foreach my $hoste (@OPTS) {
my ( $host, $url ) = @{$hoste};
my $req = $httpClient->request(
'host' => $host,
'url' => $url,
'protocol' => 0,
);
next if ( $req !~ /UID/ );
foreach ( split( /\n/, $req ) ) {
$odebug .= $_;
if (/MYUID: (\d+)/) {
$uid = $1;
}
if (/REALUID: (\d+)/) {
if ( $1 == $uid ) {
$hassuexec = 1;
}
}
}
last;
}
if ( $uid ne "" ) {
print "Found uid to be: $uid\n";
}
else {
print "Unable to get uid of remote account...\n";
}
$ftp->quit;