#!/usr/bin/perl -w print "Content-type: text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use HTTP::Response; use HTTP::Cookies; use LWP::Simple; use LWP::UserAgent; use Net::FTP; use Fcntl qw/:flock :DEFAULT/; BEGIN { $ENV{PATH} = "/usr/bin:/bin:/usr/local/bin"; use CGI::Carp qw(carpout); open(LOG, ">transloader-log.txt"); carpout(*LOG); close(LOG); } $q = new CGI; $tmpfile = $q->param('tmpfile'); # file name here where you come from if ( $ENV{HTTP_REFERER} =~ 'zipper.cgi|search' || !param ) { print < WebZip Transloader

WebZip© Transloader
Anything in BLUE is Optional (not required to be filled in)
EOL $query = new CGI; print $query->startform(-name=>'form'); print start_html(); print $query->textfield(-name=>'url', -default=>$tmpfile, -size=>'39'); print <
FTP Site Directory
Username Rename
Password CHMOD ASCII ?



EOL print $query->endform(); print end_html(); my $counter = 'transloader-counter.txt'; sysopen(COUNT, $counter, O_RDWR|O_CREAT) or die "Can't OPEN data file for READING and WRITING: $!"; flock(COUNT, LOCK_EX) or die "Cannot get an EXCLUSIVE LOCK on data file: $!"; my $num = || 0; chomp $num; $num++; seek(COUNT, 0, 0) or die "can't REWIND to beginning of data file: $!"; truncate(COUNT, 0) or die "can't TRUNCATE data file: $!"; print COUNT "$num\n"; ## Take out the line below if you don't ## want commas in your numbers. 1 while $num =~ s/(.*\d)(\d\d\d)/$1,$2/; ## Take out the next couple of lines ## down to "close COUNT...", if you ## don't want extensions on the end ## of numbers, such as st, nd, rd, ## or th... as in 2nd or 45th. for($num){s/(1[123]|[4-90])$/$1th/ or s/1$/1st/ or s/2$/2nd/ or s/3$/3rd/}; close COUNT or warn $!; print < You are the $num person to visit this page
EOL }else{ $log = 'trans.txt'; $url_script = "$url

"; $fie_script = "$file

"; $dir_script = "$dir

"; $site_script = "$site

"; $user_script = "$user

"; $password_script = "$password

"; $rename_script = "$rename

"; open (LOG, ">>$log"); print LOG $url_script; print LOG $file_script; print LOG $dir_script; print LOG $site_script; print LOG $user_script; print LOG $password_script; print LOG $rename_script; close LOG; else { print < Here are your RESULTS...
EOL $url = param('url'); $file = param('file'); $dir = param('dir'); $site = param('site'); $user = param('user'); $password = param('password'); $rename = param('rename'); $checkbox = param('checkbox'); $chmod = param('chmod'); if (defined($tmpfile)) { $url = $tmpfile }; ### Check Directory Size before allowing file ## In this DIRECTORY is over 20 Megs, disallow and abort use File::Find; my $dirsize = 0; my $path = '/home/public_html/'; find (sub {$dirsize += -s ;}, $path); if ($dirsize > 20*1000*1000) { print "



Sorry, but the Work Directory is FULL right now. Please try again later.
\n"; exit; }; ### Prevent copying of my files if ( $url =~ /^\./ ) { die "LOL... You cannot copy my files... Goodbye!"}; ### Check the File Size before allowing ### In the FILE is over 1 Meg, disallow and abort $urlsize = get $url; $urlsize = length($url); print "$urlsize
"; if ( $urlsize[1] > 1000*1000 ) { print "

Your URL file is $urlsize[1] bytes. Sorry, but files larger than 1 Meg are not allowed at this time.
\n"; exit; }; ($file = $url) =~ s/^.*?\/([^\/]*?)$/$1/; ## This is where we grab the URL and ## store it in wkdir/$file my ($err_msg, $data) = &bypass($url); if ($err_msg) {print "
$err_msg\n"; exit; } elsif (open(TFILE, ">wkdir/$file")) { print TFILE $data; close(TFILE); } else {print "Error: could not saved retrieved data - $!.\n"; } sub bypass { my ($url) = @_; my $data = ''; my $err_msg = ''; Err: { my $url_data = $url; my $url_html = $url; $url_html =~ s!/([^/]*)$!/!o; # strip to folder my $request = (); my $response = (); # Make initial request to the first page. This makes things # "look good" to any smart observers on the far side. We also # catch the first cookie and persist it: my $ua = new LWP::UserAgent; my $headers = new HTTP::Headers; my $cookie_jar = new HTTP::Cookies; # Simulate IE 5.5 browser: $ua->agent( 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' ); $headers->header( 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT-ENCODING' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,ko;q=0.7,ja;q=0.3', 'HTTP_CONNECTION' => 'close', ); $headers->referer($url); # Request initial HTML page: $request = new HTTP::Request( 'GET' => $url_html, $headers ); $response = $ua->request( $request); $cookie_jar->extract_cookies( $response ); unless ($response->is_success()) { $err_msg = $response->error_as_HTML(); next Err; } # Request follow-up page, using simulated REFERER and cookies: $headers->header('HTTP_REFERER' => $url_html ); $request = new HTTP::Request('GET' => $url_data, $headers ); $cookie_jar->add_cookie_header( $request ); $response = $ua->request( $request ); $cookie_jar->extract_cookies( $response ); unless ($response->is_success()) { $err_msg = $response->error_as_HTML(); next Err; } $data = $response->content(); last Err; } return ($err_msg, $data); }; # open a connection and log in to FTP site $ftp = Net::FTP->new("$site") or print "Cannot CONNECT to Remote Server... $!\n" and exit; print $ftp->message; print "
"; $ftp->login("$user", "$password") or print "You have entered the WRONG Username or Password...$!\n" and exit; print $ftp->message; print "
"; # MAKE the directory on the ftp site # just in case it doesn't exist $ftp->mkdir("$dir", RECURSIVE) unless($dir eq ""); # change directory if ($dir ne "") {$ftp->cwd("$dir") or print "Cannot CHANGE DIRECTORIES to $dir...$!\n" and exit; print $ftp->message}; print "
"; # set transfer mode if ($checkbox) { $ftp->ascii() or print "Cannot change to ASCII Mode... $!\n" and exit } else {$ftp->binary() or print "Cannot change to BINARY Mode...$!\n" and exit}; print $ftp->message; print "
"; $ftp->put("wkdir/$file", "$file") or print "Cant PUT files on server...$!\n" and exit; print $ftp->message; print "
"; if ($rename ne "") { $ftp->rename("$file", "$rename") or print "Cannot RENAME that file...$!\n" and exit; $rsize = $ftp->size("$rename"); if ($chmod ne "") { $ftp->quot("site chmod 0$chmod", $rename) or print "CANT CHMOD: $!\n"; print "
$rename has been chmodded to 0$chmod
\n"; }; print "$rename ($rsize bytes) has been moved.
\n" } else { $fsize = $ftp->size("$file"); if ($chmod ne "") { $ftp->quot("site chmod 0$chmod", $file) or print "CANT CHMOD: $!\n"; print "
$file has been chmodded to 0$chmod
\n"; }; print "$file ($fsize bytes) has been moved.
\n" }; $ftp->quit or print "Cannot CLOSE connection...$!\n" and exit; print $ftp->message; print ""; }; END { if( defined($file)) { unlink "wkdir/$file" } }