This article describes the use of Php curl to imitate the user login Sina Weibo microblogging method. Share to everyone for your reference. The implementation methods are as follows:
Now use PHP to do imitation user login we will use the PHP curl function, because only it can be implemented like users to visit other sites, the following to introduce you to the Curl Sina Weibo microblogging application examples.
The day before yesterday received a demand need to simulate landing micro-blog and then carry out Weibo, have done a lot of analog login Ali mother, micro-letter, and some other internal system, has not been able to log in, Haha, so there is no time to do things, but when the analysis of Sina's landing process to feel the pressure
Encountered SHA1 (SHA1 (SHA1 (PWD)), once.servertime), must not be used, mainly to make this encryption algorithm can not be allowed to do not talk about login, and then on the Internet to find the code, one hours without the obtained.
is not I use Weibo account password can also login to Sina Mail or other Sina products to go, feel the hope is very large, it is true that Micro Bo account can directly login to all Sina products, and then visit the microblogging I have been in the state of the log, to prove this god-horse use it?
Actually very useful, a big company in a project investment technology and the project profitability and prospects have a lot of relationship, Micro Bo he can spend a lot of mind to do, but the other is not necessarily, in the case of finding that place the password is not encrypted that is not very much to say. (PS: More interested in network security, this way for hackers is called a side note, side note is that when hackers attack a website, this site security to do very well, no known loopholes, more difficult to break, so hackers will look for the site under the server under the other sites, and then find a more easily breached, Through this website hangs the horse, the shell, to raise the right, then the target website also falls, thought in the same server, therefore .... The goal is to get to the target station, either way, just take it off, it's a dirty idea.
Https://login.sina.com.cn/sso/login.php?client=ssologin.js (v1.4.15) &_=1403138799543 simple grab bag found that the password is not encrypted, Can't we simulate a login? Well, actually, it's a little early for fun.
First login to Sina's bar, the code minutes will be done. Returns a JSON array
Copy Code code as follows:
$password = $p;
$username = Base64_encode ($u);
$LOGINURL = ' Https://login.sina.com.cn/sso/login.php?client=ssologin.js (v1.4.15) &_=1403138799543 ';
$loginData [' entry '] = ' SSO ';
$loginData [' gateway '] = ' 1 ';
$loginData [' from '] = ' null ';
$loginData [' savestate '] = ' 30 ';
$loginData [' useticket '] = ' 0 ';
$loginData [' pagerefer '] = ';
$loginData [' vsnf '] = ' 1 ';
$loginData [' su '] = Base64_encode ($u);
$loginData [' service '] = ' SSO ';
$loginData [' sp '] = $password;
$loginData [' sr '] = ' 1920*1080 ';
$loginData [' encoding '] = ' UTF-8 ';
$loginData [' cdult '] = ' 3 ';
$loginData [' domain '] = ' sina.com.cn ';
$loginData [' prelt '] = ' 0 ';
$loginData [' returntype '] = ' TEXT ';
Var_dump ($loginData); exit;
$login = Json_decode (Loginpost ($LOGINURL, $loginData), true);
Var_dump ($login); exit;function loginpost ($url, $data) {
Global $cookie _file;
echo $cookie _file; exit;
$tmp = ';
if (Is_array ($data)) {
foreach ($data as $key => $value) {
$tmp. = $key. " = ". $value." & ";
}
$post = Trim ($tmp, "&");
}else{
$post = $data;
}
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
curl_setopt ($ch, curlopt_post,1);
curl_setopt ($ch, Curlopt_postfields, $post);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
$return = curl_exec ($ch);
$info = Curl_getinfo ($ch);
Curl_close ($ch);
return $return;
}
Returns an array of JSON data
Copy Code code as follows:
Array (size=4)
' Retcode ' => string ' 0 ' (length=1)
' UID ' => string ' 1920109964 ' (length=10)
' Nick ' => string ' Grandpa tells a story ' (length=18)
' Crossdomainurllist ' =>
Array (size=2)
0 => String ' https://passport.weibo.com/wbsso/login?ticket=ST-MTkyMDEwOTk2NA%3D% 3d-1403228192-gz-ab37dc0c18ba3bfcd90aefac6115149d&ssosavestate=1434764192 ' (length=140)
1 => string ' https://crosdom.weicaifu.com/sso/crosdom?action=login&savestate=1434764192 ' (length=74)
This time that we login successfully, but in fact, the address of our microblog home is not weibo,com, but http://weibo.com/bipeng0405/home?wvr=5 such address, how we get this address, very simple, Direct crawl Weibo. COM then he will automatically give you jump back, you just need to take the address of the jump to record it
Copy Code code as follows:
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://weibo.com");
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
$return = curl_exec ($ch);
$info = Curl_getinfo ($ch);
Curl_close ($ch);
Here's another question, this time you may find that did not jump to their microblog home page, this is why, you can look at the landing when there are two connection addresses, which have a Weibo domain under an address, guessing should be made cookies set so first get one side of him.
Copy Code code as follows:
Get ($login [' crossdomainurllist '][0]);
This code will have a problem before weibo.com get it just now.
I hope this article will help you with your PHP program design.