Бот за svejo

rotator

Registered
Някой опитвал ли се е да си направи бот за svejo? Смисъл автоматично да добавя статии в самият сайт. Аз пробвах но немога да се логна в самият сайт. Пробвах с cURL но без успех. Ако въведа невалидна информация изкача alert, че е грешна или парола или юзернейм. А при валидна информация ме прехвърля към началната страница. Някой да има идея как да стане този номер да направя успешен логин и да го пуснем като урок тук за всеки който му трябва ?! :) :?:
 
Ако се вгледаш, по внимателно във изходния код на страницата за вход ще забележиш че има едно скрито инпутче.

HTML:
<input name="authenticity_token" type="hidden" value="YkMx3btaAl4U+wArc9SiK9xHAI8LqIT0n7SN7riYTZQ=" />
 
Или пък директно можеш можеш да пробваш така:

<?php

session_start();

$data = array('user[email_or_username]'=>'email_or_username', 'user[password]'=>'password', 'authenticity_token'=>'YkMx3btaAl4U+wArc9SiK9xHAI8LqIT0n7SN7riYTZQ=', 'commit'=>'Влез', 'user[url_referer]'=>'http://svejo.net/popular/all/new');

$ch = curl_init();

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, "http://svejo.net/user/login/");

$result = curl_exec($ch);

echo $result;

curl_close($ch);

?>

Преполагам че въпросното кодче YkMx3btaAl4U+wArc9SiK9xHAI8LqIT0n7SN7riYTZQ= се сменя от време на време :) за това може преди да изпълниш кода просто да вземеш страницата с file_get_contents и съответно да вземеш стойността му.
Мисля че от тук нататък ще се справиш и сам.
 
Добре, и с това не става просто ми пише "you are redirect" или нещо такова, ето някой да се опита да сътвори нещо.

Код:
<?php
	ob_start();
	set_time_limit(0);
	header('Content-Type: text/html; charset=utf-8');
	
	echo '<base href="http://svejo.net" />';
 
	$username = ''; //Потребител
	$password = ''; //Парола
	
	$login = 'http://svejo.net/user/login/';
	$getKey = file_get_contents($login);
	$getKey1 = eregi('<input name="authenticity_token" type="hidden" value="(.*)" />', $getKey, $getKey2);
	$getKey3 = explode('" /></div>', $getKey2[0]);
	$getKey4 = explode('<input name="authenticity_token" type="hidden" value="', $getKey3[0]);
	$realKey = $getKey4[1];
	
	
	$post = 'authenticity_token='.$realKey.'&user[email_or_username]='.$username.'&user[password]='.$password.'&user[remember_me]=checked&submit=Влез';
	$c = curl_init ($login);
	curl_setopt ($c, CURLOPT_POST, true);
	curl_setopt ($c, CURLOPT_POSTFIELDS, $post);
	curl_setopt ($c, CURLOPT_RETURNTRANSFER, true);
	$result = curl_exec ($c);
	curl_close ($c);
	
	echo $result;
?>
 
Добре логнах се но когато се опитвам да изпращам информация към submit-а на линковете сесията се разпада ?!


Код:
<?php
	ob_start();
	set_time_limit(0);
	session_start();
	
	$submitURL = htmlspecialchars(addslashes($_GET['url']));
	
	header('Content-Type: text/html; charset=utf-8');
	echo '<base href="http://svejo.net" />';
	
	$login = 'http://svejo.net/user/login/';
	$getKey = file_get_contents($login);
	$getKey1 = eregi('<input name="authenticity_token" type="hidden" value="(.*)" />', $getKey, $getKey2);
	$getKey3 = explode('" /></div>', $getKey2[0]);
	$getKey4 = explode('<input name="authenticity_token" type="hidden" value="', $getKey3[0]);
	$realKey = $getKey4[1];
	
	$username = 'user';
	$password = 'pass';

	$data = array('user[email_or_username]'=>''.$username.'', 'user[password]'=>''.$password.'', 'user[remember_me]'=>'checked', 'authenticity_token'=>''.$realKey.'', 'commit'=>'Влез', 'user[url_referer]'=>'http://svejo.net/popular/all/new');
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
	curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); 
	curl_setopt($ch, CURLOPT_HEADER, 0); 
	curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile"); 
	curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile"); 
	curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_URL, $login); 
	$result = curl_exec($ch);
	
	$submited = 'http://svejo.net/submit/';
	$sgetKey = file_get_contents($submited);
	$sgetKey1 = eregi('<input name="authenticity_token" type="hidden" value="(.*)" />', $sgetKey, $sgetKey2);
	$sgetKey3 = explode('" /></div>', $getKey2[0]);
	$sgetKey4 = explode('<input name="authenticity_token" type="hidden" value="', $sgetKey3[0]);
	$srealKey = $sgetKey4[1];
	
	$data2 = array('story[url]'=>''.$submitURL.'', 'authenticity_token'=>''.$srealKey.'', 'commit'=>'Продължи');
	$ch2 = curl_init(); 
	curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
	curl_setopt($ch2, CURLOPT_POST, 1);
	curl_setopt($ch2, CURLOPT_POSTFIELDS, $data2);
	curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE); 
	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE); 
	curl_setopt($ch2, CURLOPT_COOKIESESSION, TRUE); 
	curl_setopt($ch2, CURLOPT_HEADER, 0); 
	curl_setopt($ch2, CURLOPT_COOKIEFILE, "cookiefile"); 
	curl_setopt($ch2, CURLOPT_COOKIEJAR, "cookiefile"); 
	curl_setopt($ch2, CURLOPT_COOKIE, session_name() . '=' . session_id()); 
	curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch2, CURLOPT_URL, $submited); 
	echo $result2 = curl_exec($ch2);
?>
 

Back
Горе