Q:Perl Extracting & Printing Security Token


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Q:Perl Extracting & Printing Security Token
# 8  
Old 07-28-2011
Yes. With 'Accept-Encoding' => 'gzip,deflate' you get a page in gzip form. I check this with unix.com (I hardcoded the data in the script and change the last line to
Code:
if ($securityToken) {
    print "$securityToken\n";
} else {
    print "$content\n";
}

With
Code:
./script.pl | gunzip -

i can see the content.
I'm checking now how to use IO::Uncopress::Gunzip.

---------- Post updated at 12:37 PM ---------- Previous update was at 12:32 PM ----------

This works but gives me value for unix.com as "guest" - doesn't count my $username and $password.
Code:
use IO::Uncompress::Gunzip 'gunzip';
...

my $content = $ua->get("$url/index.php")->content;
my $gunzipped;
gunzip \$content => \$gunzipped;
$content = $gunzipped;
my $input = $1 if $content =~ /(<input.*?securitytoken.*?>)/m;
my $securityToken = $1 if $input =~ /value="(.*?)"/;
if ($securityToken) {
    print "$securityToken\n";
} else {
    print "$content\n";
}

# 9  
Old 07-28-2011
Thank you Yazu for the help, seems to be stable for now.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

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

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

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

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

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

7. 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
Login or Register to Ask a Question