<?php
/*
usage:
$array = importHotmail('hotmail-address','password');
*/
function importHotmail($email,$password)
{
$cookieFile = 'cookie.txt';
if(is_file($cookieFile))
unlink($cookieFile);
$bot = new bot($cookieFile);
$r = $bot->get('http://www.hotmail.com/',30,5);
$doc = new DOMDocument;
@$doc->loadHTML($r->content);
$POST = array();
$POST['idsbho']='1';
$POST['PwdPad']='IfYouAreReadingThisYouHaveTooMuchFreeTime';
$POST['LoginOptions']='3';
$POST['CS']='';
$POST['FedState']='';
$POST['PPSX']='';
$POST['type'] = '11';
$POST['login']=$email;
$POST['passwd']=$password;
$POST['NewUser']='1';
$POST['PPFT']='';
$POST['i1']='0';
$POST['i2']='0';
$regexp='/\<input[^\>]*'.'/im';
preg_match_all($regexp,$r->content,$matches);
foreach($matches[0] as $k => $v)
{
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$value = $matches1[1][0];
$regexp = '/name=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$name = $matches1[1][0];
switch($name)
{
case 'PPFT':
$ppft = $value;
break;
}
}
$data = explode('srf_sRBlob=\'',$r->content);
$data = explode("'",$data[1]);
$ppsx = $data[0];
$data = explode('srf_uPost=\'',$r->content);
$data = explode("'",$data[1]);
$action = $data[0];
$POST['PPFT']=$ppft;
$POST['PPSX']=$ppsx;
$POST['PwdPad']=substr($POST['PwdPad'],0,strlen($POST['PwdPad'])-strlen($POST['passwd']));
$r = $bot->post($action,$POST,30);
$data = explode('location.replace("',$r->content);
try
{
if(count($data)!=2)
throw new exception('loggin');
$url = explode('"',$data[1]);
$r = $bot->get($url[0],30,5);
$doc = new DOMDocument;
@$doc->loadHTML($r->content);
$cLink = $doc->getElementById('contactsShortcut')->getAttribute('href');
$contactsUrl = $r->calcUrl($cLink);
$r = $bot->get($contactsUrl);
$doc = new DOMDocument;
@$doc->loadHTML($r->content);
$tables = $doc->getElementsByTagName('table');
foreach($tables as $v)
{
if($v->getAttribute('class')=='ItemListContentTable')
break;
}
$trs = $v->getElementsByTagName('tr');
$returnvalue = array();
foreach($trs as $v)
{
$tds = $v->getElementsByTagName('td');
$name = $tds->item(2);
$email = $tds->item(3);
$email = html_entity_decode($email->textContent);
$email = str_replace("\n",' ',$email);
$email = trim($email);
if(strpos($email,'@'))
{
$returnValue[$email] = trim($name->textContent);
}
}
}
catch(exception $e)
{
echo '<h1>error</h1>';
dump($e);
dump($POST);
unlink($cookieFile);
exit;
}
return $returnValue;
exit;
}
/*
##################################
###Old and deprecated function:###
##################################
set_time_limit(60);
$email = '';//set the hotmail email adress here!
$pass = '';//the password for the hotmail account
$cookie = 'cookie.txt';//path to cookie file (keep it secure!)
unlink($cookie);
$bot = new bot($cookie);
$foo = $bot->get('http://www.hotmail.com/');
$redir = $foo->getRedir();
if($redir!=false)
{
$foo = $bot->get($redir);
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$value = $matches[1][0];
$regexp = '/action=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$action = $matches[1][0];
$foo = $bot->post(array('mspppostint'=>$value),$action);
if($foo)
{
$regexp = '/action=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$action = $matches[1][0];
$regexp='/\<input[^\>]*'.'/i';
preg_match_all($regexp,$foo->content,$matches);
foreach($matches[0] as $k => $v)
{
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$value = $matches1[1][0];
$regexp = '/name=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$name = $matches1[1][0];
switch($name)
{
case 'PPSX':
$ppsx = $value;
break;
case 'PPFT':
$ppft = $value;
break;
}
}
$pwdPad = 'IfYouAreReadingThisYouHaveTooMuchFreeTime';
$pwdPad = substr($pwdPad,0,-strlen($pass));
$loginForm = array(
'PPSX'=>$ppsx,
'login'=>$email,
'passwd'=>$pass,
'LoginOptions'=>'3',
'PwdPad'=> $pwdPad,
'PPFT'=>$ppft
);
$foo = $bot->post($loginForm,$action);
if($foo)
{
$regexp = '/\"(http[^\"]*)/i';
preg_match($regexp,$foo->content,$matches);
if($matches[1])
{
$foo = $bot->get($matches[1]);
$redir = $foo->getRedir();
$foo = $bot->get($redir);
if($foo)
{
$a = parse_url($redir);
$foo = $bot->get('http://'.$a['host'].'/cgi-bin/addresses');
if($foo)
{
//get addresses
$regexp = '/[a-z0-9\-\.\_]+@[a-z0-9\-\.\_]+/i';
preg_match_all($regexp,$foo->content,$matches);
print_r($matches);
}
}
else
{
//False
}
}
else
{
//False
}
}
}
}
function entity($str)
{
return htmlspecialchars($str);
}
*/
?>
Sign up to add your own comment here!
Comments
|
|
Oh~
I think I have found out the problem,
the php do not have the right to unlink the cookie file.
So after I have successfully login once then it keep auto login the page with the same id...
I have change the folder and access right of the cookie file and the folder, now it work!
Thanks regin! |
|
|
Looks fine... are you sure the password & email is correct?
If yes, please send it to me on a private message and I'll have a look on it to see if I can fix it. |
|
|
um...I'm not sure...
I have change the code to
===============================================
$cookieFile = 'cookie.txt';
if(is_file($cookieFile))
unlink($cookieFile);
$bot = new bot($cookieFile);
$r = $bot->get('https://www.paypal.com',30,5);
var_dump (htmlspecialchars($r->content));
die();
=================================================
and it print out
=================================================
string(26096) "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- Script info: script: webscr, cmd: _home, template: xpt/cps/homepage/MainHome, date: Aug. 16, 2008 04:35:04 PDT; country: US, language: en_US, xslt server: on web version: 53.0-671408 branch: AHOD_530_0818_int content version: - pexml version: 53.0-671783 page XSL: cps/default/en_US/homepage/MainHome.xsl hostname : 1NT29iwJgNUx6eaP4AaODyRi3VqUHYq2KsG41HQEQ2g rlogid : 1NT29iwJgNUx6eaP4AaOD%2b5sIHBOdpPFazohbiUdQrlz7Ip0Df6ghg%3d%3d_11bde246030 --> <title>Online Payment, Merchant Account - PayPal</title> <meta name="keywords" content="online payment, online payments, payment, payments, merchant account, online merchant account, credit card merchant account, merchant, merchants, merchant account service, merchant account services, internet merchant account"> <meta name="description" content="PayPal is the safer, easier way to make an online payment or set up a merchant account."> <link media="screen" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/core/core.css"> <link media="print" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/core/print.css"> <link media="screen" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/marketing/marketing.css"> <!--[if IE 7]><link media="screen" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/browsers/ie7.css"><![endif]--> <!--[if lte IE 6]><link media="screen" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/browsers/ie6.css"><![endif]--> <!--[if lt IE 6]><link media="screen" rel="stylesheet" type="text/css" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/css/browsers/ie5.css"><![endif]--> <link rel="apple-touch-icon" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/en_US/i/pui/apple-touch-icon.png"> <script type="text/javascript"> if (parent.frames.length > 0){ top.location.replace(document.location); }</script><script type="text/javascript" src="https://www.paypalobjects.com/WEBSCR-530-20080819-3/js/lib/yui-0.12/yahoo-dom-event.js"></script><script type="text/javascript" src="https://www.paypalobjects.com/WEBSCR-530-20080819-3/js/lib/pui/pui-0.1/paypal.js"></script><script type="text/javascript" src="https://www.paypalobjects.com/WEBSCR-530-20080819-3/js/rosettaLang.js"></script><script type="text/javascript" src="https://www.paypalobjects.com/WEBSCR-530-20080819-3/js/tns/mid.js"></script><script type="text/javascript">PAYPAL.tns.flashLocation = 'https://www.paypal.com/en_US/m/mid.swf';</script><link rel="shortcut icon" href="https://www.paypalobjects.com/WEBSCR-530-20080819-3/en_US/i/icon/pp_favicon_x.ico"> </head> <body> <noscript>...........blah blah blah
======================================================
so...can I fetch it?
and I change it back to "http://www.hotmail.com"
it gives
==================================================
string(30028) " <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html dir="ltr" class="Firefox FF_Win FF_M1 FF_D0"> <head><title> Windows Live Hotmail </title> <style type="text/css"> body { font-size:0.69em; font-family:Verdana,Tahoma,Arial,sans-serif; } </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="DownloadOptions" content="noopen" /> <link rel="stylesheet" href="/mail/ThemeCommon_13.1.0132.0805.aspx?Theme=0&culture=en-HK" type="text/css"/> <link rel="stylesheet" href="http://gfx8.hotmail.com/mail/13.1.0132.0805/LayoutCommon.css" type="text/css"/> <link rel="stylesheet" href="/mail/LayoutCommon_13.1.0132.0805.aspx?Theme=0&culture=en-HK" type="text/css"/> <link rel="stylesheet" href="http://gfx8.hotmail.com/mail/13.1.0132.0805/ClusterLtr.css" type="text/css"/> <link rel="stylesheet" href="http://gfx8.hotmail.com/mail/13.1.0132.0805/LayoutToday.css" type="text/css"/> <link rel="icon" href="http://gfx2.hotmail.com/mail/w3/pr01/ltr/favicon.ico" /> <link rel="shortcut icon" href="http://gfx2.hotmail.com/mail/w3/pr01/ltr/favicon.ico" /> </head> <body class="ApplicationReach" onload='if(typeof(InboxPage)!="undefined"){InboxPage.isPageLoaded=true;}'> <script> function doNothing(){} if(typeof(fhover)!=="function") fhover=doNothing; if(typeof(hover)!=="function") hover=doNothing; if(typeof(showBlockingNotify)!=="function") showBlockingNotify=doNothing; if(typeof(SearchProduct)!=="function") SearchProduct=doNothing; if(typeof(maybeShowBlockingNotify)!=="function") maybeShowBlockingNotify=doNothing; if(typeof(DropdownAction)!=="function") DropdownAction=doNothing; if(typeof(onSubmitInfoPaneItemClicked)!=="function") onSubmitInfoPaneItemClicked=doNothing; if(typeof(onSubmitToolbarItemClicked)!=="function") onSubmitToolbarItemClicked=doNothing; if(typeof(cancelEvent)!=="function") cancelEvent=doNothing; if(typeof(DoHelp)!=="function") DoHelp=doNothing; if(typeof(blockEnter)!=="function") blockEnter=doNothing; if(typeof(confirmDeleteFolder)!=="function") confirmDeleteFolder=doNothing; </script> <script defer="defer" type="text/javascript"> function brkframe(){window.top.location=document.location.href+'&n='+ new Date().getTime();} var g_wlmMainFormId = "aspnetForm", g_helpPaneMarket = "en-US", g_helpPaneProject = "MailClassic", g_helpBaseUrl = "http://help.live.com", g_adsToFire=[], g_isRtl = false, g_confirmEmptyFolder = "Are you sure you want to empty this folder\x3f"; if (!document.cookie || (document.cookie.indexOf("KSC")==-1) && (document.cookie.length!=0) ) {brkframe();} </script> <script defer="defer" type="text/javascript"> try{if(window.top.document!=document){brkframe()}}catch(ex){brkframe();} </script> <div id="HeaderContainer"> <div id="adHeader" class="AdHeaderContainer"> <div id="RadAd_TodayPage_Banner" class="cAdBannerContainer" style="height:90px !important"> <script defer="defer" type="text/javascript"> g_adsToFire[g_adsToFire.length] = ["RadAd_TodayPage_Banner", "&AP=1390&PG=WLHHE3&UC=142", "728", "90", false]; </script> </div> </div> <table cellspacing="0" id="uxp_hdr"><tr><td class="uxp_hdrInner"><table cellspacing="0" class="uxp_hdrInnerTable"><tr> <td id="uxp_hdr_jewelParent" class="uxp_hdr_pointer" onmouseenter="this.className+=' uxp_hdr_jewelSpanHover'" onmouseleave="this.className=this.className.replace(' uxp_hdr_jewelSpanHover','')"><a id="uxp_hdr_jewelLink" href="#"><span id="uxp_hdr_jewelSpan"></span><img src="http://gfx1.hotmail.com/mail/uxp/w2/pr04/HIG/img/h/jewel_24_hover.png" alt="More services" width="39" height="37" style="visibility:hidden"/><span class="uxp_hdr_windowsLiveText">Windows Live<span class="uxp_hdr_tm">™</span></span></a><br /><div class="uxp_hdr_menuParent"><ul id="uxp_hdr_jewelMenu" class="uxp_hdr_menu" style="display:none"><li><a href="#"><span class="uxp_hdr_rightArrow"></span>Other Live services</a><ul class="uxp_hdr_submenu"><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_jwl1">Live Search</a></li></ul></li><li class="uxp_hdr_menuSeparator"> </li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_jwl5">Account</a></li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_jwl6?productkey=wlmail">Feedback</a></li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_jwl7">Help Central</a></li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_jwl8">All services</a></li></ul></div></td><td><table id="uxp_hdr_middleArea"><tr><td id="uxp_hdr_tabsParent"><table id="uxp_hdr_tabs" cellspacing="0" class="uxp_hdr_pointer"><tr><td><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_nav3"><span>Spaces</span></a></td></tr></table></td><td id="uxp_hdr_searchParent"><form id="uxp_hdr_search" onsubmit="document.getElementById('uxp_hdr_productSearchButton').click(); return false" action="http://search.live.com/results.aspx" method="GET" target="_blank"> <label for="uxp_hdr_searchInput" style="display:none">Search</label><span class="uxp_hdr_searchBorder"><span class="uxp_hdr_innerSearchBorder"><input id="uxp_hdr_searchInput" name="q" /><span class="uxp_hdr_buttonBorder"><input id="uxp_hdr_productSearchButton" class="uxp_hdr_button" type="button" onclick="return SearchProduct(0,'393722557','66666666-6666-6666-6666-666666666666')" value="Mail" /></span></span></span> <span class="uxp_hdr_searchBorder"><span class="uxp_hdr_innerSearchBorder"><span class="uxp_hdr_buttonBorder"><input id="uxp_hdr_webSearchButton" class="uxp_hdr_button" type="button" onclick="var s=document.getElementById('uxp_hdr_search').onsubmit; document.getElementById('uxp_hdr_search').onsubmit=null; document.getElementById('uxp_hdr_submitSearchButton').click(); document.getElementById('uxp_hdr_search').onsubmit = s;" value="Web"/><input id="uxp_hdr_submitSearchButton" style="display:none" type="submit" /></span></span></span><input type="hidden" name="mkt" value="en-HK"/><input name="form" value="WLMLQB" type="hidden"/></form></td></tr></table></td><td id="uxp_hdr_meParent" class="uxp_hdr_pointer"><img src="http://p.live.com/p.aspx?CI=8000&PN=Live.Mail&U=7ec70595ca62f92e&MS=1&X=GYyBjZnaVAnvDpn5%2f9SjGSF%2fRD0%3d" alt="" style="display:none"/><div style="position:relative; direction:ltr"><span style="display:none">samvtest@hotmai...</span><a id="uxp_hdr_meLink" href="#" title="samvtest@hotmail.com">samvtest@hotmail.com <span class="uxp_hdr_downArrow"></span> </a></div><a id="uxp_hdr_signOut" target="_top" href="/mail/logout.aspx" onclick="event.cancelBubble=true">Sign out</a><div class="uxp_hdr_menuParent"><ul id="uxp_hdr_meMenu" class="uxp_hdr_menu" style="display:none"><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_ame1">View your account</a></li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_ame2">Link other accounts</a></li><li class="uxp_hdr_menuSeparator"> </li><li><a target="_top" href="http://g.live.com/9uxp9en-hk/hdr_ame4">Personalize</a></li></ul></div></td></tr></table></td></tr></table> </div> <form name="aspnetForm" method="post" action="TodayLight.aspx?n=377272937" id="aspnetForm" enctype="multipart/form-data" onkeydown="blockEnter(event);"> <div> <input type="hidden" name="__VIEWSTATE" id=" __VIEWSTATE" value="" /> </div> <input type="hidden" id="mt" name="mt" value="" /> <input type="hidden" name="EmptyFolder" value="false" /> <input type="hidden" name="EmptyFolderID" value="0" /> <input type="hidden" name="IsForRedirect" value="false" /> <table id="mainLayoutTable" cellpadding="0px" cellspacing="0px"> <tr> <td class="MainLayoutLeftBar"> <div class="ContentLeft"> <div class="ContentFolderList ContainerBGColor2 BorderBox"> <ul id="folderList" fid="00000000-0000-0000-0000-000000000000" fst="NONE" class="List FolderList"><li class="FolderItemNormal ListItem BoldText" onmouseover="fhover(this)" onmouseout="fhover(this)" count="1"> <a class="DisplayBlock" href="InboxLight.aspx?FolderID=00000000-0000-0000-0000-000000000001&InboxSortAscending=False&InboxSortBy=Date&n=96523992" title="Inbox (1)"><img src="./clear.gif" class="i_inbox"/> <span class="Caption">Inbox <span style="display:inline;">(<span>1</span>)</span></span></a> </li><li class="FolderItemNormal ListItem " onmouseover="fhover(this)" onmouseout="fhover(this)" count="0"> <a href="InboxLight.aspx?FolderID=00000000-0000-0000-0000-000000000005&InboxSortAscending=False&InboxSortBy=Date&n=861457563" title="Junk"><img src="./clear.gif" class="i_junkfolder"/> <span class="Caption">Junk <span style="display:none;">(<span></span>)</span></span></a> <a aId="EmptyFolder" class="IndexListItemEmptyLink" href="javascript:confirmDeleteFolder('00000000-0000-0000-0000-000000000005', '', '638596267')"> <img src="./clear.gif" class="glyph_empty_rest" alt="Empty this folder" /> </a> </li><li class="FolderItemNormal ListItem " onmouseover="fhover(this)" onmouseout="fhover(this)" count="0"> <a class="DisplayBlock" href="InboxLight.aspx?FolderID=00000000-0000-0000-0000-000000000004&InboxSortAscending=False&InboxSortBy=Date&n=1896761207" title="Drafts"><img src="./clear.gif" class="i_drafts"/> <span class="Caption">Drafts <span style="display:none;">(<span></span>)</span></span></a> </li><li class="FolderItemNormal ListItem " onmouseover="fhover(this)" onmouseout="fhover(this)" count="0"> <a class="DisplayBlock" href="InboxLight.aspx?FolderID=00000000-0000-0000-0000-000000000003&InboxSortAscending=False&InboxSortBy=Date&n=1609462305" title="Sent"><img src="./clear.gif" class="i_sent"/> <span class="Caption">Sent <span style="display:none;">(<span></span>)</span></span></a> </li><li class="FolderItemNormal ListItem " onmouseover="fhover(this)" onmouseout="fhover(this)" count="0"> <a href="InboxLight.aspx?FolderID=00000000-0000-0000-0000-000000000002&InboxSortAscending=False&InboxSortBy=Date&n=830897484" title="Deleted"><img src="./clear.gif" class="i_trash"/> <span class="Caption">Deleted <span style="display:none;">(<span></span>)</span></span></a> <a aId="EmptyFolder" class="IndexListItemEmptyLink" href="javascript:confirmDeleteFolder('00000000-0000-0000-0000-000000000002', '', '436382503')"> <img src="./clear.gif" class="glyph_empty_rest" alt="Empty this folder" /> </a> </li></ul><a class="ManageLink" href="ManageFoldersLight.aspx?n=585465950">Manage folders</a> </div> <script type="text/javascript" defer="defer"> function shortcutHover(elem) { if(elem.className=="ShortcutItemHover") { elem.className = ""; } else if (elem.className=="") { elem.className = "ShortcutItemHover"; } } function LaunchWebIM(username, url) { try { username = username.replace(/[@.-]/g, ''); var w = window.open( '', username, 'toolbar=no,scrollbars=0,location=no,menubar=no,target=_blank,width=420,height=650,resizable=yes' ); if(w.location == 'about:blank') w.location = url; w.focus(); } catch(e) { } } </script> <!-- <div id="shortcutsToggler" class="BorderNoBottom"><a id="shortcutsCollapser" href="#" onclick="toggleShortcuts(false);">Collapse</a><a id="shortcutsExpander" href="#" onclick="toggleShortcuts(true);">Expand</a></div> --> <div id="shortcutList" class="Shortcuts BorderNoBottom todayShortcutOn"> <a id="todayShortcut" href="TodayLight.aspx?n=745198540" title="Go to the Today Page" onmouseover="shortcutHover(this);" onmouseout="shortcutHover(this);" > <img src="./clear.gif" class="i_today" alt="Go to the Today Page"/> <span>Today</span> </a> <a id="mailShortcut" href="InboxLight.aspx?n=734838448" title="Go to your e-mail" onmouseover="shortcutHover(this);" onmouseout="shortcutHover(this);" > <img src="./clear.gif" class="i_mail" alt="Go to your e-mail"/> <span>Mail</span> </a> <a id="contactsShortcut" href="ContactMainLight.aspx?n=1204197781" title="Go to your contacts" onmouseover="shortcutHover(this);" onmouseout="shortcutHover(this);" > <img src="./clear.gif" class="i_contacts" alt="Go to your contacts"/> <span>Contacts</span> </a> <a id="calendarShortcut" href="/mail/calendar.aspx" title="Go to your calendar" onmouseover="shortcutHover(this);" onmouseout="shortcutHover(this);" > <img src="./clear.gif" class="i_calendar" alt="Go to your calendar"/> <span>Calendar</span> </a> </div> <div class="ToolsCustomerCommunication BorderBox"> <div id="CustComm_120x60" class="c120x60CustomerCommContainer CustComm_120x60" style="height:60px !important;"> <script defer="defer" type="text/javascript"> g_adsToFire[g_adsToFire.length] = ["CustComm_120x60", "&AP=1026&PG=WLHHEC&UC=142", "120", "60", false]; </script> </div> <img src="./clear.gif" width="120" height="0" style="display: block" alt="" /> </div> </div> </td> <td class="MainLayoutRightBar"> <div id="toolbarContainer"> <div class="ToolbarContent" id="mainToolbar"> <ul class="Toolbar" > <script defer="defer" type="text/javascript">g_helpKey="PIM_WhatsNew";</script> <li aId="" class="ToolbarItem ToolbarItemNew"><a title="New" href="EditMessageLight.aspx?n=603683215"><img src="./clear.gif" class="i_newmessage_2" alt="New"/> <span>New</span></a></li> <li aId="Help" class="ToolbarItem ToolbarHelpLink FloatRight" ><a title="Help" href="javascript:;" id="Help" onclick="DoHelp();"><img alt="Help" src="http://gfx2.hotmail.com/mail/w3/pr01/ltr/i_help.gif"/></a></li> <li aId="Options" class="ToolbarItem ToolbarOptionsLink FloatRight"><a title="Options" href="options.aspx?subsection=1&n=1108327601"id="Options"><img src="./clear.gif" class="i_prefs" alt="Options"/> <span>Options</span></a></li> </ul> <input type="hidden" id="ToolbarActionItem" name="ToolbarActionItem" value=""/> </div> </div> <div id="MainContent"> <table width="100%" cellpadding="0" cellspacing="0"><tr valign="top"><td> <div class="BorderNoTop"> <div class="TodayHeaderPadding BorderBottomLineColor ContainerBGColor2"> <div class="TodayHeaderGreetingDate"> <span class="TodayHeaderGreeting BoldText" >Hi, Chris!</span> <span class="TodayHeaderDate">Wednesday, August 20</span></div> <div class="TodayHeaderStorageMeter ClearBoth"> <div class="StorageMeterBar"><div class="Bar" style="width:1%;"></div></div> <div class="StorageMeterText ClearBoth"> <div class="MeterText FloatLeft">Mailbox usage: 1% of 5 GB</div> <div class="NewsletterLink FloatRight"><a href="http://newsletters.msn.com/hm/gomarket.asp?L=EN&C=XX&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com" target="_blank"><img src="http://gfx2.hotmail.com/mail/w3/pr01/ltr/i_newsletter2.gif"/>Get newsletters</a></div> <div class="ClearBoth"></div> </div> </div> </div> <div class="TodayUpsell BorderBottomLineColor UpsellBackground ClearBoth"> <div class="VersionHeading">You are using the classic version of Windows Live Hotmail.</div> <div>Have a fast connection and want more features? <a href="./FirstRunExperience.aspx">Try the full version</a> to see message previews in your inbox. (It's <b>free</b>, too.)</div> </div> <div class="TodayOptOut">Want to start with your inbox? To skip the Today page when you sign in, <a class="NonThemedLinks" href="TodayPageOptOut.aspx?n=1788764918" target="_top">change your settings</a>.</div> <!-- hash=3547148092 --> <div id="ContentWidthPlaceholder"></div> <div class="DropShadow"></div> </div> </td> <td class="dSideAds"> <div id="dSideAdsDiv"> <div id="RadAd_Today300" class="" style=""> <script defer="defer" type="text/javascript"> g_adsToFire[g_adsToFire.length] = ["RadAd_Today300", "&AP=1089&PG=WLHHE1&UC=142", "300", "250", false]; </script> </div> <div id="CustComm_300x125_TodayPage" class="" style=""> <script defer="defer" type="text/javascript"> g_adsToFire[g_adsToFire.length] = ["CustComm_300x125_TodayPage", "&AP=1419&PG=WLHHEA&UC=142", "300", "125", false]; </script> </div> </div> </td> </tr></table> </div> </td> </tr> <tr> <td class="MainLayoutBottomBar" colspan="2"> </td> </tr> </table> </form> <table id="uxp_ftr_control" cellpadding="0" cellspacing="0"> <tr> <td id="uxp_ftr_left"> <ul> <li><a id="uxp_ftr_link_trademark" target="_top" href="http://g.live.com/9uxp9en-hk/ftr1">© 2008 Microsoft</a></li> <li><a id="uxp_ftr_link_privacy" target="_top" href="http://go.microsoft.com/fwlink/?LinkId=74170">Privacy</a></li> <li class="uxp_ftr_item_last"><a id="uxp_ftr_link_legal" target="_top" href="http://g.msn.com/0TO_/enhk">Legal</a></li> </ul> </td> <td id="uxp_ftr_right"> <table id="uxp_ftr_right_nest" cellpadding="0" cellspacing="0"> <tr> <td> <ul> <li><a id="uxp_ftr_link_helpcentral" target="_top" href="http://g.live.com/9uxp9en-hk/ftr2">Help Central</a></li> <li><a id="uxp_ftr_link_account" target="_top" href="http://g.live.com/9uxp9en-hk/ftr3">Account</a></li> <li class="uxp_ftr_item_last"><a id="uxp_ftr_link_feedback" target="_top" href="http://g.live.com/9uxp9en-hk/ftr4?productkey=wlmail">Feedback</a></li> </ul> </td> </tr> </table> </td> </tr> </table> <img style="display:none;" id="cleargif" width="1" height="1" alt="" name="http://h.msn.com/c.gif?RF=&PI=7324&DI=5707&PS="/> <script> var PS = "94553"; </script> <script defer="defer" type="text/javascript" src="http://help.live.com/resources/neutral/launchhelp.js"></script> </body> <script> window["PerfRecorder"]={ config:{allowInstrumentation : true, market : "en-HK", sampleFrequency : 100, trackingThreshold : 120, delimiter: "|", sharedDomain: ".live.com"}, GT1Param: "", FireTracking : function(){}, startTimer: function(){} }; </script> <script defer="defer" type="text/javascript" src="http://gfx6.hotmail.com/mail/13.1.0132.0805/Light.js"></script> <script defer="defer" type="text/javascript" src="http://gfx7.hotmail.com/mail/13.1.0132.0805/MSNPlatform/Header.js"></script> <script type="text/javascript" src="http://ads1.msn.com/library/dap.js"></script> <script type="text/javascript"> function FireAds() { if(typeof(g_adsToFire) != "undefined") { var arrLength = g_adsToFire.length; if(arrLength > 0) { for(var i =0; i<arrLength; i++) { var adComponents = g_adsToFire[i]; if(typeof(dapMgr) != "undefined") { try { dapMgr.enableACB(adComponents[0], adComponents[4]); } catch (e) { } try { dapMgr.renderAd(adComponents[0], adComponents[1], adComponents[2], adComponents[3]); } catch (e) { } } } } } } window.setTimeout(FireAds, 20); </script> <img style="display:none" src="http://gfx1.hotmail.com/mail/w3/pr01/ltr/plx.gif" /> <script> function fireCGif() { var gifs = ["3rdPartyCleargif","OfficeLiveCleargif","cleargif"]; for(var i=(gifs.length-1); i >= 0; i--) { var cgif = document.getElementById(gifs[i]); if(cgif) { var payload; cgif.removeAttribute("src"); switch(gifs[i]) { case "OfficeLiveCleargif": payload = (PS? PS:"0"); break; case "cleargif": payload = (PS? PS:"0") + ((PerfRecorder.GT1Param == "")? "" : (">1="+PerfRecorder.GT1Param)); break; default: payload=""; break; } cgif.src = cgif.getAttribute("name") + payload; } } } </script> <script defer="defer">PerfRecorder.FireTracking("T");fireCGif();</script> </html>"
=============================================
If I remove the htmlspecialchars and just dump the $r->content out it will show a page for a second and then redirect to the page "importHotmail.php&n=1219203050738" |
|
|
Sure your server supports SSL requests?
Can you fetch a page like https://www.paypal.com ? |
|
|
Hello~Regin!
I have try this script, don't know why always get an exception of "loggin"
and I dump the $ppsx and the $action, they both empty...
but when I dump the $r->content before the line "$data = explode('srf_sRBlob=\'',$r->content);"
it show the Live web mail for a very short while and then redirect to another page.
Do you know what have I done wrong? |
|
|
| I don't support this script for PHP4... |
|
|
Hi,
I try to run the new version of the script, but I've found a trouble in the version of PHP. The actual version of PHP in my hosting is 4. There are a multiple errors of conmpatibility (in TRY / CATCH expresions).
What I will do to run this script in PHP4?
Thanks! |
|
|
to madhabnath : change the browser agent(in the bot class) to the latest one. then can solve your problem.
I test it. after that it works fine.
thanks regin for your code. |
|
|
| I'd suggest you to start tracking down the bug... I won't have time to look at it until August. |
|
|
Hi regin,
I have run your code, but it gives me the following error -
"Fatal error: Call to a member function getAttribute() on a non-object in /opt/lampp/htdocs/stagingsites/address/includes/msn.php on line 62".
I have debugged your code and found that it didn't return anything at -
try
{
if(count($data)!=2)
throw new exception('loggin');
$url = explode('"',$data[1]);
$r = $bot->get($url[0],30,5);
$doc = new DOMDocument;
@$doc->loadHTML($r->content);
now when you go to the next line ->
$cLink = $doc->getElementById('contactsShortcut')->getAttribute('href');
it gives me error. Can you please help?? |
|
|
fixed!!!
It was a permissions on the directory I created that contains the script... |
|
|
regin, great script!! I'm having the same prob as gauravjain0508 and unfortunately I'm not a apache guru... I can see that the script works when I run it from the cli but not when I execute the page... I did the following:
chmod 777 cookie.txt
chown www:www cookie.txt
And still no avail... I'm still trying to understand why it's not working... do you have any other suggestions I should try? |
|
|
gauravjain0508:
When you run the script command line your user probably have write permissions in the directory where the cookiefile is residing. When apache (your webserver) runs the script it probably doesn't have write permissions.
Please check up on that! |
|
|
hey..i always get an invalid login exception even the credentials are right.
It always goes to catch block and unlink cookie files.
Althogh this script is running fine on command line if called using simpleTest unit test cases..... |
|
|
| I haven't come across no APIs to do this... :S if you do let me know! |
|
|
| so I am guessing that there are no REST APIs available for hotmail and the best way to do this is trough a scrapper. is this correct? thank you |
|
|
I tested it on NuSpherePhpEd 5.2 (Win32) and it worked perfectly.
Thx Regin ! |
|
|
| Just updated this script.... :P - enjoy! |
|
|
Hi I am getting blank page after executing the code
<?php
set_time_limit(60);
$email = 'rupadya@hotmail.php';//set the hotmail email adress here!
$pass = '****';//the password for the hotmail account
//$cookie = 'cookie.txt';//path to cookie file (keep it secure!)
//unlink($cookie);
$bot = new bot($cookie);
$foo = $bot->get('http://www.hotmail.com/');
$redir = $foo->getRedir();
if($redir!=false)
{
$foo = $bot->get($redir);
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$value = $matches[1][0];
$regexp = '/action=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$action = $matches[1][0];
$foo = $bot->post(array('mspppostint'=>$value),$action);
if($foo)
{
$regexp = '/action=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$action = $matches[1][0];
$regexp='/\<input[^\>]*/i';
preg_match_all($regexp,$foo->content,$matches);
foreach($matches[0] as $k => $v)
{
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$value = $matches1[1][0];
$regexp = '/name=\"([^\"]*)/i';
preg_match_all($regexp,$v,$matches1);
$name = $matches1[1][0];
switch($name)
{
case 'PPSX':
$ppsx = $value;
break;
case 'PPFT':
$ppft = $value;
break;
}
}
$pwdPad = 'IfYouAreReadingThisYouHaveTooMuchFreeTime';
$pwdPad = substr($pwdPad,0,-strlen($pass));
$loginForm = array(
'PPSX'=>$ppsx,
'login'=>$email,
'passwd'=>$pass,
'LoginOptions'=>'3',
'PwdPad'=> $pwdPad,
'PPFT'=>$ppft
);
$foo = $bot->post($loginForm,$action);
if($foo)
{
$regexp = '/\"(http[^\"]*)/i';
preg_match($regexp,$foo->content,$matches);
if($matches[1])
{
$foo = $bot->get($matches[1]);
$redir = $foo->getRedir();
$foo = $bot->get($redir);
if($foo)
{
$a = parse_url($redir);
$foo = $bot->get('http://'.$a['host'].'/cgi-bin/addresses');
if($foo)
{
//get addresses
$regexp = '/[a-z0-9\-\.\_]+@[a-z0-9\-\.\_]+/i';
preg_match_all($regexp,$foo->content,$matches);
print_r($matches);
}
}
else
{
//False
}
}
else
{
//False
}
}
}
}
function entity($str)
{
return htmlspecialchars($str);
}
?>
<?php
/*
//Example of use:
$bot = new bot();
$bot->cookie = "/file/to/cookies.txt"; //setting file to store cookies in
$bot->cookie = false; //setting cookies off
$url = 'http://www.google.com/';
//send request to http://www.google.com/
if($response = $bot->get($url))
{
//got response
if($redirect = $response->getRedir())
{
echo 'You have been redirected to: '.htmlspecialchars($redirect);
}
else
{
//content of response comes here:
echo $response->content;
}
}
else
{
//could not connect!
}
*/
class bot
{
var $agent='Mozilla/5.0 (Windows; U; Windows NT 5.1; da-DK; rv:1.7.12) Gecko/20050919 Firefox/1.0.7';
var $dataBuffer;
var $cookie;
function bot($cookie=false)
{
$this->cookie = $cookie;
}
//make a http post to a url
function post ($data, $url, $timeout=30) {
$url_array = parse_url($url);
$query = "";
foreach ($data as $key => $value) {
if ($query) $query .= "&";
$query.= $key."=".urlencode($value);
}
$len = strlen($query);
$out = "POST ".($url_array["path"]? $url_array["path"]:'/')."?".$url_array["query"]." HTTP/1.1\r\n";
$out .= "Host: ".$url_array['host']."\r\n";
$out .= "User-Agent: ".$this->agent."\r\n";
$out .= "Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$out .= "Accept-Language: en-us,en;q=0.5\r\n";
// $out .= "Accept-Encoding: gzip,deflate\r\n";
$out .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
// $out .= "Keep-Alive: 300\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Connection: Close\r\n";
$out .= "Content-Length: $len\r\n\r\n";
$out .= "$query\r\n";
$ch = curl_init();
if($this->cookie)
{
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// curl_setopt($ch,CURLOPT_HTTPHEADER,array($cookie));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch,CURLOPT_USERAGENT,$this->agent);
$returned = curl_exec($ch);
if (!$returned) {
return false;
} else {
$response = new httpResponse($url,$returned);
return $response;
}
}
function get($url,$timeout=30)
{
$url_array = parse_url($url);
$query = "";
$len = strlen($query);
$path = $url_array['path'];
if($url_array['query'])
{
$path .= '?'.$url_array['query'];
}
$out = "GET ".$path." HTTP/1.1\r\n";
$out .= "Host: ".$url_array['host']."\r\n";
$out .= "User-Agent: ".$this->agent."\r\n";
$out .= "Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$out .= "Accept-Language: en-us,en;q=0.5\r\n";
$out .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$out .= "Connection: Close\r\n";
$ch = curl_init();
if($this->cookie)
{
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_USERAGENT,$this->agent);
curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
$returned = curl_exec($ch);
curl_close ($ch);
if ($returned == "") {
return false;
} else {
$response = new httpResponse($url,$returned);
return $response;
}
}
}
?>
<?php
class httpResponse
{
var $url;
var $raw;
var $headers = array();
var $content;
function httpResponse($url,$raw)
{
$this->url = $url;
$this->raw = $raw;
//Parse response
// echo htmlspecialchars($raw);
$raw = explode("\r\n\r\n",$raw,2);
$content = explode("\n",$raw[1],2);
$this->headers = explode("\n",$raw[0]);
$this->content = $raw[1];//substr(trim($content[1]),0,-2);
}
function getRedir()
{
foreach($this->headers as $k => $v)
{
// echo str_replace(' ','_',$v).'<br>';
if(substr(strtolower($v),0,9)=='location:')
{
$str = trim(substr($v,9));
$a = parse_url($str);
if($a['host']=="")
{
$a1 = parse_url($this->url);
if(substr($str,0,2)=='./')
{
$str = '/'.substr($str,2);
}
if(substr($str,0,1)=='/')
{
// echo '<b>test2</b>';
$str = $a1['scheme'].'://'.$a1['host'].$str;
$this->content = '';
// echo '<span style="color:blue;font-weight:bold;">1: '.$str.' / '.$v.' / '.$this->url.'</span><br>';
return $str;
}
else
{
if(strpos($str,'/')!==false)
{
$regexp = '/[^\/]+$/i';
$foo = preg_replace($regexp,'',$str);
}
else
{
$foo = $str;
}
if($foo == "")
{
$foo = "/";
}
if(substr($a1['path'],-1)!='/'&&substr($foo,0,1)!='/')
{
//echo '<br>';
//echo '<b>test1</b>';
// echo $this->url.'<br>';
// echo $a1['path'];
// echo '<br>';
$dirs = explode('/',$a1['path']);
// print_r($dirs);
$dirs[(count($dirs)-1)]="";
$dirPath = implode('/',$dirs);
$dirPath = str_replace('//','',$dirPath);
if($dirPath=="")
{
$dirPath = '/';
}
// echo '<h2>'.$dirPath.'</h2><br>';
// echo '<span style="color:red;">'.$foo.'</span><br>';
$foo = $dirPath.''.$foo;
$redir = $a1['scheme'].'://'.$a1['host'].$foo;;
// echo '<span style="color:blue;font-weight:bold;">2.1: '.$redir.' / '.$v.' / '.$this->url.'</span><br>';
return $redir;
}
if(substr($a1['path'],-1)=='/'&&substr($foo,0,1)=='/')
{
// echo '<span style="color:green;font-weight:bold;">BAH: '.$foo.'</span><br>';
$foo = substr($foo,1);
}
$str = $a1['scheme'].'://'.$a1['host'].$a1['path'].$foo;
$this->content = '';
// echo '<span style="color:blue;font-weight:bold;">2: '.$str.' / '.$v.' / '.$this->url.'</span><br>';
return $str;
}
}
return $str;
}
}
return false;
}
function getEncoding()
{
foreach($this->headers as $k => $v)
{
if(substr(strtolower($v),0,17)=='content-encoding:')
{
$str = trim(substr($v,17));
return $str;
}
}
return false;
}
}
?> |
|
|
Hello.
run script ---> page Empty
I not understand
file hotmail.php (this page)
<?
include("httpResponse.php");
include("bot.php");
THEN....
____________________
run script ---> page Empty ??
Help me plese |
|
|
| Carllewis1980, could you share the working version of the script? |
|
|
I have it all working fine now, but how can i do a preg_match_all on this statement...
<a href="#" onclick="javascript:DC(event);return false;">abc@acb.com</a> |
|
|
OK, I've found up something. The problem is caused because hotmail makes two redirects in row (instead of one). The easiest way to fix that is to put the first $foo->getRedir(); instead of http://www.hotmail.com/.
Now it looks like:
$foo = $bot->get('http://mail.live.com/');
So we get to the log in page. $value is retrieved (I don't have any idea what it is but it is retrieved :) ! But action is empty! I suppose that action is the place where login form should send data. The problem is that they don't show that form directly. They use JS function that generates all the page's content :(
Do you have any idea how to deal with that?
Thanks,
Eugene |
|
|
Hi again!
if($redir!=false)
{
$foo = $bot->get($redir);
$regexp = '/value=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$value = $matches[1][0];
$regexp = '/action=\"([^\"]*)/i';
preg_match_all($regexp,$foo->content,$matches);
$action = $matches[1][0];
What is supposed to be in $value and $action? That variables are just empty. If I know what they are for, I'll try to modify the regular expressions to retrieve the neccessary data.
Thanks,
Eugene |
|
|
Hi there!
I've downloaded the script, and included the two classes at the top of it. I've made all the changes that are posted in comments as well. But still it returns nothing. I supposed that hotmail changed some HTML and the regular expressions stopped working. So I tried to print_r($foo->content) but it is empty too :(
Plese help! Where should I look for the mistake?
PS. I execute the script on Windows server. Could that be a problem?
Thanks,
Eugene |
|
|
| Can any one create a tutorial for this process? i have read that hotmail change their login sequence regularly! i also read that there is software that can help with this??? I have seen i can buy the software on the internet but i'd rather learn it myself!!! |
|
|
| tried this right now does not work, trying to make the script work for live. the redirects happen to login.live.com but the post with the email/passwd is not working. Is there something else I need to pass in ? thanks. |
|
|
hi
It wont work on my machine because the cookie file???
HELP... please! |
|
|
Hi,
Iam getting emails like this "Array ( [0] => Array ( [0] => chilukuri123@gmai... [1] => eleven_raju@yahoo... ) )" .Iam not getting the full email address.please some one help me |
|
|
Here is a fix
Change
$foo = $bot->get('http://'.$a['host'].'/cgi-bin/addresses');
to
$foo = $bot->get('http://'.$a['host'].'/mail/ContactListLight.aspx');
change
$regexp = '/[a-z0-9\-\.\_]+@[a-z0-9\-\.\_]+/i';
to
$regexp = '/[a-z0-9\-\.\_]+@[a-z0-9\-\.\_]+/i';
then it will work as expected.. or at least you will get emails |
More comments: 1 2 Next
|
|