Logging into a secure site that looks for cookies
| From: | Brandon Orther | Date: | Fri, 10 Aug 2001 20:14:29 +0000 |
| Subject: | Logging into a secure site that looks for cookies | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-62212@lists.php.net to get a copy of this message | ||
Hello,
A site needs cookies
I am trying to convert this perl into the same working PHP. If anyone
can help I greatly appreciate it.
------------------------------------------------------------------------
-----------------------------------------------
#!/usr/bin/perl
#
# Part ripped off from Tom Brown, tbrown@baremetal.com
#
my $USERID = "username"; # your reseller id
my $PASS = "password "; # your reseller password
use strict;
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form) ;
use vars qw($opt_d); use Getopt::Std;
getopts('d');
die "Usage: getpw domain_name" unless ($#ARGV == 0);
my $debug = $opt_d;
my ($domain) = @ARGV;
my $HOSTNAME = "somthing.net";
my $URI = "/folder/new.cgi";
my $init_cookie = 'CheckCookie=CheckCookie'; # really should load the
login page my $AGENT = 'baremetal Reconciller'; my $headers =
make_headers( 'User-Agent' => $AGENT, Cookie => $init_cookie );
my ($page, $response, %reply_headers) = post_https($HOSTNAME, 443, $URI,
$headers,
make_form(
'username' => $USERID,
'password' => $PASS,
'action' => 'login'
));
if ($debug)
{
foreach (keys %reply_headers)
{
printf "header: %s: %s\n", $_, $reply_headers{$_};
}
}
my $cookie = $reply_headers{'SET-COOKIE'} or die "can't get auth
cookie!"; print "cookie set to $cookie\n" if ($debug);
$headers = make_headers('User-Agent' => $AGENT, Cookie => $cookie);
($page, $response, %reply_headers)
= post_https($HOSTNAME, 443, $URI, $headers,
"action=send_password&domain=$domain"
);
die "whoa, request failed: $response" unless ($response);
if ($page =~ /password sent/i)
{
print "Password Sent\n";
exit(0);
}
print "Password not sent\n";
exit(1);
------------------------------------------------------------------------
-----------------------------------------------