must be an email!\n"); $user = str_replace("\n","",$user); $pass = str_replace("\n","",$pass); $this->user = strtolower(trim($user)); if($debug == "DEBUG") $this->DEBUG = true; $this->pass = $pass; $this->server();//connettiamo al server ufficiale di messenger e riceviamo l'inidirizzo del gw da usare $this->gate();//funzione di base che tiene aperta la connessione e richiama tutte le funzione per l'autenticazione } private function server() //OK { $risp = $head = ''; if($fp = fsockopen("messenger.hotmail.com",1863,$errno,$errstr,30)) { $head.= "VER 1 MSNP8 CVR0\r\n"; $head.= "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ".$this->user."\r\n"; $head.= "USR 3 TWN I ".$this->user."\r\n"; fwrite($fp,$head); while(!feof($fp)) $risp.= fread($fp,1024); fclose($fp); if($this->DEBUG) $this->dabagga($head,$risp,"messenger.hotmail.com:1863"); $this->gw = substr($risp,strpos($risp,"3 NS ")+5,strpos($risp,":1863 0")-strpos($risp,"3 NS ")-5); unset($risp,$head); } else die("Unable to open socket connection on messenger.hotmail.com:1863"); print "\n\tPlease wait...\n"; } private function gate() //OK { if($fp = fsockopen($this->gw,1863,$errno,$errstr,30)) { $risp = $head = ''; $head.= "VER 1 MSNP8 CVR0\r\n"; $head.= "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS $this->user\r\n"; $head.= "USR 3 TWN I $this->user\r\n"; fwrite($fp,$head); for($i=1;$i<=3;$i++) $risp.=fread($fp,1024); #creiamo le vars per ottenere il ticket maledetto, nexus -> redirect -> ecc ticket. $arr['ct'] = $this->ct = substr($risp,strpos($risp,"ct=")+3,strpos($risp,",rver=")-strpos($risp,"ct=")-3); $arr['rver'] = $this->rver = substr($risp,strpos($risp,",rver=")+6,strpos($risp,",wp=")-strpos($risp,",rver=")-6); $arr['wp'] = $this->wp = substr($risp,strpos($risp,",wp=")+4,strpos($risp,",lc=")-strpos($risp,",wp=")-4); $arr['lc'] = $this->lc = substr($risp,strpos($risp,",lc=")+4,strpos($risp,",id=")-strpos($risp,",lc=")-4); $arr['id'] = $this->id = substr($risp,strpos($risp,",id=")+4,strpos($risp,",ru=")-strpos($risp,",id=")-4); $arr['ru'] = $this->ru = substr($risp,strpos($risp,",ru=")+4,strpos($risp,",tw=")-strpos($risp,",ru=")-4); $arr['tw'] = $this->tw = substr($risp,strpos($risp,",tw=")+4,strpos($risp,",kpp=")-strpos($risp,",tw=")-4); $arr['kpp'] = $this->kpp = substr($risp,strpos($risp,",kpp=")+5,strpos($risp,",kv=")-strpos($risp,",kpp=")-5); $arr['kv'] = $this->kv = substr($risp,strpos($risp,",kv=")+4,strpos($risp,",ver=")-strpos($risp,",kv=")-4); $arr['ver'] = $this->ver = substr($risp,strpos($risp,",ver=")+5,strpos($risp,",rn=")-strpos($risp,",ver=")-5); $arr['rn'] = $this->rn = substr($risp,strpos($risp,",rn=")+4,strpos($risp,",tpf=")-strpos($risp,",rn=")-4); $arr['tpf'] = $this->tpf = substr($risp,strpos($risp,",tpf=")+5,strlen($risp)); if($this->DEBUG) print_r($arr); $this->nexus();//nexus -> redirect(puo essere ricorsiva) -> e continua qui sotto con USR 4 di autenticazione $last = "USR 4 TWN S $this->ticket\r\n"; fwrite($fp,$last); $risp = ""; while(!preg_match("#MPOPEnabled#",$risp)) $risp.=fread($fp,1024); if($this->DEBUG) $this->dabagga($head.$last,$risp,$this->gw.":1863"); //primo ping necessario $risp = ""; fwrite($fp,"PNG\r\n"); $risp.= fread($fp,1024); if($this->DEBUG) $this->dabagga("PNG\r\n",$risp,"+ PING!\n"); //e sopra siamo entrati, da qui in poi siamo dentro if($this->socket = $fp) { if($this->DEBUG) { print "SUCCESSFUL SOCKET COPY\n"; } } else die("fail to copy socket\n"); } else die ("Unable to connect gw :".$this->gw.":1863"); } private function nexus() //Ok { $head = $risp = $redir = ''; if($fp = fsockopen("ssl://nexus.passport.com",443,$errno,$errstr,10)) //nexus { $head.="GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"; fwrite($fp,$head); while(!feof($fp)) $risp.=fread($fp,1024); fclose($fp); $redir = substr($risp,strpos($risp,",DALogin=")+9,strpos($risp,"DAReg=")-strpos($risp,",DALogin=")-21);//primo redirect ufficiale if($this->DEBUG) $this->dabagga($head,$risp,"ssl://nexus.passport.com:443"); $this->redirect($redir); } else die("Unable to connect: ssl://nexus.passport.com:443\n"); } private function redirect($indirizzo) { $head = $risp = ''; print "\n\tPlease wait...\n"; if($sock = fsockopen("ssl://$indirizzo",443,$errno,$errstr,10)) //core { $head.= "GET /login2.srf HTTP/1.0\r\n"; $head.= "Authorization: Passport1.4 OrgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=".urlencode($this->user).",pwd=".urlencode($this->pass).",lc=".$this->lc.",id=".$this->id.",tw=".$this->tw.",fs=".$this->wp.",ru=".$this->ru.",ct=".$this->ct.",kpp=".$this->kpp.",kv=".$this->kv.",ver=".$this->ver.",rn=".$this->rn.",tpf=".$this->tpf."\r\n"; $head.= "User-Agent: MSMSGS\r\n"; $head.= "Host: $indirizzo\r\n"; $head.= "Connection: Keep-Alive\r\n"; $head.= "Cache-Control: no-cache\r\n\r\n"; fwrite($sock,$head); while(!feof($sock)) $risp.=fread($sock,1024); fclose($sock); if(preg_match("#HTTP\/1.1 200 OK#",$risp)) //se la risposta è ok estraiamo il ticket $this->ticket = substr($risp,strpos($risp,",from-PP='")+10,strpos($risp,"',ru=")-strpos($risp,",from-PP='")-10); if($this->DEBUG) { $this->dabagga($head,$risp,"ssl://$indirizzo:443"); print "TICKET: $this->ticket\n"; } if(preg_match("#HTTP\/1.1 401 Unauthorized#",$risp)) die("\tWrong username or Password...\nExit!\n"); if(preg_match("#HTTP\/1.1 302 Found#",$risp)) //ricorsiva, eseguiamo un altro redirect verso il nuovo indirizzo { $fclose($sock); $redir = substr($risp,strpos($risp,"Location: ")+10,strpos($risp,"\r\n\r\n")-strpos($risp,"Location: ")-10); $this->redirect($redir); } } else die("Unable to connect to $indirizzo\n"); } private function dabagga($sent,$received,$servername) { if(preg_match("#\+#",$servername)) print $servername; else print "\t** Connecting to $servername **\n\n"; $sent = explode("\r\n",$sent); foreach($sent as $asd) print ">>> $asd\n"; $received = explode("\r\n",$received); foreach($received as $asd) print "<<< $asd\n"; unset($sent,$received,$servername,$asd); print "\n"; } private function ping() { if($this->socket) { $risp = ""; fwrite($this->socket,"PNG\r\n"); $risp.= fread($this->socket,1024); if($this->DEBUG) $this->dabagga("PNG\r\n",$risp,"+ PING!\n"); } } public function get_list($file_name = NULL) { $return = false; if($this->socket) { $risp = ""; $list = array(); fwrite($this->socket,"SYN 5 6\r\n"); $this->ping(); while(!preg_match("#QNG#",$risp)) $risp.=fread($this->socket,1024); if(!($file_name != NULL) || !(!empty($file_name))) $file_name = "list.txt"; $work = explode("\r\n",$risp); foreach($work as $val) if($val!=""){ $ex=explode(" ",$val); if($ex[0]=="LST") $list[]=$ex[1]; } if($asd = fopen($file_name,'w')) { foreach($list as $val) fwrite($asd,$val."\n"); fclose($asd); $return = true; } else echo "ERROR WRITING FILE"; } else echo "BAD SOCKET\n"; return $return ? true : false; } public function __destruct() { if($this->socket) { fwrite($this->socket,"OUT\r\n"); if($this->DEBUG) print "Logged out\n"; } } } ?>