Toon posts:

[php] MSNbot script.. accepteren

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hey beste tweakers.. ik heb eigenlijk zitten twijfelen zal ik het wel of niet posten ben eerst zelf maar gaan klooien maar daar kwam helaas niets uit..

ik zit met het volgende probleem ik wil graag dat het msnbot script automatisch mensen toevoegt aan zijn lijst nu heb ik op een site gezochjt die voor velen aanbevolen werd (op phpfreakz.nl) en daar kwam ik tot de conclussie dat het commanco GTC en dan N moet zijn ik klooien ...

nu heb ik dus het volgende bij connecting staan (ik denk dat het daar moet)
$this->msn_send('CHG ' . $this->_trid++ . ' NLN');

$this->msn_send('BLP ' . $this->_trid++ . ' AL');

$this->msn_send('GTC ' . $this->_trid++ . ' N');
nu ik dit heb gedaan doet ie niets :( ook niet als ik alleen A of alleen AN neerzet hij accepteerd het gewoon niet :'( voor de mensen die niet weten waar ik het over heb:
PHP:
1
<?error_reporting(E_ALL);set_time_limit(0);class Net_MSN{    var $_user = '***';    var $_user_real = 'Nederlandse chatbot';    var $_pass = '***';    var $_msn_host = 'messenger.hotmail.com';    var $_msn_port = 1863;    var $_msn_proto = 'MSNP2';    var $_not_serv;    var $_not_port;    var $_hash = 'Q1P7W2E4J9R8U3S5';    var $_enc = 'MD5';    var $_trid = 0;    var $connected = 0;    var $_socket;    function Net_MSN()    {        $this->msn_dispatch();    }    function msn_dispatch()    {        echo "Starten msn_dispatch\n";        if ($this->_socket = fsockopen($this->_msn_host, $this->_msn_port)) {            $this->connected = true;            $this->msn_send('VER ' . $this->_trid . ' ' . $this->_msn_proto);            if (eregi('^VER ', $this->msn_recv())) {                echo "\n\nSuccessfully communicated to " . $this->_msn_host . "\n";            }            $this->msn_send('INF ' . $this->_trid++);            if (eregi('^INF ', $this->msn_recv())) {                echo "We got the encryption package...\n";            }            $this->msn_send('USR ' . $this->_trid++ . ' ' . $this->_enc . ' I ' . $this->_user);            $inbound = $this->msn_recv();            if (eregi('^XFR ', $inbound)) {                echo "User Passport information sent, awaiting transfer...\n";                @list($cmd, $trid, $type, $info, $etc) = explode(' ', $inbound);                $info = trim($info);                echo "Transfer server recv'd: " . $info . "\n";                @list($srv, $prt) = explode(':', $info);                $this->_not_serv = $srv;                $this->_not_port = $prt;                echo "Notification server + port: $srv, $prt\n";                echo "Closing connection for transfer server...\n";                $this->connected = false;                $this->msn_notification_connect();            }        }    }    function msn_notification_connect() {        echo "--------------\n\nStart msn_notifcation_connect\n";        if (!$this->connected) {            if ($this->_socket = fsockopen($this->_not_serv, $this->_not_port)) {                $this->connected = true;                $this->msn_send('VER ' . $this->_trid++ . ' ' . $this->_msn_proto);                if (eregi('^VER ', $this->msn_recv())) {                    echo "\n\nSucessfully communicated to " . $this->_not_serv . "\n";                }                $this->msn_send('INF ' . $this->_trid++);                if (eregi('^INF ', $this->msn_recv())) {                    echo "We got the encryption package...\n";                }                $this->msn_send('USR ' . $this->_trid++ . ' ' . $this->_enc . ' I ' . $this->_user);                $inbound = $this->msn_recv();                if (eregi('^USR ', $inbound)) {                    @list($cmd, $trid, $enc, $mode, $digest) = explode(' ', $inbound);                    if (trim($mode) == 'S') {                        echo "Encryption mode recv'd...\n";                        $encpass = md5(trim($digest) . $this->_pass);                        $this->msn_send('USR ' . $this->_trid++ . ' MD5 S ' . $encpass);                        echo "Encryped user password sent: " . $encpass . "\n";                    }                }                $final = $this->msn_recv();                if (eregi('^USR ', $final)) {                    @list($cmd, $trid, $stat, $usr, $sn, $etc) = explode(' ', $final);                    if (trim($stat) == 'OK') {                        echo "Server replied OK to signon...\n\n";                        $this->msn_send('CHG ' . $this->_trid++ . ' NLN');                        $this->msn_send('BLP ' . $this->_trid++ . ' AL');                        $this->msn_send('GTC ' . $this->_trid++ . ' N');                        $this->msn_send('REA ' . $this->_trid++ . ' ' . $this->_user . ' ' . urlencode($this->_user_real));                        //zelf:                        $this->msn_send('CVR '.$this->_trid++.' 0x0409 win 4.10 i386 MSMSGS 4.5.0127 MSMSGS');                    }                }            }        }    }    function msn_recv()    {        if ($this->connected) {            $d = fgets($this->_socket, 2048);            if($d != ""){                echo "<font color=blue>Received: $d</font>\n";                flush();                return $d;            } else                return false;        }    }    function msn_send($data,$raw=false)    {        if ($this->connected) {            echo "<font color=red>Sending: $data</font>\n";flush();            if($raw)                return fputs($this->_socket, $data);            else                return fputs($this->_socket, $data . "\r\n");        }    }    function msn_wait(){        //Wait for incomming chat requests:        $incomming = $this->msn_recv();        if(eregi('^RNG ', $incomming)){            $bla = new msn_user($incomming,$this->_user);        }    }} // end Net_MSNclass msn_user{    var $_socket,        $_switchip,        $_switchport,        $_id;    function msn_user($incomming,$user){        echo "nieuwe";        $this->_id = 1;        @list($cmd,$sesid,$switchip,$bla,$hash) = explode(" ",$incomming);        @list($this->_switchip,$this->_switchport) = explode(":",$switchip);        $this->_socket = fsockopen($this->_switchip, $this->_switchport) or die("Unable to connect to the switchboard");        //set_file_buffer($this->_socket,0);        //ANS 1 venky_dude@hotmail.com 989495494.750408580 11742066        $this->send("ANS",$user. " ".$hash." ".$sesid);        while(1){            $this->get();        }    }    function send($cmd,$data,$raw=false){        $data = $cmd . " ". $this->_id++ . " " . $data;        echo "<font color=red>Sending (in msn_user): $data</font>\n";flush();        if(!$raw)    $data .= "\r\n";        return fputs($this->_socket, $data);    }    function get(){        $replies = array(   ":)" => ":)",                            "hoi" => "hoi"                );        $d = fgets ($this->_socket,1024);        if (eregi('^MSG ', $d)) {            list(,$from,$fromname,$length) = explode(" ",$d);            $msg = fread($this->_socket,$length);            if(ereg("Content-Type: text/x-msmsgscontrol",$msg)) return; //hebben we niet nodig die meuk            //Strip header:            list($header,$msg) = explode("\r\n\r\n",$msg,2);            echo "Bericht: $msg\n";                if ($msg == "menu")                $this->send_msg("(*) bot's menu: (*) \r:[ botinfo \r:[ links");            else if(isset($replies[$msg])){                $this->send_msg($replies[$msg]);            }        }        flush();        return $d;    }    function send_msg($msg){        $header = "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nX-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0\r\n\r\n";        $header .= $msg;        $this->send('MSG', 'N ' . strlen($header) . "\r\n" . $header,true); //send raw data    }}//Gooi buffer vol:echo "<pre>Starten maar";for($i=0;$i<1000;$i++)    echo " ";echo "\n";flush();$msn = new Net_MSN;while($msn->connected){    $msn->msn_wait();}?>

daar bedoel ik dus mee hij wil geen nieuwe mensen automatisch accepteren :( weet iemand misschien wat ik moet toevogen? :) bedankt ik heb al op deze site gekeken:

en dat al geprobeert:
http://www.hypothetic.org/docs/msn/session.php

thx!

Verwijderd

Je moet eerst de lijst met huidige gebruikers opvragen daarna stuurt msn een "ADD" commando met een nieuwe persoon

Verwijderd

Topicstarter
Op woensdag 17 juli 2002 22:26 schreef TimD het volgende:
Je moet eerst de lijst met huidige gebruikers opvragen daarna stuurt msn een "ADD" commando met een nieuwe persoon
moet ik dan eerst het RL comnmando doen :S en daarna het add commando klopt dat snap ik dat goed?

Verwijderd

Op woensdag 17 juli 2002 22:42 schreef Godzilla het volgende:

[..]

moet ik dan eerst het RL comnmando doen :S en daarna het add commando klopt dat snap ik dat goed?
nee je vraagt eerst de lijst op (met RL ofzo) en daarna krijg je nieuwe mensen (direct na de lijst, geen extra commando's sturen). lees de site.. ik heb het ook daarvan geleerd, simpel as that

Verwijderd

De GTC code die je noemde is alleen een soort configuratie instelling voor de client, in dit geval dus je phpscript.
De MSN-server doet hier dus niets mee. Je script moet dus de call afhandelen:

Binnen de "msn_wait()" krijg je als iemand jou add dit binnen:
code:
1
ADD 0 RL <num> <username> <screenname>

Met deze commando's zet je deze persoon op het lijstje van de bot:
code:
1
2
ADD <id++> AL <username>
ADD <id++> FL <username>

Echter de kans bestaat dat iemand je probeert te adden terwijl je in een chat-sessie zit in msn_user()
Het bovenste bericht zul je dan niet ontvangen.

Beste oplossing is dus om binnen de msn_wait() regelmatig de RL (mensen die jou op hun lijstje (willen) hebben) te syncen met de AL en FL lijst.

Helaas zal dit phpscript niet uitstijgen boven een single-user/session gedrag. Een 'echte' bot zal het dus nooit worden.