•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 402,922 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,059 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 4092 | Replies: 4
![]() |
•
•
Join Date: May 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I need to modify this script to have also an external txt file with urls instead of having only one url from the form that is created by the script. Just like the proxy.txt and agents.txt.
Please help me...
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();
}
sub newinfo{
print <<ENDHTML;
<form action=bot.cgi?hitsnow method=post>
URL to send hits to:<input type=text name=url><br>
Refferring URL:<input type=text name=refer><br>
How many hits to send:<input type=text name=howmany><br>
<input type=submit value=Submit></form>
ENDHTML
;
exit;
}
if ($buffer eq 'hitsnow'){
&sendthemhits();
}
sub sendthemhits{
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
for($count=1;$count<$FORM{howmany};$count++){
open(QQ,"$proxy");
@proxies=<QQ>;
close(QQ);
open(WE,"$agents");
@agents=<WE>;
close(WE);
srand;
@run = (0..$number);
$run = rand(@run);
@ug = (0..$nagent);
$ug = rand(@ug);
my $ua = LWP::UserAgent->new(agent => "@agents[$ug[$ug]]" , keep_alive => 1 , timeout => 10);
$ua->proxy('http',"http://@proxies[$run[$run]]");
my $res = HTTP::Request->new( GET => "$FORM{url}");
$res->referer("$FORM{refer}");
my $response= $ua->request($res);
if ($response->is_success){
print "Connection: $count - @proxies[$run[$run]] - Success<br>\n";
}
}
}
Please help me...
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();
}
sub newinfo{
print <<ENDHTML;
<form action=bot.cgi?hitsnow method=post>
URL to send hits to:<input type=text name=url><br>
Refferring URL:<input type=text name=refer><br>
How many hits to send:<input type=text name=howmany><br>
<input type=submit value=Submit></form>
ENDHTML
;
exit;
}
if ($buffer eq 'hitsnow'){
&sendthemhits();
}
sub sendthemhits{
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
for($count=1;$count<$FORM{howmany};$count++){
open(QQ,"$proxy");
@proxies=<QQ>;
close(QQ);
open(WE,"$agents");
@agents=<WE>;
close(WE);
srand;
@run = (0..$number);
$run = rand(@run);
@ug = (0..$nagent);
$ug = rand(@ug);
my $ua = LWP::UserAgent->new(agent => "@agents[$ug[$ug]]" , keep_alive => 1 , timeout => 10);
$ua->proxy('http',"http://@proxies[$run[$run]]");
my $res = HTTP::Request->new( GET => "$FORM{url}");
$res->referer("$FORM{refer}");
my $response= $ua->request($res);
if ($response->is_success){
print "Connection: $count - @proxies[$run[$run]] - Success<br>\n";
}
}
}
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
•
•
Join Date: May 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by Comatose
I'm not 100% sure that I understand what you are asking. I know that you want to use a text file to be read into the script, but what I'm lost at, is are you wanting for the HTML that accepts the URL and number of hits to no longer exist, and have that information be replaced by the text file?
Hello,
Yes that's exactly what I want. Cause I would like better to call this script by cron and have set all those variables in txt files so the script would work when it's called by cron and not when I call it from the browser as it works now.
Thanks for your help and time.
James
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
Ok, The information that the web page retrieves, I need to know what kind of file format they are in. I understand they will be text, but I need to know the format of it, such as:
or will it be something like:
or will they be in different text files, or how is this supposed to work. I can modify the script to work with the text files, but I need to understand how you will have it laid out. Let me know.
url <TAB> referer <TAB> howmany
or will it be something like:
url referer howmany
or will they be in different text files, or how is this supposed to work. I can modify the script to work with the text files, but I need to understand how you will have it laid out. Let me know.
•
•
Join Date: May 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
They'll be in different text files. One URL per line. The "how many hits will be just a number in a txt file let's say for 30 hits per url (i.e. 30).
I need it to run from cron.
Now(the way the script works) I need to call the script http://myurl.com/test.cgi?new to run the script and it waits for user input. I want to be able to upload the txt files and set the script to work lets say every night at 12:00 with a cron command.
Look the start of this code:
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();
Thanks
James
They'll be in different text files. One URL per line. The "how many hits will be just a number in a txt file let's say for 30 hits per url (i.e. 30).
I need it to run from cron.
Now(the way the script works) I need to call the script http://myurl.com/test.cgi?new to run the script and it waits for user input. I want to be able to upload the txt files and set the script to work lets say every night at 12:00 with a cron command.
Look the start of this code:
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();
Thanks
James
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Perl script modification needed... (Perl)
- problem in running perl script (Perl)
- How to modify this perl script and make it running in Linux , solaris and windowXP? (Perl)
- How to call a perl script in the C# app? (C#)
- Create a perl script for string matching (ASP)
- On execution of perl script, popup asks if i want to save or run this file (Linux Servers and Apache)
- Calculate the amount of time in the linux process using perl script (Perl)
Other Threads in the Perl Forum
- Previous Thread: Posting Large amounts of text from Guestbook
- Next Thread: Perl Whitespaces



Linear Mode