| Zentara 2006-10-13, 7:56 am |
| On Thu, 12 Oct 2006 06:03:51 -0400, knightmerc@yahoo.com (Lyvim Xaphir)
wrote:
>Hello everyone. I'm looking for a perl script that utilizes
>Crypt:SSLeay to log in to an https server with a name and password.
>Does anyone know where to find sample scripts like that?
>
>Thanks in advance
>
>LX
Here is one that might fit your needs.
This uploads a file, to https, and logs in
with http access.
Just remove the authorization line, or
change the request to a GET or whatever,
to get a static page.
#!/usr/bin/perl
use warnings;
use strict;
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common qw(POST);
my $https_url =
'https://zentara.zentara.net/~zentara/cgi-bin/uploads/up1.cgi';
my $https_user = 'zentara';
my $https_pass = 'foobar';
my $file = 'testout.tgz';
&postHTTPS();
sub postHTTPS
{
my $ua = new LWP::UserAgent;
$ua->protocols_allowed( [ 'https'] );
$ua->cookie_jar(HTTP::Cookies->new(file
=>".cookies.txt",autosave => 1));
#setup request
my $req = POST($https_url,
Content_Type => 'multipart/form-data',
Content =>[
file =>[ $file ],
], );
#setup auth
$req->authorization_basic($https_user, $https_pass);
#do post
my $response = $ua->request($req);
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
print "$content\n";
}
if ( $response->is_success ) {
print $response->as_string;
}else {
print $response->status_line;
}
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
|