Home Backend Development PHP Tutorial PHP simulates GMAIL, HOTMAIL (MSN), YAHOO, 163, 126 mailbox login details_PHP tutorial

PHP simulates GMAIL, HOTMAIL (MSN), YAHOO, 163, 126 mailbox login details_PHP tutorial

Jul 21, 2016 pm 03:06 PM
gmail msn php yahoo introduce exist simulation Log in of detailed Mail

I have been busy recently, and I am rushing to publish this article at the end of this holiday, in order to make these source codes open source
Of course these methods may not be advisable, but they should be in this direction. Since I am currently doing UCHOME Hong Kong and Taiwan’s site
Our planner said that we wanted to change the display method in friend invitations. I didn’t care at first, so I said yes!
When I was doing this, I discovered that this place in UCH was made in roaming mode, which was very confusing and nothing could be changed!
Alas, since I agreed and said it was possible, now the actual situation is no longer possible, so I feel embarrassed. In order to quickly solve this problem, I searched it on GOOGLE and
Baidu, and the result was unexpected again, just one There are no other open source examples of 126 mailboxes. Brother Yiniu left QQ and said he wanted other source codes.
You can add QQ to buy them! No more comments for this person! I spent some time and sorted it out, and I was lucky enough to get a few. Because my time is limited, I have been working on the project at hand, so I didn’t care about the others. Now I give GMAIL, HOTMAIL ( MSN), PHP source code of YAHOO's email contacts:

1.GMAIL

Copy codeThe code is as follows:

define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) ); //Define the path where COOKIES is stored, and you must have permission to operate
define( "TIMEOUT", 1000 ); // Timeout setting
class GMAIL
{
private function login($username, $password)
                                  Grab the data of the login page and write down the cookies "https://www .google.com/accounts/ServiceLoginAuth";
$ch = curl_init($login_url);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR) ;
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);                                                                    //Simulation parameters
'dsh','timeStmp','secTok'); .$v.'"/s*id="'.$v.'"/s*value="(.*?)"/s*//>/i', $contents, $matches);
                                                                                                                                                                                                                                                                                                                          mail';
preg_match('//i ', $contents, $matches);
if(!empty($matches)) {
$GALX = $matches[1];
$matches = array();
            }
                $timeStmp = time();

                //第二步: 开始登录
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth");
                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                curl_setopt($ch, CURLOPT_POST, 1);
                $fileds = "dsh=$dsh&Email=".$username."&Passwd={$password}&GALX=$GALX&timeStmp=$timeStmp&secTok=$secTok&signIn=Sign in&rmShown=1&asts=&PersistentCookie=yes";
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fileds);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);             
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $str = curl_exec($ch);              
                curl_close($ch);

                //第三步:check Cookies即也算是个引导页面
                $ch = curl_init("https://www.google.com/accounts/CheckCookie?chtml=LoginDoneHtml");

                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch,CURLOPT_COOKIEFILE,COOKIEJAR);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);                
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);    
                $str2 = curl_exec($ch);

                curl_close($ch);

                if (strpos($contents, "安全退出") !== false)
                {                       
                        return FALSE;
                }              
                return TURE;
        }

                                                                                                                                                                                                                         ) )
                                                                                                                                                                               
                                                                                                                                                                                                              =true&groups=true&show=ALL&enums=true&psort=Name&max=300&out=js&rf=&jsx=true"); //out=js returns json data, if not set, returns xml data.
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                                                                                                                                                                                                                                                                                     / "1.0/"?>pab:searchContactsFNtrueuser:getSignaturespab:getAllGroups";
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $str);

                                                                                               $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
$contents = curl_exec($ch);
curl_close($ch);
//die($contents);
                   //get mail list from the page information username && emailaddress
                                                                                                                                                                                                                                                                                         ;/Umsi",$contents,$mails);
preg_match_all("/(.*)/Umsi",$contents ,$names);
$users = array();
foreach($names[1] as $k=>$user)
{
//$user = iconv($user ,'utf-8','gb2312');
                                                                                                                         {
               return 'There is no contact in your mailbox yet';
            } 
                */
                $contents = substr($contents, strlen('while (true); &&&START&&&'),  -strlen('&&&END&&& '));
                return $contents;
        }
}
$gamil = new GMAIL;
$res = $gamil->getAddressList('username@163.com','123456');
echo $res;
?>


2.HOTMAIL(MSN)
复制代码 代码如下:

define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) ); //定义COOKIES存放的路径,要有操作的权限
define( "TIMEOUT", 1000 ); //超时设定
class MSN
{
function getAddressList($username, $password)
{
//第一步:模拟抓取登录页面的数据,并记下cookies
$cookies = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=".time()."&rver=6.0.5285.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=2052&id=64855&mkt=en");
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
curl_close($ch);
//参数的分析
$matches = array();
preg_match('//i', $str, $matches);
                $PPFT = $matches[2];

                preg_match('/srf_sRBlob=/'(.*?)/';/i', $str, $matches);
                $PPSX = $matches[1];

                $type = 11;

                $LoginOptions = 3;

                $Newuser = 1;

                $idsbho = 1;

                $i2 = 1;

                $i12 = 1;

                $i3 = '562390';

                $PPSX = 'Pa';
                //合并参数
                $postfiles = "login=".$username."&passwd=".$password."&type=".$type."&LoginOptions=".$LoginOptions."&Newuser=".$Newuser."&idsbho=".$idsbho."&i2=".$i2."&i3=".$i3."&PPFT=".$PPFT."&PPSX=".$PPSX."&i12=1";

                //第二步:开始登录
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                curl_setopt($ch, CURLOPT_URL, 'https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct='.(time()+5).'&rver=6.0.5285.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=2052&id=64855&mkt=en&bk='.(time()+715)); //此处的两个time()是为了模拟随机的时间           
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postfiles);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
                //curl_setopt($ch, CURLOPT_HEADER, 1);
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                $content = curl_exec($ch);
                curl_close($ch);

                if( stripos($content,'WLWorkflow') !== FALSE ) {     //WLWorkflow登录页面JS
                    return false;      //登录失败
                }
                //获取location链接
                $matches = array();      
                preg_match('/window.location.replace/(/"(.*?)/"/)/i', $content, $matches);
                $url_contiune_1 = $matches[1]; //接下来的链接
                if(!$url_contiune_1) {
                    return false;
                }
                //第三步: 进入引导页面

                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                curl_setopt($ch, CURLOPT_URL, $url_contiune_1);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
                curl_setopt($ch, CURLOPT_HEADER, 1);
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $content_2 = curl_exec($ch);

                //echo $postfiles; 
                curl_close($ch);

                //获取redicturl链接
                $matches = array();      
                preg_match('//i', $content_2, $matches);
                $url_contiune_2 = $matches[1]; //接下来的链接
                if(!$url_contiune_2) {
                    return false;
                }

                //跳过进入首页
                /*
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                curl_setopt($ch, CURLOPT_URL, $url_contiune_2);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
                curl_setopt($ch, CURLOPT_HEADER, 1);
                curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $content_3 = curl_exec($ch);

                curl_close($ch);
                */
                //获取邮箱请求基址 读取host
                $matches = array();      
                preg_match('/(.*?)////(.*?)//(.*?)/i', $url_contiune_2, $matches);
                $url_contiune_3 = trim($matches[1]).'//'.trim($matches[2]); //首页定义的站点基址
                $url_4 = $url_contiune_3.'/mail/ContactMainLight.aspx?n=435707983'; //n后面的数字是随机数
                if(!$url_contiune_3) {
                    return false;
                }

                //第四步: 开始获取邮箱联系人
                //base  $url_4
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
                curl_setopt($ch, CURLOPT_URL, $url_4);
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $str = curl_exec($ch);
                //分析数据 (此处的数据因为hotmail的JS处理机制,所以在页面上看不出来,源码上可以看到数据)
                return $this->hanlde_date($str);

        }
        function hanlde_date($data) {
                $new_str = array();
                if(!empty($data)) {
                        $ops_start = stripos($data,'ic_control_data');
                        $ops_end = stripos($data,';',$ops_start);
                        $new_str = substr($data, $ops_start + strlen('ic_control_data = '), $ops_end - $ops_start - strlen('ic_control_data = ') );
                        return $new_str; //返回JSON对象
                } else {
                    return array();
                }

                                   
        }
}
$msn = new MSN;
$res = $msn->getAddressList('username@111.com','123456');
echo $res;
?>


3.YAHOO
复制代码 代码如下:

