Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: curl постинг на phpbb
Форумы портала PHP.SU » » Работа с сетью » curl постинг на phpbb

Страниц (1): [1]
 

1. intertrey - 21 Июня, 2011 - 09:13:56 - перейти к сообщению
Добрый день! Подскажи коллеги может кто сталкивался, с такой фигней.
Есть форум на движке phpbb у него видимо какие то защитные функции включены касающиеся сида сессии... не магу запостить сообщение выдает "Invalid Session. Please resubmit the form"

ФУКНЦИИ ДЛЯ ПОСТИНГА ВЫНЕСЕНЫ В ОТДЕЛЬНУЮ БИБЛИОТЕКУ
CODE (text):
скопировать код в буфер обмена
  1.  
  2. function post_content ($url,$postdata,$referer = FALSE,$head = FALSE,$proxy = FALSE,$auth = FALSE,$red = FALSE) {
  3.          
  4.           $uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
  5.            
  6.           $ch = curl_init( $url );
  7.           curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
  8.           curl_setopt($ch, CURLOPT_URL, $url);
  9.           curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
  10.           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11.           curl_setopt($ch, CURLOPT_HEADER, 1);
  12.           curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
  13.           curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  14.           curl_setopt($ch, CURLOPT_ENCODING, "");
  15.           curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
  16.           curl_setopt($ch, CURLOPT_TIMEOUT, 150);
  17.           curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  18.           curl_setopt($ch, CURLOPT_AUTOREFERER, 1);        
  19.           curl_setopt($ch, CURLOPT_POST, 1);
  20.           curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);  
  21.           curl_setopt($ch, CURLOPT_COOKIEJAR, (dirname(__FILE__))."/coo.txt");
  22.           curl_setopt($ch, CURLOPT_COOKIEFILE,(dirname(__FILE__))."/coo.txt");
  23.            if($red){
  24.               curl_setopt($ch, CURLOPT_MAXREDIRS, $red);
  25.            }
  26.        
  27.           if($referer){
  28.                 curl_setopt($ch, CURLOPT_REFERER,$referer);
  29.             }
  30.            
  31.           if($head){
  32.                 curl_setopt($ch, CURLOPT_HTTPHEADER,$head);
  33.             }
  34.          
  35.           if($proxy == TRUE){ curl_setopt($ch, CURLOPT_PROXY, trim($proxy));}  
  36.                
  37.           if($auth == TRUE){curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$auth");}    
  38.        
  39.           $content = curl_exec( $ch );
  40.           $err     = curl_errno( $ch );
  41.           $errmsg  = curl_error( $ch );
  42.           $header  = curl_getinfo( $ch );
  43.           curl_close( $ch );
  44.          
  45.           unset($postdata);
  46.           $header['errno']   = $err;
  47.           $header['errmsg']  = $errmsg;
  48.           $header['content'] = $content;
  49.           return $header;
  50.         }    
  51.  
  52.  

НЕПОСРЕДСТВЕННО САМ ПОСТИНГ
CODE (text):
скопировать код в буфер обмена
  1.  
  2. function index(){
  3.         set_time_limit(0);
  4.         //собираются некоторые данные для постинга из базы
  5.         $datapost = $this->lib_parser->textPost(TRUE,'pagePornbb',$cat = FALSE,'linkTn2',FALSE,TRUE);
  6.         $title   = $datapost['title'];
  7.         $message = $datapost['content'];
  8.         $nobr    = $datapost['nobr'];
  9.         $this->lib_parser->zb_text($nobr);
  10.  
  11.           $postdata = 'username=ЛОГИН&password=ПАСС&autologin=on&redirect=&login=Log+in';
  12.           $referer = 'http://www.pornbb.org/';
  13.          
  14.           $url = 'http://www.pornbb.org/login.php'; //ссылка на форму куда логинимся
  15.          
  16.           $mainpost = post_content($url,$postdata,$referer); //запрос на авторизацию
  17.        
  18.           //из заголовкой вытаскиываю нужный мне сид
  19.           preg_match('|(?<=phpbb2mysql_sid=)([^\<]+)(?=;)|',$mainpost['content'] ,$sid);
  20.           $sid = $sid[0];
  21.           //echo $sid.'<br>';
  22.          
  23.  
  24.           sleep(30);// может быть задержка поможет, где то читал...
  25.           $url2 = 'http://www.pornbb.org/posting.php?sid='.$sid;//куда будем передавать пост запрос для размещения инфы
  26.           $ref2 = 'http://www.pornbb.org/posting.php?mode=reply&t='.$sid; //с какой страницы пришли и с каким сидом      
  27.  
  28.           $head2 = array('Expect:');  //без заголовка хоть какого нить не работает)        
  29.                        $postdata2 = array(
  30.                            'addbbcode20' => '%23444444',
  31.                            'addbbcode22' => '12',
  32.                            'message' => $message,
  33.                            'subject' => $title,
  34.                            'addbbcode22' => '0',
  35.                            'post_icon' => '0',
  36.                            'mode' => 'reply',
  37.                            'sid' => $sid,
  38.                            'post' =>'Submit',
  39.                            't' =>'5071455'
  40.                             );      
  41.      
  42.       //постим
  43.               $mainpost2 = post_content($url2,$postdata2,$ref2,$head2,FALSE,FALSE,$red = 0);
  44.         //видим что не очень всё хорошо  
  45.              var_dump($mainpost2);
  46.  


У кого находил, что бывает помогает паузу поставить между авторизацией и постингом.
Причем примерно аналогичным постером, создавал посты уже на форумах серий phpbb
Куда копать подскажите? Хм
Разъясните мне про
не совсем понимаю как она точно работает...
2. Давит - 21 Июня, 2011 - 09:23:00 - перейти к сообщению
intertrey пишет:
Разъясните мне про
PHP:
скопировать код в буфер обмена

curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);

