Sponsored Content
Top Forums Shell Programming and Scripting Q:Perl Extracting & Printing Security Token Post 302542153 by AndrewTwain on Tuesday 26th of July 2011 10:58:10 PM
Old 07-26-2011
[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:

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";

Just view your page source to find an example of the vB security token while logged in.

Last edited by AndrewTwain; 07-27-2011 at 04:31 AM.. Reason: full source
 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Network Shell Script & Blade Logic & Network Security

I am going to take up a position in Data & Network Security. I would need to write network shell scripts doing the following task: Going to around 2000 servers and findout which groups has access to each servers and which ids are there in each group that has access. I need to implement... (1 Reply)
Discussion started by: pinnacle
1 Replies

2. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

3. Shell Programming and Scripting

Extracting and printing data

Hi I have the following data : <Cell id="34A" ref="ds:/BTS:34/Cells/Cell:34A"/> <Cell id="34B" ref="ds:/BTS:34/Cells/Cell:34B"/> <Cell id="34C" ref="ds:/BTS:34/Cells/Cell:34C"/> I would like to print this data in the following format : BTS:34 Cell:34A.I'm... (9 Replies)
Discussion started by: Prega
9 Replies

4. Emergency UNIX and Linux Support

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: ... (3 Replies)
Discussion started by: AndrewTwain
3 Replies

5. Shell Programming and Scripting

Extracting character between 2 token - using only first match

Hello. ps -ae return I would like that the following command return 3214 echo " 3214 ? 00:00:01 acroread" | grep -o "]]]*" (5 Replies)
Discussion started by: jcdole
5 Replies

6. 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

7. Shell Programming and Scripting

Extracting substring within string between 2 token within the string

Hello. First best wishes for everybody. here is the input file ("$INPUT1") contents : BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY; BASH_FUNC_message_debug%%=() { local -a L_ARRAY; BASH_FUNC_message_end_script%%=() { local -a L_ARRAY; BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
LWP::Protocol::socks(3pm)				User Contributed Perl Documentation				 LWP::Protocol::socks(3pm)

NAME
LWP::Protocol::socks - adds support for the socks protocol and proxy facility SYNOPSIS
use LWP::Protocol::socks; DESCRIPTION
Use this package when you wish to use a socks proxy for your connections. It provides some essential hooks into the LWP system to implement a socks "scheme" similar to http for describing your socks connection, and can be used to proxy either http or https connections. The use case is to use LWP::UserAgent's proxy method to register your socks proxy like so: $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); Then just use your $ua object as usual! EXAMPLES
#!/usr/local/bin/perl use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); # for socks5, use socks like so: $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); # for socks4, use socks4 like so: $ua->proxy([qw(http https)] => 'socks4://socks.yahoo.com:1080'); my $response = $ua->get("http://www.freebsd.org"); print $response->code,' ', $response->message," "; my $response = $ua->get("https://www.microsoft.com"); print $response->code,' ', $response->message," "; NOTES
I don't have much time to contribute to this. If you'd like to contribute, please fork https://github.com/scr/cpan and send me a pull request. AUTHORS
Sheridan C Rawlins <sheridan.rawlins@yahoo.com> Oleg G <oleg@cpan.org> perl v5.14.2 2012-02-12 LWP::Protocol::socks(3pm)
All times are GMT -4. The time now is 11:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy