Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Perl - Retrieving and Printing Security Token Post 302542483 by AndrewTwain on Wednesday 27th of July 2011 05:57:12 PM
Old 07-27-2011
[Solved] Perl - Retrieving and Printing Security Token

My script below is supposed to log in to my vB account on any vB forum I'm registered on and retrieve + print my security token. However it seems to be hit and miss. The logging in works perfectly just will not retrieve and print the security token for every forum I log in to. Code Below:

Code:
#!/usr/bin/perl
use LWP::UserAgent;

my $ua = LWP::UserAgent->new(agent => q{Mozilla/5.0 (Windows; U;  Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET  CLR 3.5.30729)});
$ua->cookie_jar({});

print("Specify site URL(e.g http://site.com/): ");
chomp(my $url = <>);
print("Username: ");
chomp(my $username = <>);
print("Password: ");
chomp(my $password = <>);

my $req = HTTP::Request->new(POST => $url . '/login.php?do=login');
$req->content_type('application/x-www-form-urlencoded');
$req->content("vb_login_username=$username&vb_login_password=$password&do=login&securitytoken=guest&vb_login_md5password=&vb_login_md5password_utf=&s=");
$ua->request($req);
my $content = $ua->get("$url/index.php")->content;
my ($securityToken) = $content =~ /value="\w{10}-\w{40}" /g;
print "Security token: $securityToken\n";

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl printing error

Hi Scripting Gurus, I am new bee in perl, and trying to write a script which must print the free disk space availability of C and E drives. Please advice. Here is the script snippet and expected output: #!/usr/bin/perl use CGI qw/:html3 :standard/; $spaceuselog =... (4 Replies)
Discussion started by: ccsaviour
4 Replies

2. Shell Programming and Scripting

Need help in printing a sql query in perl

Hi All, I have the following sql query select abcd from udbadm.log where xyz='1'. I have 16k queries similar to this with different values for xyz. I want to print the values of 'abcd' for each row. I have the following perl code, but not sure how i can print that particular... (1 Reply)
Discussion started by: userscript
1 Replies

3. Shell Programming and Scripting

[Perl] Printing - Scalars

Hey Guys, I have some weird problem with printing scalars ... When I'm executing script both are printing in terminal ... But only one is printed to the file ? I don't know whats going on .. :) Btw .. I'm noobie :) took me lots of time to put this simple script together :) Thank you... (3 Replies)
Discussion started by: NDxiak
3 Replies

4. Shell Programming and Scripting

Printing between 2 matches with Perl

Can we please modify this perl one-liner to print lines between pattern1 and pattern2 in a file? Currently it prints lines till pattern2. (4 Replies)
Discussion started by: anand_bh
4 Replies

5. Shell Programming and Scripting

Q:Perl Extracting & Printing Security Token

I have a script which is supposed to log in to my vB account and print my security token, however doesn't seem to work globally. The logging in works perfectly just will not retrieve and print the security token for every forum I log in to. Code Below: #!/usr/bin/perl use LWP::UserAgent; ... (8 Replies)
Discussion started by: AndrewTwain
8 Replies

6. Shell Programming and Scripting

Perl: selective printing of lines

Hi, I have a file with lines like this. 2 7 18 ggcgt anna 2 7 18 hhchc sam 3 7 18 hhdjcc ross 4 7 18 hhcjd jenny 0 8 21 jjdhs sam 3 8 21 kkok bush 2 9 24 kosss BrenhamIf the values of the second column are equal, print only those lines with the least first column value. So in... (5 Replies)
Discussion started by: polsum
5 Replies

7. Shell Programming and Scripting

help with perl database printing

Hey guys i am using perl and trying to pull a list of books from a database and then populate the list in a separate TT2 file. When the list is generated there should be 39 book names. When I do the foreach statement in my tt2 below, the first statement gives me 39 Array(random number) and the... (1 Reply)
Discussion started by: Joey12
1 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Security Token

I got this message while submitting a reply to a thread. I could submitt the replies till yesterday but today it shows me the following message "Your submission could not be processed because a security token was missing." What should I do to resolve this? (1 Reply)
Discussion started by: Akang
1 Replies
HTTP::OAI::UserAgent(3pm)				User Contributed Perl Documentation				 HTTP::OAI::UserAgent(3pm)

NAME
HTTP::OAI::UserAgent - Extension of the LWP::UserAgent for OAI HTTP requests DESCRIPTION
This module provides a simplified mechanism for making requests to an OAI repository, using the existing LWP::UserAgent module. SYNOPSIS
require HTTP::OAI::UserAgent; my $ua = new HTTP::OAI::UserAgent; my $response = $ua->request( baseURL=>'http://arXiv.org/oai1', verb=>'ListRecords', from=>'2001-08-01', until=>'2001-08-31' ); print $response->content; METHODS
$ua = new HTTP::OAI::UserAgent(proxy=>'www-cache',...) This constructor method returns a new instance of a HTTP::OAI::UserAgent module. All arguments are passed to the LWP::UserAgent constructor. $r = $ua->request($req) Requests the HTTP response defined by $req, which is a HTTP::Request object. $r = $ua->request(baseURL=>$baseref, verb=>$verb, %opts) Makes an HTTP request to the given OAI server (baseURL) with OAI arguments. Returns an HTTP::Response object. OAI-PMH related options: from => $from until => $until resumptionToken => $token metadataPrefix => $mdp set => $set $str = $ua->url(baseURL=>$baseref, verb=>$verb, ...) Takes the same arguments as request, but returns the URL that would be requested. $time_d = $ua->delay( $time_d ) Return and optionally set a time (in seconds) to wait between requests. $time_d may be a CODEREF. perl v5.12.4 2011-06-23 HTTP::OAI::UserAgent(3pm)
All times are GMT -4. The time now is 02:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy