Jump to content
xisto Community
Sign in to follow this  
Arne-Christian

Php Msn Bot Does Not Work Right

Recommended Posts

I can send messages to it in 20-40 seconds then the bot logs out with any other messages in the debug log Then the main key, the source code: msnp9.class.php


<?php/**************************************************| MSN Protocol Class for Freakbot |**************************************************/class msn{ // messenger.hotmail.com is an exchange server // using it will redirect to a server with an open slot // using a known server ip will help connect faster // commenting out $ssh_login will mean the url to the // secure login server will be taken from a secure // session. this will slow down connecting a bit. // Note: comment out $ssh_login if you experience auth failures var $server = 'messenger.hotmail.com'; var $port = 1863; var $nexus = 'https://nexus.passport.com/rdr/pprdr.asp'; var $ssh_login = 'login.live.com/login2.srf'; var $debug = 1; // curl is used for the secure login, if you don't have // the php_curl library installed, you can use a curl binary // instead. $use_curl needs to be set to 1 to enable this. // set $curl to the path where curl is installed. // curl can be downloaded here: curl.haxx.se/download.html


var $curl_bin = 1; //var $curl = '/usr/local/bin/curl'; // linux var $curl = 'c:curlcurl.exe'; // windows /** * * desc : Connect to MSN Messenger Network * * in : $passport = passport i.e: user@hotmail.com * $password = password for passport * * out : true on success else return false * */ function connect($passport, $password) { $this->trID = 1; if ($this->fp = @fsockopen($this->server, $this->port, $errno, $errstr, 2)) { $this->_put("VER $this->trID MSNP9 CVR0rn"); while (! feof($this->fp)) { $data = $this->_get(); switch ($code = substr($data, 0, 3)) { default: echo $this->_get_error($code); return false; break; case 'VER': $this->_put("CVR $this->trID 0x0409 win 4.10 i386 MSNMSGR 7.0.0816 MSMSGS $passportrn"); break; case 'CVR': $this->_put("USR $this->trID TWN I $passportrn"); break; case 'XFR': list(, , , $ip) = explode (' ', $data); list($ip, $port) = explode (':', $ip); if ($this->fp = @fsockopen($ip, $port, $errno, $errstr, 2)) { $this->trID = 1; $this->_put("VER $this->trID MSNP9 CVR0rn"); } else { if (! empty($this->debug)) echo 'Unable to connect to msn server (transfer)'; return false; } break; case 'USR': if (isset($this->authed)) { return true; } else { $this->passport = $passport; $this->password = urlencode($password); list(,,,, $code) = explode(' ', trim($data)); if ($auth = $this->_ssl_auth($code)) { $this->_put("USR $this->trID TWN S $authrn"); $this->authed = 1; } else { if (! empty($this->debug)) echo 'auth failed'; return false; } } break; } } } else { if (! empty($this->debug)) echo 'Unable to connect to msn server'; return false; } } function rx_data() { $this->_put("SYN $this->trID 0rn"); $this->_put("PNGrn"); $this->_put("CHG $this->trID NLNrn"); $this->_put("PNGrn");$this->current_time = time(); while (! feof($this->fp)) { $xrk = time(); if($xrk == $this->current_time+10) { $this->_put("PNGrn"); $this->current_time = time(); } $data = $this->_get(); if ($data) { //echo $data.'<br />'; switch($code = substr($data, 0, 3)) { default: // uncommenting this line here would probably give a load of "error code not found" messages. //echo $this->_get_error($code); break; case 'LST': $bits = explode (' ', trim($data)); if($bits[3] == 8) { $this->_put("ADD $this->trID AL $bits[1] $bits[2]rn"); } break; case 'CHL': $bits = explode (' ', trim($data)); $return = md5($bits[2].'Q1P7W2E4J9R8U3S5'); $this->_put("QRY $this->trID msmsgs@msnmsgr.com 32rn$return"); break; case 'RNG': // someone's trying to talk to us list(, $sid, $server, , $as, $email, $name) = explode(' ', $data); list($sb_ip, $sb_port) = explode(':', $server); $sbsess = new switchboard; if ($sbsess->auth($sb_ip, $sb_port, $this->passport, $sid, $as)) { // sb session opened // recieve users message $x = 0; while($x !== 5000251) { // Here all the messages is, here you add or delete if ($msg = $sbsess->rx_im()) { $msg = strtolower($msg); if (preg_match('/*BLEEP*(.*?)$/i', $msg)) { $sbsess->tx_im($this->fp, "O *BLEEP* you too!", $this->passport, $email); } elseif(preg_match('/hi(.*?)$|hello(.*?)$|howdy(.*?)$|w(.[azz].*?)$|hey(.*?)$|sup(.*?)$/i', $msg)) { $name = str_replace("%20"," ",$name); $name = str_replace("/r","",$name); $name = str_replace("/n","",$name); $sbsess->tx_im($this->fp, "Good day $name, if your a *BLEEP*tard press 1, if your planing to kill somebody press 2, if you think i am a *BLEEP*tard press 3",$this->passport, $email); } elseif(preg_match('/date|time/i', $msg)) { $this->xtimes = date("h:m:s"); $sbsess->tx_im($this->fp,"The time is: $this->xtimes (GMT+1)...*BLEEP*",$this->passport,$email); } elseif($msg == "exit") { $sbsess->tx_im($this->fp, "Freakbot recived command: exit", $this->passport, $email); echo "<div class="msg">FreakyBot recived Exit signal from $name</div>/n"; $sbsess->im_close(); } else { // send the message straight back! $rnd = rand(0,25); if($rnd == 0) { $sbsess->tx_im($this->fp, "Go *BLEEP* a duck!", $this->passport, $email); } if($rnd == 1) { $sbsess->tx_im($this->fp, "*BLEEP* your mother!", $this->passport, $email); } if($rnd == 2) { $sbsess->tx_im($this->fp, "Your a *BLEEP*ing buthole", $this->passport, $email); } if($rnd == 3) { $sbsess->tx_im($this->fp, "Ever seen a duck *BLEEP*ing a lion? Its not a prety watch!", $this->passport, $email); } if($rnd == 4) { $sbsess->tx_im($this->fp, "*BLEEP* a horse will you?!", $this->passport, $email); } } } else { echo 'No message was received from user.'; } # $x++; } // While end } else { echo 'Unable to authenticate with switchboard.'; } break; } } } } /*====================================* Various private functions *====================================*/ function _ssl_auth($auth_string) { // Den er ikke empty doh if (empty($this->ssh_login)) { if ($this->curl_bin) { exec("$this->curl -m 60 -LkI $this->nexus", $header); $header = implode($header, null); } else { $ch = curl_init($this->nexus); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_TIMEOUT, 2); $header = curl_exec($ch); curl_close($ch); } preg_match ('/DALogin=(.*?),/', $header, $out); if (isset($out[1])) { $slogin = $out[1]; } else { return false; } } else { $slogin = $this->ssh_login; } if ($this->curl_bin) { $header1 = '"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string.'"'; exec("$this->curl -m 60 -LkI -H $header1 https://$slogin", $auth_string); $header = null; foreach ($auth_string as $key => $value) { if (strstr($value, 'Unauthorized')) { echo 'Unauthorised'; return false; } elseif (strstr($value, 'Authentication-Info')) { $header = $value; } } } else { $ch = curl_init('https://'.$slogin); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string, 'Host: login.passport.com' )); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_TIMEOUT, 2); $header = curl_exec($ch); curl_close($ch); } preg_match ("/from-PP='(.*?)'/", $header, $out); return (isset($out[1])) ? $out[1] : false; }// Reciving <<< function _get() { if ($data = @fgets($this->fp, 4096)) { $this->timex = date("h:m:s"); if ($this->debug) echo "<div class="r"><b>[{$this->timex}] Server</b>:> $data</div>n"; return $data; } else { return false; } }// Sending function _put($data) { fwrite($this->fp, $data); $this->timex = date("h:m:s"); $this->trID++; if ($this->debug) echo "<div class="g"><b>[{$this->timex}] Client</b>:> $data</div>"; } function _get_error($code) { switch ($code) { case 201: return 'Error: 201 Invalid parameter'; break; case 217: return 'Error: 217 Principal not on-line'; break; case 500: return 'Error: 500 Internal server error'; break; case 540: return 'Error: 540 Challenge response failed'; break; case 601: return 'Error: 601 Server is unavailable'; break; case 710: return 'Error: 710 Bad CVR parameters sent'; break; case 713: return 'Error: 713 Calling too rapidly'; break; case 731: return 'Error: 731 Not expected'; break; case 800: return 'Error: 800 Changing too rapidly'; break; case 910: case 921: return 'Error: 910/921 Server too busy'; break; case 911: return 'Error: 911 Authentication failed'; break; case 923: return 'Error: 923 Kids Passport without parental consent'; break; case 928: return 'Error: 928 Bad ticket'; break; default: return 'Error code '.$code.' not found'; break; } }}?>

msn_sb.class.php


<?php/**************************************************| MSN Protocol Class for Freakbot |**************************************************/class switchboard{ // font colours/styles var $font_fn = 'Arial'; var $font_co = '333333'; var $font_ef = ''; // other var $debug = 1; var $trID = 1; var $email = ''; function switchboard() { $this->session_start_time = time(); } /** * * desc : send IM message * * in : $ns = notification server connection * $msg = message to send * $passport = current logged in user * $email = user to send message to * * out : true on success else return false * */ function tx_im($ns, $msg, $passport, $email) { $message = "(anti-spam-(anti-spam-mime-version:)) 1.0rn(anti-spam-(anti-spam-content-type:)) text/plain; charset=UTF-8rnX-MMS-IM-Format: FN=$this->font_fn; EF=$this->font_ef; CO=$this->font_co; CS=0; PF=22rnrn$msg"; $message = "MSG 20 N ".strlen($message)."rn$message"; if (@is_resource($this->sb)) { // switchboard session already open $this->_put($message); return true; } else { // open switchboard session through NS fputs($ns, "XFR $this->trID SBrn"); $ns_data = fgets($ns, 4096); @list($xfr,,, $server,, $as) = explode(' ', $ns_data); if ($xfr != 'XFR') { echo 'unable to read NS info. last message: '; echo $ns_data; return false; } list($server, $port) = explode(':', $server); if ($this->sb = @fsockopen($server, $port, $errno, $errstr, 5)) { $this->_put("USR $this->trID $passport $asrn"); $this->_get(); if (is_array($email)) { foreach($email as $key => $value) { $this->_put("CAL $this->trID $valuern"); if (strstr($this->_get(), 'CAL')) { $this->_get(); // should be JOI... } } } else { $this->_put("CAL $this->trID $emailrn"); if (strstr($this->_get(), 'CAL')) { $this->_get(); // should be JOI... } } $this->_put($message); $this->timex = date("h:m:s:"); if($this->debug) echo "<div class="msg"><b>[{$this->timex}] Message</b>:> $msg</div>n"; return true; } } return false; } /** * * desc : recieve an IM from the switchboard * * in : none * out : a. null on fail/no message * b. message string * */ function rx_im() { $message = null; $msglen = null; stream_set_timeout($this->sb, 1); while (!feof($this->sb)) { $data = ($msglen) ? $this->_get($msglen) : $this->_get(); switch (substr($data, 0, 3)) { default: //if (empty($msglen)) continue; $message.= $data; if (strlen($message) >= $msglen && !empty($msglen)) { $mesg = explode("n", trim($message)); $last = end($mesg); //if (@substr($last, 0, 10) != 'TypingUser') if (!strstr($message, 'TypingUser')) { // this isn't a notification that the user is typing a message return $last; } $msglen = null; $message = null; }/* if ($this->session_start_time + 10 < time()) { // looks like we've been idle for a while echo 'IM timed out'; $this->im_close(); return null; } */ break; case 'MSG': list(,,, $msglen) = explode (' ', $data); break; case 'BYE': return null; break; } } return null; } /** * * desc : authorise with switchboard from an IM invitation * * in : $server = switchboard server ip * $port = switchboard server port * $passport = logged in users passport email * $sID = session id * $as = auth string * * out : true on success else return false * */ function auth($server, $port, $passport, $sID, $as) { if ($this->sb = @fsockopen($server, $port, $errno, $errstr, 5)) { $this->_put("ANS $this->trID $passport $as $sIDrn"); if (!$this->rx_iro()) return false; return true; } return false; } /** * * desc : recieve IRO commands from IM session * * in : none * out : true on success else return false * */ function rx_iro() { if ($data = $this->_get()) { @list($iro, , $cur_num, $tot, $email, $name) = explode(' ', $data); $sbsess->email = $email; if ($iro != 'IRO') { echo "** BAD data in rx_iro(): see line above **n"; return false; } // recieve names/list of others connected for ($i=1; $i<$tot; $i++) { if (!$data = $this->_get()) { echo "** BAD data in rx_iro(): see line above **n"; return false; } } @list($ans) = explode(' ', $this->_get()); if ($ans != 'ANS') return false; return true; } return false; } /** * * desc : close switchboard connection * * in : none * out : none * */ function im_close() { $this->_put("OUTrn"); @fclose($this->sb); } /*====================================* Various private functions *====================================*/ function _get($use_fread=0) { $data = ($use_fread) ? @fread($this->sb, $use_fread) : @fgets($this->sb, 4096); if ($data) { $this->timex = date("h:m:s"); if ($this->debug) echo "<div class="r"><b>[{$this->timex}] Server</b>:> $data</div>n"; return $data; } else { return false; } } function _put($data) { @fputs($this->sb, $data); $this->trID++; $this->timex = date("h:m:s"); if ($this->debug) echo "<div class="g"><b>[{$this->timex}] Client</b>:> $data</div>n"; }}?>

then the execute program (start.php)


<?php ob_implicit_flush(); ERROR_REPORTING(E_ALL);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd;<html xmlns="http://www.w3.org/1999/xhtml/; xml:lang="en"> <head> <title>FreakBot</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"></script> <style type="text/css" media="screen" title="default"> body { font: 76%/1.4 tahoma, verdana, arial, helvetica, sans-serif; } .r { color: red; } .g { color: green; } .b { color: black; font-family: "Courier New"; } .msg{ color: #0099CC; font: 76%/1.4 Verdana, Arial, Helvetica, sans-serif; } </style> </head> <body><div class="b">########################################</div><div class="b">##....FreakBot @ Hotmail.com MSN BOT..##</div><div class="b">##.........By El Diablo : Version 1.0.##</div><div class="b">########################################</div><?php include('msnp9.class.php'); include('msn_sb.class.php'); $msn = new msn; if ($msn->connect('fr3akb0t@hotmail.com', 'xfxas')) { // we're connected // run rx_data function to 'idle' on the network // rx_state will loop until the connection is dropped $msn->rx_data(); echo '<p>Connection dropped</p>'; } else { // wrong username and password? echo '<p>Error Connecting to the MSN Network</p>'; }?> </body></html>

Thanks for all help :unsure:


Share this post


Link to post
Share on other sites

Am trying to send a message with this code it doesn't work can anybody give me the right code please ..Case'ILN':$sbsess = new switchboard;$sbsess->tx_im($this->fp, $msg, $this->passport, $email);Please its urgent

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.