Page 1 of 1

Alot of HELP needed!!!

Posted: Fri Jan 18, 2008 11:56 am
by n00b!
This involves making fake cookie files (myspace wont log you in without cookies) and so on. Its a little more complicated than loggin through a browser, cause you have to make an entire script that will "react" like a browser will at all events. Here's what I got so far:

Code: Select all

<head>
<meta http-equiv="Content-Type" content="application/x-www-form-urlencoded">
</head>
<?
 
// setup and configure temp cookies
 
$ch = curl_init();
$randnum = rand(1,9999999);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookiejar-$randnum");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookiejar-$randnum");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 0);
 
 
 
// get homepage for login page MyToken
 
curl_setopt($ch, CURLOPT_URL,"http://www.myspace.com");
$page = curl_exec($ch);
 
 
 
// find MyToken
 
preg_match("/MyToken=([^\"]+)\"/",$page,$token);
$token = $token[1];
 
 
 
// Print MyToken on-screen so we know we got it
 
echo $token;
 
 
 
// do actual login
 
$YOUR_EMAIL = "[color=#BF0000]youremail123+yahoo.com[/color]";
$YOUR_PASSWORD = "[color=#BF0000]yourpass123[/color]";
curl_setopt($ch, CURLOPT_URL,"http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken={$token}");
curl_setopt($ch, CURLOPT_REFERER, "http://www.myspace.com");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_POST, 1);
$postfields = "email=" . urlencode($YOUR_EMAIL);
$postfields .= "&password=" . urlencode($YOUR_PASSWORD);
$postfields .= '&ctl00%24Main%24SplashDisplay%24login%24loginbutton.x=38&ctl00%24Main%24SplashDisplay%24login%24loginbutton.y=15';
curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
$page = curl_exec($ch);
 
 
 
// find redirect url to home page
 
preg_match("/replace\(\"([^\"]+)\"/",$page,$redirpage);
$redirpage = $redirpage[1];
 
 
 
// do the redirect
 
curl_setopt($ch, CURLOPT_REFERER,"http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken={$token}");
curl_setopt($ch, CURLOPT_URL,$redirpage);
curl_setopt($ch, CURLOPT_POST, 0);
$page = curl_exec($ch);
 
 
 
// find edit profile link (with token attached)
 
preg_match("/ id=\"ctl00_Main_ctl00_Welcome1_EditMyProfileHyperLink\" href=\"([^\"]+)\"/",$page,$redirpage);
$redirpage = $redirpage[1];
 
 
 
// go there (edit profile)
 
curl_setopt($ch, CURLOPT_URL, $redirpage);
$page = curl_exec($ch);
 
echo $page;
 
?>
That's supposed to log you in, accept your pass and email, assign you a MyToken number, and then finally re-direct you to the page where its all told its VALID and takes you to the home page. As a test to see if we got to the home page, I have it search for and take us to the edit profile page.

It freezes up at the final step, where its supposed to take us the myspace check-valid page which would in turn takes us to our logged in home page.

Ive even got it to show the MyToken and print it on the screen so we know we go it! Just need help of where I'm going wrong.

Re: Alot of HELP needed!!!

Posted: Fri Jan 18, 2008 2:34 pm
by Jonah Bron
I think instead of this:

Code: Select all

preg_match("/MyToken=([^\"]+)\"/",$page,$token);
$token = $token[1];
You want this:

Code: Select all

preg_match_all("/MyToken=\"([^\"]*?)\"/", $page, $token);
$token = $token[0]
I'm not sure if that will solve your initial problem. I don't have any experience with curl... :?

Re: Alot of HELP needed!!!

Posted: Fri Jan 18, 2008 4:31 pm
by n00b!
Ehh, it didn't really change anything. If I put a 0 instead of the 1 I had, it just prints out "MyToken" in front of the token. :(