Guest User

antigate client perl Coro anyevent

a guest
Jul 5th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.43 KB | None | 0 0
  1. sub AntigateRec
  2. {
  3.     my ($file, $settings) = @_;
  4.     my ($id, $result,$response,$request, $ac_slot);
  5.    
  6.     my $filetype = 'jpeg';
  7.     $filetype = 'gif' if($file=~m/GIF/);
  8.    
  9.    
  10.     $request = POST "", Content_Type => 'form-data', Agent => "Opera/9.80",
  11.     Content =>
  12.              [
  13.                 method       => 'post',
  14.                 key          => $ag_key,
  15.                 file         => [ undef, ('nyan.'.$filetype), Content => $file ],
  16.                 %{{
  17.                     phrase       => 0,
  18.                     regsense     => 0,
  19.                     numeric      => 1,
  20.                     calc         => 0,
  21.                     min_len      => 2,
  22.                     max_len      => 30,
  23.                     is_russian   => 0,
  24.                     max_bid      => 0.001,
  25.                
  26.                     %{ $settings || {} },
  27.                 }}
  28.                
  29.             ];
  30.            
  31.     do{
  32.         http_post 'http://69.39.239.48/in.php',
  33.                 $request->content,
  34.                 timeout => 35,
  35.                 headers => {
  36.                         Host => 'antigate.com',
  37.                         'Content-Type' => $request->header('Content-Type')
  38.                     },
  39.             Coro::rouse_cb;
  40.            
  41.             my ($response) = Coro::rouse_wait;
  42.    
  43.     if($response=~m/ERROR_KEY_DOES_NOT_EXIST/){ print "Invalid anticaptcha key\n"; Coro::AnyEvent::sleep(30000);;}
  44.     if($response=~m/ERROR_WRONG_USER_KEY/){print "ERROR_WRONG_USER_KEY\n"; sleep;}
  45.     if($response=~m/ERROR_NO_SLOT_AVAILABLE/){print "ERROR_NO_SLOT_AVAILABLE\n"; $ac_slot=1;}
  46.     # warn 1;
  47.     if($response=~m/OK\|(.*?)$/){$id = $1; $ac_slot=0;}elsif(!$ac_slot){ print $response; return;}
  48.    
  49.     if($ac_slot){Coro::AnyEvent::sleep(2);} #Если слоты заняты, то спим 3 секунды чтоб не грузить сервер запросами
  50.    
  51.     }while($ac_slot);
  52.    
  53.    
  54.     ###Ждем капчу
  55.     while(1)
  56.     {
  57.  
  58.             http_post 'http://69.39.239.48/res.php?key='.$ag_key.'&action=get&id='.$id,
  59.                 $request->content,
  60.                 timeout => 35,
  61.                 headers => {
  62.                         'Content-Type' => $request->header('Content-Type'),
  63.                         Host => 'antigate.com'
  64.                     },
  65.             Coro::rouse_cb;
  66.            
  67.             my ($response, $headers) = Coro::rouse_wait;
  68.             # print Dumper [($response, $headers)];
  69.            
  70.             if($response=~m/ERROR/){print "Error: $response\n"; sleep;}
  71.            
  72.             if($response=~m/CAPCHA_NOT_READY/)
  73.             {
  74.                 print "Error: captcha not ready, sleeping for 3 seconds\n";
  75.                 Coro::AnyEvent::sleep(3);
  76.             }
  77.             else
  78.             {
  79.                
  80.                 if($response=~m/OK\|(.*?)$/)
  81.                   {
  82.                       return $1;
  83.                   }
  84.                   else { warn $response; warn 'shit' and return ; }  
  85.  
  86.             }
  87.            
  88.     }
  89.    
  90. }
Advertisement
Add Comment
Please, Sign In to add comment