Home: Perl Programming Help: Beginner:
perl memory ?



flaq1991
Novice

Nov 3, 2013, 3:29 AM


Views: 2274
perl memory ?

perl have a memory ? or history? I noticed that when my skryp work for more than five minutes to significantly slows... or is it any way?


Laurent_R
Veteran / Moderator

Nov 3, 2013, 10:46 AM


Views: 2267
Re: [flaq1991] perl memory ?

It depends on what your script is doing.

Perl can run as fast after an hour as during the first 10 seconds, but if you are constantly loading things into memory, it might become slower and slower to retrieve the data.

I can't say more without seeing what your script is doing.


flaq1991
Novice

Nov 3, 2013, 11:46 PM


Views: 2256
Re: [Laurent_R] perl memory ?

this code search a correctly login in my test php script. Thanks for reply.


Code
#!/usr/bin/perl 

use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)");
Start();


print "Wybierz plik : ";
$plik = <>;
open(FILE, $plik) or die("Nie moge otworzy&#263; pliku.\n");
my @lista = <FILE>;
close(FILE);
foreach $hasla (@lista)
{
$hasla =~ s/^\s+//;
$hasla =~ s/\s+$//;

unless($hasla =~ m/(.*?):(.*?)(\ |$)/g){next;}
my $uzytkownik = $1;
my $haslo = $2;

powtorz:
print "Login: $uzytkownik\nHaslo: $haslo\n\n";

$ua->default_headers->push_header('Referer' => 'http://127.0.0.1/test.php');
my $response = $ua->post( "http://127.0.0.1/test.php", {"account_login" => $uzytkownik, "password_login" => $haslo });
if ($response->is_success) {

if ($response->content =~ m/login failed/i) {
print "login not found\n\n";
}
else
{
print "login found\n\n";
open(FILE, ">>working.txt");
print FILE "$hasla\n";
close(FILE);
}
sub Start() {
system(cls);
print "\n\n"
}
}
}



Zhris
Enthusiast

Nov 4, 2013, 12:51 AM


Views: 2250
Re: [flaq1991] perl memory ?

I shouldn't really be helping because others have pointed out that this appears to be a script designed to brute force login to a website. But heres some pointers since you already have your code up and running...

1) You probably don't want to keep setting the referrer header per iteration.

2) Don't pull the entire file into an array. Read it line by line.

Chris


flaq1991
Novice

Nov 4, 2013, 12:29 PM


Views: 2230
Re: [Zhris] perl memory ?

the point is?

Code
 print "Login: $uzytkownik\nHaslo: $haslo\n\n";


Edit : now it works! thank you all for helping me :)


(This post was edited by flaq1991 on Nov 4, 2013, 2:18 PM)