Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   Проблема c реггером (https://forum.antichat.xyz/showthread.php?t=72856)

Shadow_p1raT 06.06.2008 17:24

Проблема c реггером
 
Решил написать регеер,но для начала решил потренироваться на локалхосте.
Скачать двиг phpfusion,наколбасил скрипт:
PHP код:

<?php
if($_GET['do']=="register"){
echo 
"<img src=testxak.php?do=1>";
echo 
"<form method=GET>"
echo 
"Капча";
echo 
"<input type=text name=cap>";
echo 
"<input type=submit value=go>";
}
$host="www.test1.ru";
$path="/phpfusion/register.php";
//Грузим страницу
function get($host,$path)

$res=""
$sock=fsockopen($host80$errno$errstr30); 
 if(!
$sock){ 
      echo 
$errstr($errno); 
           }else{ 
    
$headers "GET $path HTTP/1.0\r\n"
    
$headers .="Host: $host\r\n"
    
$headers .="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14\r\n"
    
$headers .="Accept-Language: ru,ru-RU;q=0.9,en;q=0.8\r\n"
    
$headers .="Connection: Close\r\n\r\n"
                } 
fwrite($sock$headers); 
         while(!
feof($sock)){ 
     
$res .=fgets($sock1024); 
                            } 
return 
$res

//Отделяем  куки
function get_ret_cookie($res

  
preg_match_all('/Set-Cookie: (.+);/iUs',$res,$cook); 
  if(!isset(
$cook[1])) return ''

  
$cookies=implode('; ',array_unique($cook[1])); 
  return 
$cookies
}
//Грузим url
function url($res)
{
$preg=preg_match("/value='[0-9a-z]{32,}/",$res,$reg);
$code=$reg[0];
$code=str_replace("value='","",$code);
return 
$code;
}
//Грузим капчу
function get_image($host,$code,$cookies)
{
$fp=fsockopen($host,80,$errnum,$errtxt,30); 

$header ="GET /phpfusion/includes/captcha_include.php?captcha_code=$code HTTP/1.0\r\n"
$header.="Host: test1.ru\r\n"
$header.="Connection: close\r\n";
$header.="Referer: http://www.test1.ru/phpfusion/register.php\r\n";
$header.="Cookie: $cookies\r\n";
$header.="\r\n"
fputs($fp,$header.$vars); 

while(!
feof($fp)) 

  
$ret.=fgets($fp128); 


$ret=substr($ret,strpos($ret,"\r\n\r\n")+4); //убираем заголовки сервера 

header('Content-type: image/png');
return(
$ret); 
}
if(
$_GET['do']==1)
{
$res=get($host,$path);
$cookies=get_ret_cookie($res);
$code=url($res);
$image=get_image($host,$code,$cookies);
echo 
$image;
}
//Отпровляем заголовки 
function post($host,$captha,$cookies,$code)
{
$fp1=fsockopen($host,80,$errnum,$errtxt,30); 
$zapros="username=Shadow&password1=123456789&password2=123456789&email=br1an%40xaker.ru&user_hide_email=0&captcha_encode=$code&captcha_code=$captha&user_location=RU&register=%D0%E5%E3%E8%F1%F2%F0%E0%F6%E8%FF";
$browsers = array ("MSIE 6.0""Mozilla/4.0""Mozilla/5.0""Opera/9.23""MSIE 7.0");
    
$send  "POST /phpfusion/register.php HTTP/1.0\r\n";  
    
$send .= "Host: www.test1.ru\r\n";  
    
$send .= "User-Agent: ".$browsers[rand(0,4)]."\r\n";  
    
$send .= "Referer: http://www.test1.ru/phpfusion/register.php\r\n"
    
$send .= "Cookie: $cookies\r\n";
    
$send .= "Pragma: no-cache\r\n";
    
$send .= "Content-Type: application/x-www-form-urlencoded\r\n";
    
$send .= "Content-Length: ".strlen($zapros)."\r\n"
    
$send .= "Connection: Close\r\n\r\n";
    
$send .= "$zapros";
fputs($fp1,$send); 
while(!
feof($fp1)){ 
$respons=fgets($fp11024); 
echo 
$respons;

return 
$respons
}
if(
$_GET['cap'])
{
$captha=$_GET['cap'];
echo 
post($host,$captha,$cookies,$code);
}
?>

НО в ответ получаю:
Код:

Регистрация не завершена по следующим причинам:

Неверный проверочный код.

В чём ошибка?

Shadow_p1raT 06.06.2008 18:19

Блин,ну помогите please!

BlackSun 06.06.2008 18:26

Если не ошибаюсь, то капча юзает в свих грязных целях сессии ...

Shadow_p1raT 07.06.2008 11:51

Если кому интересно то моя проблема решилась так:
Правильный код.
PHP код:

<?php
if($_GET['do']=="reg")
{
echo 
"<img src=testxak.php?do=1>";
echo 
"<form method=GET>"
echo 
"Капча";
echo 
"<input type=text name=cap>";
echo 
"<input type=submit value=go>";
}
$host="www.test1.ru";
$path="/phpfusion/register.php";
//Грузим страницу
function get($host,$path)

$res=""
$sock=fsockopen($host80$errno$errstr30); 
 if(!
$sock){ 
      echo 
$errstr($errno); 
           }else{ 
    
$headers "GET $path HTTP/1.0\r\n"
    
$headers .="Host: $host\r\n"
    
$headers .="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14\r\n"
    
$headers .="Accept-Language: ru,ru-RU;q=0.9,en;q=0.8\r\n"
    
$headers .="Connection: Close\r\n\r\n"
                } 
fwrite($sock$headers); 
         while(!
feof($sock)){ 
     
$res .=fgets($sock1024); 
                            } 
return 
$res

//Отделяем  куки
function get_ret_cookie($res

  
preg_match_all('/Set-Cookie: (.+);/iUs',$res,$cook); 
  if(!isset(
$cook[1])) return ''

  
$cookies=implode('; ',array_unique($cook[1])); 
  return 
$cookies
}
//Грузим url
function url($res)
{
$preg=preg_match("/value='[0-9a-z]{32,}/",$res,$reg);
$code=$reg[0];
$code=str_replace("value='","",$code);
$handle=fopen("code.txt","wb");
fwrite($handle,$code);
return 
$code;
}
//Грузим капчу
function get_image($host,$code,$cookies)
{
$fp=fsockopen($host,80,$errnum,$errtxt,30); 

$header ="GET /phpfusion/includes/captcha_include.php?captcha_code=$code HTTP/1.0\r\n"
$header.="Host: www.test1.ru\r\n"
$header.="Connection: close\r\n";
$header.="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14\r\n";
$header.="Referer: http://www.test1.ru/phpfusion/register.php\r\n";
$header.="Cookie: $cookies\r\n";
$header.="\r\n"
fputs($fp,$header.$vars); 

while(!
feof($fp)) 

  
$ret.=fgets($fp128); 


$ret=substr($ret,strpos($ret,"\r\n\r\n")+4); //убираем заголовки сервера 

header('Content-type: image/png');
return(
$ret); 
}
if(
$_GET['do']==1)
{
$res=get($host,$path);
$cookies=get_ret_cookie($res);
$code=url($res);
$image=get_image($host,$code,$cookies);
echo 
$image;
}
//Отпровляем заголовки 
function post($host,$captha,$cookies,$file)
{
$name=rand(0,9991413);
$mail=rand(0,783131);

$fp1=fsockopen($host,80,$errnum,$errtxt,30); 
$zapros="username=$name&password1=89133486688&password2=89133486688&email=$mail%40mail.ru&user_hide_email=0&captcha_encode=$file&captcha_code=$captha&user_location=BH&register=%D0%E5%E3%E8%F1%F2%F0%E0%F6%E8%FF";
    
$send  "POST /phpfusion/register.php HTTP/1.0\r\n";  
    
$send .= "Host: www.test1.ru\r\n";  
    
$send .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14\r\n";  
    
$send .= "Referer: http://www.test1.ru/phpfusion/register.php\r\n"
    
$send .= "Cookie: $cookies\r\n";
    
$send .= "Pragma: no-cache\r\n";
    
$send .= "Content-Type: application/x-www-form-urlencoded\r\n";
    
$send .= "Content-Length: ".strlen($zapros)."\r\n"
    
$send .= "Connection: Close\r\n\r\n";
    
$send .= $zapros;
fputs($fp1,$send); 
while(!
feof($fp1)){ 
$respons=fgets($fp11024); 
echo 
$respons;

return 
$respons
}
if(
$_GET['cap'])
{
$file=file_get_contents("code.txt");
$file=trim($file);
$captha=$_GET['cap'];
echo 
post($host,$captha,$cookies,$file);
}
?>

Проблема была в том что финкции post не передовался параметр $code.


Время: 09:07