treasurehuntbob has asked for the wisdom of the Perl Monks concerning the following question:

EXAMPLES: trying to access "tom.com" the REFERER is "bob.com

Im running a script that gains access to "tom.com" by "tricking" the site into thinking im "bob.com" after it runs the script sets the HTTP_COOKIE as follows:

$ENV{HTTP_COOKIE} = "REFERER=http://bob.com; ORIGINID=0; username=VOOOON; password=XfgEdnb48";

I want to extract "take" only the user & password above out of the $ENV variable above and set a cookie for a specific web site "EX: tom.com" so that Iam a authorized user when I type in or redirect to the site "tom.com" without having to use my script ".cgi" or having to manually type the user&pssword combo in at all.

Can this be done; if you respond Iam kinda new please be specific "written" if possible.
  • Comment on http_cookie, cookies, extracting from $ENV variable set cookie question

Replies are listed 'Best First'.
Re: http_cookie, cookies, extracting from $ENV variable set cookie question
by Anonymous Monk on Mar 21, 2001 at 17:07 UTC

    I'm not sure about all the rest, but one old fashioned way to split this cookie that you take is like that: (although I encourage you to use CGI.pm)

    my $cookie = $ENV{'HTTP_COOKIE'}; # if you wanna do this like that. @all = split(/\;/, $cookie); foreach (@all) { ($var, $value) = split(/=/); $values{$var} = $value; }

    now you have a has called %values, from which you can call the username/password :

    my $username = $values{'username'}; my $password = $values{'password'}; # now do whatever you want with them.
    not sure why you're doing this like that though..