30 October 2004
This post may be outdated due to it was written on 2004. The links may be broken. The code may be not working anymore. Leave comments if needed.
#!/usr/bin/perl
#Save this code as water.pl
#Usage:perl water.pl
#Author: [email protected]

#use strict;
use LWP::UserAgent;
#use HTTP::Cookies;
#use HTTP::Headers;
use HTTP::Request;
#use HTTP::Response;

#my $brower = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';

my $ua = new LWP::UserAgent;
#$ua->agent($brower);

#my $header = new HTTP::Headers;
#$header->content_type('application/x-www-form-urlencoded');

my $count = 1;
my $sleeptime = 1;

#按 Ctrl+c 退出
while (1) {
  #不重复标题内容的帖
  my $rands = rand(1000);
  #membername 注册的用户名, password 密码
  #forum 论坛id号, intopictitle 标题, inpost 内容
  my $content = 
"action=addnew&forum=1&membername=test&password=testtest&intopictitle=1313s.com-$rands&inpost=1313s.com-$rands";
  #http://192.168.0.44/*/post.cgi为目标地址
  my $request = new HTTP::Request('GET',"http://192.168.0.44/cgi-bin/lb/post.cgi?$content");

  #$header->content_length(length($content));
  #my $request = new HTTP::Request('POST',"http://192.168.0.44/cgi-bin/lb/post.cgi",$header,$content);

  my $response = $ua->request($request);

  #连接不成功,可能目标地址错误或者其他
  if (! $response->is_success) {
    die "failed reason: ", $response->status_line;
  }

  #返回的网页内容中有“成功”
  if ($response->content=~ /成功/) {
    print "success $count";
    $count++;
  }
  #查找灌水机制的时间,并调整 sleep time
  elsif ($response->content =~ /待.+?([0-9]+).+?秒/) {
    $sleeptime = $1;
    print "faied,reason is 灌水预防机制,and we changed the sleep time,Don't worry";
  } else {
    print "faied,reason unkown!";
  }
  #For 灌水预防机制
  print ",wait $sleeptime seconds\n";
  sleep $sleeptime;
}

Special

此代码发布只为研究学习之用,任何人不得用于非法行为。


blog comments powered by Disqus