Msn Connection Tutorial
By JD (enc0de)
; __________________________________________________
; | Connection Based On Tutorial By JD (enc0de) |_
; | http://jd.frandt.com/ | |
; | Find Me In %#UniteD\bScripterS On MSN | |
; | Feel Free To Use This But Please Leave This Box | |
; | Original Tutorial Available From The Site Above | |
; |_________________________________________________| |
; |_________________________________________________|
;
; Thanks to hizpower (MSHS) for testing!
;
;You Need mIRC - I Recommend mIRC 6.14 from http://mirc.com
;Now You Need Cookies Set (%Ticket, %Profile & %Subinfo)
;You Need nHTMLn_2.92.dll By Necroman
;You Need M$NChatX.ocx By Neo-Vortex
; the debug alias - just echo the stuff to @JDdebug - helps when your trying to read stuff
alias D-bug {
; if the window dosnt exist - open it
if (!$window(@JDdebug)) { window -n @JDdebug }
; echo the info
echo -t @JDdebug $+ $sockname $+ $1-
}
; so we can use the pass to our rooms
alias pass { sockwrite -tn $hget(JDct,$chan) mode $me +h $1- }
; we type /connect to connect to msn
alias connect {
; if theres no hash table - make one
if (!$hget(JDct)) { hmake JDct 100 }
; Open A Socket Called "Normal.Lookup" To The MSN Lookup Server
sockopen Normal.Lookup 207.68.167.253 6667
}
; when MSN accepts the "Normal.Lookup" socket and the socket is opened...
on 1:sockopen:Normal.Lookup:{
; add a timer to keep the socket active
.timerPPFkeepLookup 0 8 if ($sock( $+ $sockname $+ )) sockwrite -n $sockname Version
; find a port
var %port = $rand(1111,9999)
; if the port isnt free - find one that is
while (!$portfree(%port)) { var %port $rand(1111,9999) }
; open a window called "LookupOCX"
window -hpk0 @LookupOCX
; load the browser into the window
var %s = $dll($shortfn($mircdirnHTMLn_2.92.dll),attach,$window(@LookupOCX).hwnd)
; now load the M$NChatX into the window using %port
var %s = $dll($shortfn($mircdirnHTMLn_2.92.dll),navigate,about:<OBJECT ID="ChatFrame" CLASSID="CLSID:ECCDBA05-B58F-4509-AE26-CF47B2FFC3FE"><PARAM NAME="NickName" VALUE="JD"><PARAM NAME="Server" VALUE="207.68.167.253: $+ %port $+ "></OBJECT>)
; listen for the ocx on %port
socklisten PreNormalLookupOCX %port
}
; when the ocx has tried to say something...
on 1:socklisten:PreNormalLookupOCX:{
; connect to the ocx
sockaccept NormalLookupOCX
; close the listening socket
sockclose $sockname
}
; when the ocx says something...
on 1:sockread:NormalLookupOCX:{
; get the socket info from the buffer
var %buffer | sockread %buffer | tokenize 32 %buffer | D-bug $1-
; now replace the guest with passport
%buffer = $replace(%buffer,gatekeeper,GateKeeperPassport)
; if the ocx tells us that it needs to set the IRCVERS set the IRCVERS
if ($1 == IRCVERS) { sockwrite -n Normal.Lookup IRCVERS IRC8 MSN-ADMIN!9.02.0309.2602 }
; if the ocx tells us that it needs to set the Auth set the Auth
if ($1 == AUTH) { sockwrite -n Normal.Lookup %buffer }
; if the ocx tells us that it needs to set the Nick we close the OCX and let mirc take over;)
if ($1 == NICK) { sockclose $sockname | close -@ @LookupOCX }
}
; when the MSN lookup server says something...
on 1:sockread:Normal.Lookup:{
; get the socket info from the buffer
var %buffer | sockread %buffer | tokenize 32 %buffer | D-bug $1-
; if Server wants to auth...
if ($1 == AUTH) {
; if Gatekeeper is shown... show gate
if ($3 $5 == * 0) { connectmirc | set %gate $4 | echo 4 -at Lookup Auth Accepted - Logged in Anonymously ( $+ %gate $+ ) }
; if auth hasnt finished send string to the OCX
if ($4 != :ok) { sockwrite -n NormalLookupOCX $1- }
; if the auth is finished send the cookies
else { sockwrite -n $sockname AUTH GateKeeperPassport S : $+ $base($len(%ticket),10,16,8) $+ %ticket $+ $base($len(%profile),10,16,8) $+ %profile $+ $lf $+ PROP $ SUBSCRIBERINFO : $+ %subinfo }
}
; subinfo might have failed
elseif ($2 == 908) { echo 4 -st SubscriberInfo Failed - Please Update Subinfo & Type /connect }
; if gatekeeper Authentication Failed - Notify and close everything
elseif ($2 == 910) { sockclose NormalLookupOCX | sockclose $sockname | close -@ @LookupOCX | echo 4 -st Lookup $right($4-,-1) - Please Update Cookies & Type /connect }
; if the room isnt found - echo it to the active window
elseif ($2 == 702) { echo $color(info) -at $hget(JDct,chan) Not Found }
; if the room is found on MSN
elseif ($2 == 613) {
;echo the room was found
echo $color(info) -at $hget(JDct,chan) Found... Joining
; open a socket to the IP of the channel
var %sockname chan. $+ $r(A,Z) $+ $r(A,Z) $+ $r(A,Z) $+ $r(A,Z)
sockopen %sockname $right($4,-1) $5
; put a note on the socket with the rooms IP
sockmark %sockname $right($4,-1)
; add the room name with socket name to hash tables for later referencing
hadd JDct $hget(JDct,chan) %sockname
}
}
; when MSN accepts a channel socket and the socket is opened...
on 1:sockopen:chan*:{
; send nickname to channel socket
sockwrite -n $sockname NICK $me
; find a port
var %port = $rand(1111,9999)
; if the port isnt free - find one that is
while (!$portfree(%port)) { var %port $rand(1111,9999) }
; open a window named the same as the room socket
window -hpk0 @ $+ $sockname
; load the browser into the window
var %s = $dll($shortfn($mircdirnHTMLn_2.92.dll),attach,$window(@ $+ $sockname).hwnd)
; now load the M$NChatX into the window using %port
var %s = $dll($shortfn($mircdirnHTMLn_2.92.dll),navigate,about:<OBJECT ID="ChatFrame" CLASSID="CLSID:ECCDBA05-B58F-4509-AE26-CF47B2FFC3FE"><PARAM NAME="NickName" VALUE="JD"><PARAM NAME="Server" VALUE=" $+ $sock($sockname).mark $+ : $+ %port $+ "></OBJECT>)
; listen for the ocx on %port
socklisten PreChanOCX. $+ $right($sockname,4) %port
; put a note on the socket with the rooms name
sockmark $sockname $hget(JDct,chan)
}
; when the ocx has tried to say something...
on 1:socklisten:PreChanOCX.*:{
; connect to the ocx
sockaccept TheChanOCX. $+ $right($sockname,4)
; close the listening socket
sockclose $sockname
}
; when the ocx says something...
on 1:sockread:TheChanOCX.*:{
; get the socket info from the buffer
var %buffer | sockread %buffer | tokenize 32 %buffer | D-bug $1-
; set %sockvar so we know what window to close @ end of event
var %sockvar $right($sockname,4)
; now replace the guest with passport
%buffer = $replace(%buffer,gatekeeper,GateKeeperPassport)
; if the ocx tells us that it needs to set the IRCVERS set the IRCVERS
if ($1 == IRCVERS) { sockwrite -n chan. $+ $right($sockname,4) IRCVERS IRC8 MSN-Admin!9.02.0309.2602 }
; if the ocx tells us that it needs to set the Auth set the Auth
if ($1 == AUTH) {
sockwrite -n chan. $+ $right($sockname,4) %buffer
}
; if the ocx tells us that it needs to set the Nick we close the OCX and let mirc take over;)
if ($1 == NICK) { sockclose $sockname | close -@ @Chan. $+ %sockvar }
}
; when the ocx says something...
on 1:sockread:Chan*:{
; get the socket info from the buffer
var %buffer | sockread %buffer | tokenize 32 %buffer | D-bug $1-
if ($1 == AUTH) {
if ($4 != :ok) { sockwrite -n TheChanOCX. $+ $right($sockname,4) $1- | return }
; if the auth is finished send the cookies
elseif ($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 : 4,0JD'z Connection Tutorial - http://jd.frandt.com $+ $lf $+ PROP $ SUBSCRIBERINFO : $+ %subinfo $+ $lf $+ join $sock($sockname).mark 12345 | return }
}
; if the room list is sent to us - change it so mirc can read it
elseif ($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 mirc $1-5 : $+ %n | return }
; subinfo might have failed
elseif ($2 == 908) { echo 4 -st SubscriberInfo Failed - Please Update Subinfo & Type /join $sock($sockname).mark }
; heres a few raw numerics we are just going to ignore
elseif ($2 isin 001 002 003 004 251 252 253 254 255 265 266 422) { return }
; if authentication fails show us and close the related socket and window
if ($2 == 910) { sockclose TheChanOCX. $+ $right($sockname,4) | close -@ @ $+ $sockname | echo 4 -st Room $right($5-,-1) - Please Update Cookies & Type /join $sock($sockname).mark | sockclose $sockname }
; if someone joins a room...
elseif ($2 == join) {
; add the room name to hash tables - just so if we get a cloned room we can work with it
hadd JDct $right($4,-1) $sockname
; change the join so mirc can read it
sockwrite -n mirc $1-2 $4
; Display ChanServ as setting modes when user joins a room
if ($gettok($3,4,44)) { sockwrite -n mirc :ChanServ MODE $remove($4,:) + $+ $replace($gettok($3,4,44),.,q,@,o,+,v) $remove($gettok($1,1,33),:) }
; display if person is banned from talking - Nickserv sets mode +b Nickname (dosnt matter if room mode is +S)
sockwrite -n mirc :NickServ MODE $remove($4,:) $iif($ifmatch == b,+,-) $+ b $remove($gettok($1,1,33),:)
}
; if the privmsg is font related edit so mirc can use it
elseif ($2 == PRIVMSG) { $iif($left($4,3) == : S,sockwrite -n mirc $1-3 : $+ $left($6-,-1),sockwrite -n mirc $1-) | return }
else sockwrite -n mirc $1-
}
;This alias connects mirc to a socket
alias ConnectMirc {
; find a port
var %port = $rand(1111,9999)
; if the port isnt free - find one that is
while (!$portfree(%port)) { var %port $rand(1111,9999) }
; listen for mirc to connect to socket
socklisten PreMirc %port
; connect mirc to socket
server localhost %port
}
; when mirc tries to say something...
on 1:socklisten:PreMirc:{
; connect to mirc
sockaccept Mirc
; close the listening socket
sockclose $sockname
; sets the server welcome message
sockwrite -n mirc :JDct 001 $me : $+ 4Welcome To JD'z Connection Tutorial , $me
}
; when mirc says something...
on 1:sockread:Mirc:{
; get the socket info from the buffer
var %buffer | sockread %buffer | tokenize 32 %buffer | D-bug $1-
; if mirc tries to join a room
if ($1 == Join) {
; if socket exists - send the join to the socket
if ($sock($hget(JDct,$2))) { sockwrite -n $ifmatch $1- }
; or else find the room
else { sockwrite -n Normal.Lookup FINDS $2 | hadd JDct chan $2 }
}
;next three lines just send the info from mirc to the channel by getting socket names from hash tables
elseif ($sock($hget(JDct,$2))) { sockwrite -n $ifmatch $1- }
elseif ($sock($hget(JDct,$comchan($2,1)))) { sockwrite -n $ifmatch $1- }
elseif ($sock(chan*,0)) { sockwrite -n chan* $1- | halt }
}
; when mirc starts - autoconnect if cookies are set
on 1:START:{ if (%ticket) && (%profile) && (%subinfo) { connect } | else { echo 4 -st Cookies Not Set - Please Update Cookies & Type /connect } }