Well.. i made a tutorial because well... this was my life afew years ago, tinkering with things to make it run faster and blah blah.
Main Idea:
You need to open a socket to msn which will be where u send commands such as FINDS to get room ip. To connect to this socket you need to "auth" youself. this involves connecting to the msnchat ocx to send strings of data to send back to the msnserver to "auth" yourself.
Then Send The Command To get the rooms ip.
Use this ip to connect to the room. authing it again using the ocx.
Alter messages to make mirc able to read them.
Note:
This is an old connection, one of my first, and i dont think it works anymore, because of all the MSNChat updates, and how you need to pay now (gay but i have an exploit)
Code:
alias msnconnect {
unmsnconnect
;before u connect you want to make sure all the sockets are closed.
if (!$hget(conex)) { hmake conex 100 }
;this makes a hash table where info will be stored
;we need to create a socket to send info to mirc. first find a freeport
var %mircport $rand(1300,8000)
while (!$portfree(%mircport)) { var %mircport $rand(1300,8000) }
;ok we got a freeport set to %mircport. now listen on this port.
socklisten start %mircport
;were listening on a port. now connect to it.
server 127.0.0.1 %mircport
;ok now we have a to make an event for the socklisten. on*:socklisten:start: ... look down for it. then come back here.
sockopen msnserver 207.68.167.253 6667
;this connects to the msnserver
authmsnserver
;this will be an alias to auth the msnserver socket. look down.
}
alias unmsnconnect {
;closes all sockets used in the msn connection
sockclose msn*
sockclose mircserver
sockclose chan*
sockclose auth*
sockclose star*
close -@ @msnchatcontrol
}
on *:socklisten:start:{
;the ports been connected to. now accept it
sockaccept mircserver
;its been given a name. mircserver and this is where u sockwrite info u want mirc to show.
sockclose start
;close the socklistening port as its nolonger needed.
sockwrite -n mircserver :ConeX 001 $me : $+ Connecting
;this will show in the status. Connecting. change ConeX to whatever u want. it is what $server will return.
}
alias authmsnserver {
;this is to open a connection to the ocx for authing the msnsocket
var %port = $rand(1111,9999)
while (!$portfree(%port)) { var %port $rand(1111,9999) }
;same format as with the mircserver.
socklisten msnauth %port
;listen on the socket. then open the ocx through nHTMLn.dll
window -hpk0 @msnchatcontrol
var %s = $dll($shortfn($scriptdirnHTMLn.dll),attach,$window(@msnchatcontrol).hwnd)
var %s = $dll($shortfn($scriptdirnHTMLn.dll),select,$window(@msnchatcontrol).hwnd)
var %s = $dll($shortfn($scriptdirnHTMLn.dll),navigate,about: $+ $&
<OBJECT ID="ChatFrame" CLASSID="CLSID:ECCDBA05-B58F-4509-AE26-CF47B2FFC3FE"> $+ $&
<PARAM NAME="RoomName" VALUE="ConeX"> $+ $&
<PARAM NAME="NickName" VALUE="ConeX"> $+ $&
<PARAM NAME="Server" VALUE="207.68.167.253: $+ %port $+ "> $+ $&
</OBJECT>)
;now we need the socklisten event.
}
on *:socklisten:msnauth:{
sockaccept msnocx
;msnocx is the name given to the socket connected to the ocx. we need a sockread on this.
sockclose msnauth
}
on *:sockread:msnocx:{
.var %read | .sockread %read | .tokenize 32 %read
;this allows us to use $1 etc.
if ($1 == IRCVERS) || ($1 == AUTH) { sockwait msnserver $1- }
;sockwait is an alias to check wait for the socket to become active. this is because the msnserver socket takes longer to connect. u forward the msgs to the msnserver to start the auth process. it will return data which will be sent to the ocx. look for the on *:sockread:msnocx below.
if ($1 == Nick) {
sockwrite -n msnserver Nick $me
}
;this is to finish the auth process when its asked for. this will trigger alot of raws in the msnserver sockread. look below.
}
on *:sockopen:msnserver:{
.timerkeep 0 8 sockwrite -n msnserver $crlf
;this timer keeps the msnserver open.
}
on *:sockread:msnserver:{
;main msnserver sockread
.var %read | .sockread %read | .tokenize 32 %read
if ($1 == AUTH) { sockwrite -n msnocx $1- }
;this sends to the ocx to get the correct string to send back.
if ($2 == 376) {
sockwrite -n mircserver :ConeX 001 $me : $+ Connection Ready
;just a message to be seen in status.
sockclose msnocx
;the ocx has done its job and can be closed.
window -c @msnchatcontrol
;the window is nolonger needed so is closed.
;WE ARE NOW CONNECTED ( STAGE ONE COMPLETED ) we need to edit the join command in the mircserver sockread. look below for the mircserver sockread.
}
elseif ($2 == 613) {
;the room has been found. this is part of stage two. this is what triggers the next step.
hadd conex ip $+ $hget(conex,room) $remove($4,:)
;this adds to the hash table the ip that was returned for the room.
sockwrite -n mircserver :Conex 001 $me : Room Found $hget(conex,room)
;this puts a msg in status saying the room was found.
hadd conex roomid $rand(1111,9999)
;this is so we can have multi rooms. each room is assigned an "ID" . this shortens sockets and other things. also there isnt a problem with %# .
hadd conex $hget(conex,room) $hget(conex,roomid)
;asisigns the id to the room
sockopen room $+ $hget(conex,roomid) $hget(conex,ip $+ $hget(conex,room)) 6667
;this connects opening a port with the roomid on the end. this is an example of the roomips use. it connects to the ip that was retrieved in the raw.
sockmark room $+ $hget(conex,roomid) $hget(conex,room)
;marks the socket with the roomname. easy reference later on.
;now we need the ocx opened again to auth the rooms socket.
var %port = $rand(1300,8000)
while (!$portfree(%port)) { var %port = $rand(1300,8000) }
hadd conex port $+ $hget(conex,roomid) %port
;assigns a freeport to the "rooms ocx". we now connect to the ocx
window @msnchatcontrol $+ $hget(conex,roomid)
var %s = $dll($shortfn($scriptdirnHTMLn),attach,$window(@msnchatcontrol $+ $hget(conex,roomid)).hwnd)
var %s = $dll($shortfn($scriptdirnHTMLn),select,$window(@msnchatcontrol $+ $hget(conex,roomid)).hwnd)
var %s = $dll($shortfn($scriptdirnHTMLn),navigate,about: $+ $&
<OBJECT ID="ChatFrame" CLASSID="CLSID:ECCDBA05-B58F-4509-AE26-CF47B2FFC3FE"> $+ $&
<PARAM NAME="RoomName" VALUE="ConeX"> $+ $&
<PARAM NAME="NickName" VALUE="ConeX"> $+ $&
<PARAM NAME="Server" VALUE=" $+ $hget(conex,ip $+ $hget(conex,room)) $+ : $+ $hget(conex,port $+ $hget(conex,roomid)) $+ "> $+ $&
</OBJECT>)
socklisten startchan $+ $hget(conex,roomid) $hget(conex,port $+ $hget(conex,roomid))
;this is the same as before but the ip is different. its the ip from the raw. now we need a on *:socklisten:startchan*: look down again.
}
elseif ($2 == 702) {
;if raw 702 is got then the room isnt found. this is where u can have msgs for things such as room creation.
}
else sockwrite -n mircserver $1-
;for all other msgs send to the mircserver.
}
alias sockwait {
if ($sock($1)) {
if ($sock($1).status == active) {
sockwrite -n $1 $2-
}
else { .timer -m 1 20 sockwait $1 $2- }
}
}
on *:sockread:mircserver:{
.var %read | .sockread %read | .tokenize 32 %read
if ($1 == Join) {
if ($sock(room $+ $hget(conex,$2))) { sockwrite -n room $+ $hget(conex,$2)) Join $2 | return }
;if the socket is already open then send the join directly and thats it. else start opening it.
sockwrite -n msnserver FINDS $2
;sends the command to find a room. this will return raw 613 if the room is found.
hadd conex room $2
;we add the roomname to the hash table. this is a reference to later info. just returns room is being connected to later on. im expecting the room is there. so look in the msnserver sockread for raw 613. if it isnt found it is raw 702.
}
elseif ($sock(room $+ $hget(conex,$2))) { sockwrite -n room $+ $hget(conex,$2)) $1- }
elseif ($sock(room $+ $hget(conex,$comchan($2,1)))) { sockwrite -n room $+ $hget(conex,$comchan($2,1))) $1- }
elseif ($sock(room*,0)) { sockwrite -n room* $1- | halt }
}
on *:socklisten:startchan*:{
sockaccept chanocx $+ $right($sockname,4)
; $right($sockname,4) is the roomid. this allows us to keep sockets grouped. now the sockread for the ocx.
sockclose $sockname
}
on *:sockread:chanocx*:{
.var %read | .sockread %read | .tokenize 32 %read
%read = $replace(%read,gatekeeper,GateKeeperPassport)
;this switches from guest mode to passport mode. take it out for guest. however auths will also need to be changed. look at my connection for an example.
if ($1 = IRCVERS) { sockwait room $+ $right($sockname,4) %read }
if ($1 = AUTH) && ($4 != :ok) { sockwait room $+ $right($sockname,4) %read }
;these two start the auth process. now the room socket is below.
}
on *:sockread:room*: {
.var %read | .sockread %read | .tokenize 32 %read
;THIS IS THE SOCKET WHERE MOST OF YOUR EDITING WILL TAKE PLACE. THIS IS WHERE U ADD PROTECTIONS AND SUCH THINGS. also where u edit info so mirc can understand.
if ($1 = AUTH) && ($4 != :ok) {
sockwrite -n chanocx $+ $right($sockname,4) $1-
}
;part of the authprocess. just sends the string to the ocx to get the correct string back.
if ($1 = AUTH) && ($4 == :ok) {
sockwrite -n $sockname AUTH GateKeeperPassport S : $+ $base($len(%ticket),10,16,8) $+ %ticket $+ $base($len(%profile),10,16,8) $+ %profile $+ $lf $+ USER $me $me $me : $+ ConeX $+ $lf $+ Nick $me
}
;when u get :ok in the auth string the passport info needs to be sent. the info is stored as %ticket + %profile. if u get raw 910 ure passport info is outdated/incorrect . it need updating.
if ($2 = 002) { sockwrite -n $sockname JOIN $hget(conex,room) $hget(conex,$hget(conex,room)) | sockclose chanocx $+ $right($sockname,4) | close -@ @msnchatcontrol* }
; you will get raw 002 when uve finished the auth aslong as other raws. when we get this we send the join command through the server. and close the auth socket and its window as it is nolonger needed. you now have all you need to join the room. hopefully you have connected. however mirc dont know this. u need to alter the on join command.
if ($2 == JOIN) {
sockwrite -n mircserver $1 $2 $4-
;this takes out $3 which contains info about sex,profile and away status. an "msn" feature ;\ . mirc should now see people join. more importantly you join.
if ($gettok($3,4,44)) {
sockwrite -n mircserver :Server MODE $remove($4,:) + $+ $replace($gettok($3,4,44),.,q,@,o,+,v) $remove($gettok($1,1,33),:)
;this sends info like if the person entering was accessed. allows you to see them being +q,o,v etc bt "msn" .
}
halt
}
if ($2 == 353) {
.var %i = 5, %n
while (%i < $numtok($1-,32)) {
inc %i
.var %n = %n $gettok($gettok($1-,%i,32),-1,44)
}
sockwrite -n mircserver $1-5 : $+ %n
halt
}
if ($2 == PRIVMSG) {
;format font codes out so mirc can read it.
if ($left($4,3) == :S) { sockwrite -n mircserver $1-3 $+(:,$left($6-,$calc($len($6-) -1))) | return }
elseif ($4 == :VERSION) {
sockwrite -n $sockname NOTICE $gettok($gettok($1,1,33),1,58) :VERSION Connection Made With CodeX Tutorial By Cypher
;version reply
return
}
elseif ($4 == :Time) {
sockwrite -n $sockname NOTICE $gettok($gettok($1,1,33),1,58) :Time $date $+ , $time
;time reply
}
else { sockwrite -n mircserver $1- | return }
}
;this again sorts the nicks info. takes out profile,away status info out so mirc can read it.
sockwrite -n mircserver $1-
;send everything else to the mircserver.
}
I could shorten it, not sure if i should, since i want you people to understand it, i know mirc sucks (thats why i quit).
Things i might add later:
-Updater. To Update passport info when it gets old
-Auto Connect On Startup . lol not to hard.
-Protections. in the room* sockread.
-Debug Options. After .var %read | .sockread %read | .tokenize 32 %read put echo -s $sockname : $1- . then u can look at this and work out how to add things.
-Room Creation. on raw 702 open a dialog where options to make a room can be made.
-Font Options. on privmsg u want to make it how webchat can read it.
-Reopen Sockets When They Are Closed. Can Be Done With on *:sockclose: . little thought can get you relooking the msnserver socket when it closes.
__________________