не совсем понимаю как она точно работает...



http://www.php.su/functions/?curl_setopt
3. intertrey - 21 Июня, 2011 - 10:08:07 - перейти к сообщению
Давит пишет:
intertrey пишет:
Разъясните мне про
PHP:
скопировать код в буфер обмена

curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);

не совсем понимаю как она точно работает...



http://www.php.su/functions/?curl_setopt


Извините, но вы сами то туда заходили?
COOKIESESSION там нет про сессии
4. OrmaJever - 21 Июня, 2011 - 10:17:08 - перейти к сообщению
Я в том году делал флудилку для ~3.0.x, смотреть и править не охота, просто выложу весь скрипт там может разберётесь Подмигивание
PHP:
скопировать код в буфер обмена
  1. <?
  2. //############### Setings ###################//
  3. $login = '';                                                                                    // Логин на форуме
  4. $password = '';                                                                         // Пароль на форуме
  5. $number = 100;                                                  // Сколько постов нужно нафлудить?
  6. $link = 'http://site.ru/forum/';                                        // Ссылка на форум
  7. $f = 3;  $t = 19;                                               // Номер радела и темы узнать можно из ссылки viewtopic.php?f=3&t=19 -> $f=6 a $t=5494
  8. $time = 10;                                                     // Время между постами в секундах (на версиях 3.x стоит около 5 сек)
  9. $message = 'flud!';                                                                                     // Тект поста
  10.  
  11. //############### Setings ###################//
  12.  
  13.  
  14. function curl($url='', $post='', $referer='', $proxy='')
  15.     {
  16.         $cl = curl_init();
  17.         curl_setopt($cl, CURLOPT_URL, $url);
  18.         curl_setopt($cl, CURLOPT_RETURNTRANSFER,1);
  19.         curl_setopt($cl, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.2.15 Version/10.10');
  20.         curl_setopt($cl, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
  21.         curl_setopt($cl, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
  22.         if(!empty($post)) {curl_setopt($cl, CURLOPT_POST, 1); curl_setopt($cl, CURLOPT_POSTFIELDS, $post);}else{curl_setopt($cl, CURLOPT_POST, 0);}
  23.         if(!empty($referer)){curl_setopt($cl, CURLOPT_REFERER, $referer);}else{curl_setopt($cl,CURLOPT_REFERER, 1);}
  24.         if(!empty($proxy)) {curl_setopt($cl, CURLOPT_PROXY, $proxy);}
  25.         $ex=curl_exec($cl);
  26.         curl_close($cl);
  27.         return $ex;
  28.     }
  29.  
  30.    $x = curl($link.'ucp.php?mode=login');
  31.    preg_match('#[a-z0-9]{32}#i',$x, $sid);
  32.    curl($link.'ucp.php?mode=login', 'username='.$login.'&password='.$password.'&redirect=index.php&sid='.$sid[0].'&login=Вход');
  33.  
  34.    for($i=0;$i<$number;$i++)
  35.    {
  36.        $x = curl($link.'posting.php?mode=reply&f='.$f.'&t='.$t);
  37.        preg_match('#[a-z0-9]{40}#i',$x, $token);
  38.        preg_match('#\d{10}#i',$x, $tm);
  39.        preg_match('#[a-z0-9]{32}#i',$x, $sid);
  40.        preg_match('#(?<=name="topic_cur_post_id"\svalue=")\d{6}#i',$x, $post_id);
  41.        curl($link.'posting.php?mode=reply&f='.$f.'&sid='.$sid[0].'&t='.$t, 'icon=0&subject=flud&addbbcode20=100&message='.$message.'&topic_cur_post_id='.$post_id[0].'&post=Отправить&attach_sig=on&creation_time='.$tm[0].'&form_token='.$token[0], $link.'posting.php?mode=reply&f='.$f.'&t='.$t);
  42.        sleep($time);
  43.    }
  44.  
  45. ?>
5. intertrey - 21 Июня, 2011 - 13:32:38 - перейти к сообщению
OrmaJever пишет:
Я в том году делал флудилку для ~3.0.x, смотреть и править не охота, просто выложу весь скрипт там может разберётесь Подмигивание
PHP:
скопировать код в буфер обмена
  1. <?
  2. //############### Setings ###################//
  3. $login = '';                                                                                    // Логин на форуме
  4. $password = '';                                                                         // Пароль на форуме
  5. $number = 100;                                                  // Сколько постов нужно нафлудить?
  6. $link = 'http://site.ru/forum/';                                        // Ссылка на форум
  7. $f = 3;  $t = 19;                                               // Номер радела и темы узнать можно из ссылки viewtopic.php?f=3&t=19 -> $f=6 a $t=5494
  8. $time = 10;                                                     // Время между постами в секундах (на версиях 3.x стоит около 5 сек)
  9. $message = 'flud!';                                                                                     // Тект поста
  10.  
  11. //############### Setings ###################//
  12.  
  13.  
  14. function curl($url='', $post='', $referer='', $proxy='')
  15.     {
  16.         $cl = curl_init();
  17.         curl_setopt($cl, CURLOPT_URL, $url);
  18.         curl_setopt($cl, CURLOPT_RETURNTRANSFER,1);
  19.         curl_setopt($cl, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.2.15 Version/10.10');
  20.         curl_setopt($cl, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
  21.         curl_setopt($cl, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
  22.         if(!empty($post)) {curl_setopt($cl, CURLOPT_POST, 1); curl_setopt($cl, CURLOPT_POSTFIELDS, $post);}else{curl_setopt($cl, CURLOPT_POST, 0);}
  23.         if(!empty($referer)){curl_setopt($cl, CURLOPT_REFERER, $referer);}else{curl_setopt($cl,CURLOPT_REFERER, 1);}
  24.         if(!empty($proxy)) {curl_setopt($cl, CURLOPT_PROXY, $proxy);}
  25.         $ex=curl_exec($cl);
  26.         curl_close($cl);
  27.         return $ex;
  28.     }
  29.  
  30.    $x = curl($link.'ucp.php?mode=login');
  31.    preg_match('#[a-z0-9]{32}#i',$x, $sid);
  32.    curl($link.'ucp.php?mode=login', 'username='.$login.'&password='.$password.'&redirect=index.php&sid='.$sid[0].'&login=Вход');
  33.  
  34.    for($i=0;$i<$number;$i++)
  35.    {
  36.        $x = curl($link.'posting.php?mode=reply&f='.$f.'&t='.$t);
  37.        preg_match('#[a-z0-9]{40}#i',$x, $token);
  38.        preg_match('#\d{10}#i',$x, $tm);
  39.        preg_match('#[a-z0-9]{32}#i',$x, $sid);
  40.        preg_match('#(?<=name="topic_cur_post_id"\svalue=")\d{6}#i',$x, $post_id);
  41.        curl($link.'posting.php?mode=reply&f='.$f.'&sid='.$sid[0].'&t='.$t, 'icon=0&subject=flud&addbbcode20=100&message='.$message.'&topic_cur_post_id='.$post_id[0].'&post=Отправить&attach_sig=on&creation_time='.$tm[0].'&form_token='.$token[0], $link.'posting.php?mode=reply&f='.$f.'&t='.$t);
  42.        sleep($time);
  43.    }
  44.  
  45. ?>




Я попробовал как у тебя сделано, тоесть ты
1. сначала в "холостую подцепляешся к странице которая производит авторизацию" ucp.php?mode=login
2. Выдираешь сид регуляркой
PHP:
скопировать код в буфер обмена
  1. preg_match('#[a-z0-9]{32}#i',$x, $sid);

причем если посмотреть заголовки

CODE (htmlphp):
скопировать код в буфер обмена
  1. array(24) { ["url"]=> string(31) "http://www.pornbb.org/index.php" ["content_type"]=> string(9) "text/html" ["http_code"]=> int(200) ["header_size"]=> int(812) ["request_size"]=> int(1200) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(1) ["total_time"]=> float(0.563) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(8325) ["speed_download"]=> float(14786) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.344) ["redirect_time"]=> float(0.219) ["certinfo"]=> array(0) { } ["errno"]=> int(0) ["errmsg"]=> string(0) "" ["content"]=> string(58419) "HTTP/1.1 302 Found Set-Cookie: phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22e46630b69a3f249fe065ae14db46412d%22%3Bs%3A6%3A%22userid%22%3Bi%3A32126%3B%7D; expires=Wed, 20-Jun-2012 10:10:50 GMT; path=/ Set-Cookie: phpbb2mysql_sid=dfa1257b2e7ed9990321495a96920a37; path=/ Location: http://www.pornbb.org/index.php Content-Type: text/html Content-Length: 0 Date: Tue, 21 Jun 2011 10:10:50 GMT Server: Apache 2.2 Via: 1.1 1-5e48ad2cdbda4 Proxy-Connection: Close HTTP/1.1 200 OK Cache-Control: private, pre-check=0, post-check=0, max-age=0 Expires: 0 Pragma: no-cache Content-Encoding: gzip Vary: Accept-Encoding Content-Type: text/html Transfer-Encoding: chunked Date: Tue, 21 Jun 2011 10:10:50 GMT Server: Apache 2.2 Via: 1.1 1-5e48ad2cdbda4 Proxy-Connection: Close


То из твоей регулярки у меня выдирается 22e46630b69a3f249fe065ae14db4641 выражение, хотя наверное же сид должен быть ? Set-Cookie: phpbb2mysql_sid=dfa1257b2e7ed999 0321495a96920a37 вот же тут...

3.Далее идёт авторизация, где в редиректе указывается, что мы типа пришли с главной страницы с нужным нам сидом

4.Теперь задача вытащить данные из reply тоесть у тебя токен и тоже сид,( который нам нужен непосредствено для отправки поста??)
вытаскиваешь так
PHP:
скопировать код в буфер обмена
  1.  preg_match('#[a-z0-9]{40}#i',$x, $token);

Я у себя так
PHP:
скопировать код в буфер обмена
  1.  preg_match('|(?<=name=\"sid\" value=\")([^\<]+)(?=\")|',$mainpost1['content'],$result1);

5. Далее формируем пост запрос и кидаем на съедение курлу...

млин Я пробовал сид и так выдергивать и эдак всё равно пишёт Invalid Session. Please resubmit the form.

Подскажи логику работы а)
6. flisk - 21 Июля, 2011 - 13:33:58 - перейти к сообщению
Я пробовал писать флудер для phpbb2. 1 сообщение отправляет нормально, а дальше вылетает с этой ошибкой сессии, будь она неладна. Если кому интересно - вот код:

CODE (htmlphp):
скопировать код в буфер обмена
  1. <?php
  2. $cook='z:\usr\local\apache\bin\cookie.txt';
  3. @unlink ($cook); /* удаляем файл кук, ибо иначе со "старой" кукой при след. запуске скрипт снова даст ошибку сессии */
  4. function autorize($url, $postdata = "") {
  5.  
  6.        $ch = curl_init();
  7.        curl_setopt($ch, CURLOPT_URL, $url);
  8.        curl_setopt($ch, CURLOPT_HEADER, 1);
  9.        curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox');
  10.        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11.        curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
  12.        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  13.  
  14.        if($postdata) {
  15.          curl_setopt($ch, CURLOPT_POST, 1);
  16.          curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  17.          }
  18.  
  19.        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20.        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  21.  
  22.        $data = curl_exec($ch);
  23.        curl_close($ch);
  24.  
  25.        return $data;
  26.  }
  27.  
  28.  
  29. $url = 'http://forum.ru/login.php';
  30. $postdata = array('username'=>'user', 'password'=>'parol', 'redirect'=>'viewtopic.php?p=32', 'login'=>'true');
  31.  
  32. $response=autorize($url,$postdata);
  33. list ($null, $sid) = explode ("sid=", $response, 2);
  34. list ($sid, $null) = explode (";", $sid, 2);
  35.  
  36. $url = 'http://forum.ru/posting.php';
  37. $postdata = array('message'=>'flood flood flood', 'attach_sig'=>'on', 'mode'=>'reply','sid'=>$sid,'t'=>'4', 'post'=>'%CE%F2%EF%F0%E0%E2%E8%F2%FC');
  38.  
  39. for ($a=3;$a>0;$a--) {
  40. autorize ($url,$postdata);
  41. sleep (3);
  42. }
  43. echo "Gotovo!";
  44. ?>
7. webog - 03 Апреля, 2014 - 17:37:35 - перейти к сообщению
Для Vbulletin есть такой же?
8. OrmaJever - 03 Апреля, 2014 - 17:45:41 - перейти к сообщению
С новым годом. Посмотрите дату публикации последнего сообщения.

 

Powered by ExBB FM 1.0 RC1