define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) ); //Define the path where COOKIES is stored, and you must have permission to operate
define( "TIMEOUT", 1000 ); // Timeout setting
class YAHOO
{
private function login($username, $password)
                                 Grab the data of the login page and write down the cookies $login_url = "https: //login.yahoo.com/config/login?.src=fpctx&.intl=us&.done=http%3A%2F%2Fwww.yahoo.com%2F";
                                                                                 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl _setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            $contents = curl_exec(
$ch); ,'last','promo','intl','bypass','partner','u','v','challenge','yplus','emailCode','pkg','stepid',' ev','hasMsgr','chkP','done','pd','pad','aad');
                  $postfiles = array(); > foreach($name as $v) {
preg_match('//i', $contents, $matches);
                                                                                                                1];
                                      $matches = array();                                        $postfiles['.'.$v] = urlencode($postfiles[ '.'.$v]);
                                                                         
                $postfiles['pad'] = 5;
                $postfiles['aad'] = 6;
                $postfiles['login'] = urlencode($username);
                $postfiles['passwd'] = $password;
                $postfiles['.persistent'] = 'y';
                $postfiles['save'] = '';
                $postfiles['.done'] = urlencode($postfiles['.done']);
                //$postfiles['.pd'] = urlencode($postfiles['.pd']);
                $postargs = '';

                foreach($postfiles as $k => $v){
                    $postargs .= $k.'='.$v.'&';       
                }
                $postargs = substr($postargs,0,-1);
                $request = "https://login.yahoo.com/config/login?";

                //开始登录
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_URL, $request);

                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postargs);
                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $contents = curl_exec($ch);
                curl_close($ch);
                if (stripos($contents,'submit') != FALSE)
                {                       
                        return 0;
                }       
                return 1;
        }

        //获取邮箱通讯录-地址
        public function getAddressList($username, $password)
        {              
                if (!$this->login($username, $password))
                {
                        return 0;
                }

            //开始进入模拟抓取
            //get mail list from the page information username && emailaddress
            $url = "http://address.mail.yahoo.com/";
            $data = array( );
            if ( !$data = $this->hanlde_date( $url, $names, $emails) )
            {
                return FALSE;
            }
            echo '
';
            print_r($data);
            return $data;
        }
        function hanlde_date( $url, &$names, &$emails)
        {
            $ch = curl_init( );
            curl_setopt( $ch, CURLOPT_COOKIEFILE, COOKIEJAR );
            curl_setopt( $ch, CURLOPT_URL, $url );
            curl_setopt( $ch, CURLOPT_TIMEOUT, TIMEOUT );
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $contents = curl_exec($ch);
            curl_close($ch);
            $temparr = array();
            preg_match_all('/InitialContacts/s*=/s*(.*?);/i',$contents,$temparr);
            return $temparr[1][0].';';       //匹配出JSON对象数组
        }
}
$yahoo = new YAHOO;
$res = $yahoo->getAddressList('username@yahoo.com.cn','123456');
?>


注:
163,126在网上的源码都有,在此就不一一的列出来了哦
当然此代码是自己个人的拙作,只是为了给大家此类问题做一个指引

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327649.htmlTechArticle最近一直在忙,赶在这个假期结束的时候,发表一下此文,为了是让这些源码开源出来 当然这些方法可能不可取,但大致应该是这种方向了...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

gate.io registration tutorial gate.io registration tutorial Mar 31, 2025 pm 11:09 PM

This article provides a detailed Gate.io registration tutorial, covering every step from accessing the official website to completing registration, including filling in registration information, verifying, reading user agreements, etc. The article also emphasizes security measures after successful registration, such as setting up secondary verification and completing real-name authentication, and gives tips from beginners to help users safely start their digital asset trading journey.

gate.io latest registration tutorial for beginners gate.io latest registration tutorial for beginners Mar 31, 2025 pm 11:12 PM

This article provides newbies with detailed Gate.io registration tutorials, guiding them to gradually complete the registration process, including accessing the official website, filling in information, identity verification, etc., and emphasizes the security settings after registration. In addition, the article also mentioned other exchanges such as Binance, Ouyi and Sesame Open Door. It is recommended that novices choose the right platform according to their own needs, and remind readers that digital asset investment is risky and should invest rationally.

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

In Laravel, how to deal with the situation where verification codes are failed to be sent by email? In Laravel, how to deal with the situation where verification codes are failed to be sent by email? Mar 31, 2025 pm 11:48 PM

The method of handling Laravel's email failure to send verification code is to use Laravel...

How to get the return code when email sending fails in Laravel? How to get the return code when email sending fails in Laravel? Apr 01, 2025 pm 02:45 PM

Method for obtaining the return code when Laravel email sending fails. When using Laravel to develop applications, you often encounter situations where you need to send verification codes. And in reality...

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

The latest registration tutorial for gate.io web version The latest registration tutorial for gate.io web version Mar 31, 2025 pm 11:15 PM

This article provides a detailed Gate.io web version latest registration tutorial to help users easily get started with digital asset trading. The tutorial covers every step from accessing the official website to completing registration, and emphasizes security settings after registration. The article also briefly introduces other trading platforms such as Binance, Ouyi and Sesame Open Door. It is recommended that users choose the right platform according to their own needs and pay attention to investment risks.

See all articles