mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#212091 10/05/09 09:13 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
everytime i use sockopen -e .. the socket always ends up closing.i need to use ssl to connect to a messenger switchboard server for an msn messenger bot. any ideas why the socket would keep closing?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Probably because the remote host is closing the connection, either because it's not accepting SSL connections or mIRC doesn't support the handshake mechanism (there are subtle variations to the SSL protocol that mirc does not support)


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Make sure you are using the latest version of mIRC.
When SSL was introduced to mIRC, if you attempted to send anything on sockopen, the connection would die.

The solution was to use a signal (without -n switch) to allow the sockopen event to complete before sending any data.
It was fixed in the next version


[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
well i don't know what im doing wrong then. the msn server just isnt responding back correctly to me

Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Are you using mIRC v6.35?
Do you have the required DLL's in the mirc directory when mIRC loaded?

try this and post the output

//echo -a RES: 1 $version 2 $sslready 3 $isfile($mircdirssleay32.dll) 4 $isfile($mircdirlibeay32.dll)


[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Sorry for the late reply but it gives me

RES: 1 6.35 2 $true 3 $true 4 $true

Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Very strange, have you tried using one of the mIRC MSN clients from mIRCscripts.org?

My only guess is that you must be scripting something wrong, I guess you're having issues connecting to the switchboard... do you see the certificate acceptance dialog?


[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
I'm not sure what it is, but after opening a socket using sockopen -e, i'm just not getting any response back from the server. i'm wanting to connect to messenger using the protocol 15.

Code:
alias email return bzerk_10@msn.com

alias msnlogin {
  sockopen initial messenger.hotmail.com 1863
}

on *:SOCKOPEN:initial: {
  sockwrite -n $sockname VER 0 MSNP15 CVR0
}

on *:SOCKREAD:initial: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x

  if ($1-3 == VER 0 MSNP15) {
    sockwrite -n $sockname CVR 1 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1-2 == CVR 1) {
    sockwrite -n $sockname USR 2 TWN I bzerk_10@msn.com
  }

  ; redirection (need to use ssl when connecting to switchboard server - sockopen -e)
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58)

    sockopen -e switchboard %ip 1863
  }
}

on *:SOCKOPEN:switchboard: {
  sockwrite -n $sockname VER 0 MSNP15 CVR0
}

on *:SOCKREAD:switchboard: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x
}


The switchboard socket just seems to close after i send:

sockwrite -n $sockname VER 0 MSNP15 CVR0

This is the documentation that I'm following:
http://209.85.229.132/search?q=cache:mvF1xSZB0IcJ:www.csse.monash.edu.au/courseware/cse1370/2006/Chat/mosim.doc+msnp14+authentication&cd=8&hl=en&ct=clnk&gl=uk

I hope someone can help me out here

Last edited by pouncer; 19/05/09 03:16 PM.
Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Originally Posted By: pouncer

alias msnlogin {
sockopen initial messenger.hotmail.com 1863
}


err, that should be
Code:
sockopen -e initial...


edit: actually, I don't think the switchboard uses SSL at all, so both your sockopens shouldn't have -e

Sorry, I'm running from memory.
Basically, if the first sockopen is working, then the second one (redirect) dosn't need SSL.
If the first one isn't working - then you should be using -e for both sockopens.
The authentication server will require '-e' though.

Last edited by The_JD; 20/05/09 09:17 PM.

[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
MSNP15 returns an IP and a port to connect to in the XFR response.

Change this:

Code:
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58)

    sockopen -e switchboard %ip 1863
  }


To this:

Code:
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58), %port = $gettok($4,2,58)

    sockopen -e notification %ip %port
  }


Also, you are not connecting to the switchboard in the XFR response, you are connecting to the notification server.

The notification server is the server which sends details of your online contacts, where you send your status, personal message, etc.

The switchboard is a server that you connect to when you begin a conversation with a contact. You open a new switchboard connection for each conversation.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok, thanks for the response guys. This is the code I have now:

Code:
alias email return bzerk_10@msn.com

alias msnlogin {
  sockopen initial messenger.hotmail.com 1863
}

on *:SOCKOPEN:initial: {
  sockwrite -n $sockname VER 0 MSNP15 CVR0
}

on *:SOCKREAD:initial: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x

  if ($1-3 == VER 0 MSNP15) {
    sockwrite -n $sockname CVR 1 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1-2 == CVR 1) {
    sockwrite -n $sockname USR 2 TWN I bzerk_10@msn.com
  }

  ; redirection (need to use ssl when connecting to switchboard server - sockopen -e)
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58)

    sockopen notification %ip 1863
  }
}

on *:SOCKOPEN:notification: {
  sockwrite -n $sockname VER 0 MSNP15 CVR0
}

on *:SOCKREAD:notification: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x

  if ($1-3 == VER 0 MSNP15) {
    sockwrite -n $sockname CVR 1 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1-2 == CVR 1) {
    sockwrite -n $sockname USR 2 TWN I bzerk_10@msn.com
  }
}


The server is sending back GCF 0 6735 but i keep getting line too long erros after that:

Quote:

GCF 0 6735
-
* /tokenize: line too long (line 37, Test.mrc)
-
* /echo: insufficient parameters (line 39, Test.mrc)
-
* /tokenize: line too long (line 37, Test.mrc)
-
* /tokenize: line too long (line 37, Test.mrc)
-
* /tokenize: line too long (line 37, Test.mrc)
-


The GCF return from the server is something lie this:

GCF 0 6735\r\n
<some xml policy command here blah blah>\r\n
ticket=blah&profile=blah\r\n

and i need to pick out the ticket and profile to send the next USR command

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You didn't do what I said:

Code:
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58)

    sockopen notification %ip 1863
  }


Should be:

Code:
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58), %port = $gettok($4,2,58)

    sockopen notification %ip %port
  }


MSN can and have been known to change the ports before, so I would advise you use the port the server tells you to use and not a hardcoded one.

As for your new problem, as soon as you receive the GCF response you need to start reading data into a binary variable, like this:

Code:
elseif ($1 == GCF) {
  sockread -f $3 &data
  var %start = $calc($bfind(&data,1,ticket=) + 7), %end = $calc($bfind(&data,%start,&profile=) - 1), %ticket = $bvar(&data,$+(%start,-,%end)).text
  var %start = $calc($bfind(&data,1,&profile=) + 9), %end = $calc($bfind(&data,%start,$crlf) - 1), %profile = $bvar(&data,$+(%start,-,%end)).text
  ; Do whatever you need to with %ticket and %profile here.
}


I'm not too sure how long the ticket and profile data is going to be, so you might still get line too long errors. If you do let me know and I'll try to make a full binary variable solution instead.

Also, general tip, when working with MSNPxx protocols it's important to make sure you always get the right TRiD when communicating with the server otherwise you will be disconnected. Use this alias to make sure you always have an accurate TRiD:

Code:
alias trid {
  inc %msn. $+ $1
  return $($+(%,msn.,$1),2)
}


Then you would use it like this:

Code:
  if ($1 $3 == VER MSNP15) {
    sockwrite -n $sockname CVR $trid($sockname) 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1 == CVR) {
    sockwrite -n $sockname USR $trid($sockname) TWN I bzerk_10@msn.com
  }


Then just make sure you unset the variables when the sockets are closed:

Code:
on *:sockclose:*:{
  if ($istok(initial notification,$sockname,32)) unset %msn. $+ $sockname
}

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Thanks hixxy. i'm still having trouble however capturing the ticket and profile. here is the full code so far:

Quote:

GCF 0 6735
ticket is:
profile is:
-
* /echo: insufficient parameters (line 54, Test.mrc)
-
* /tokenize: line too long (line 52, Test.mrc)
-


Code:
alias email return bzerk_10@msn.com

alias msnlogin {
  sockopen initial messenger.hotmail.com 1863
}

alias reset {
  sockclose initial
  sockclose notification
  unset %msn.*
}

alias trid {
  inc %msn. $+ $1
  return $($+(%,msn.,$1),2)
}

on *:sockclose:*:{
  if ($istok(initial notification,$sockname,32)) unset %msn. $+ $sockname
}

on *:SOCKOPEN:initial: {
  sockwrite -n $sockname VER $trid($sockname) MSNP15 CVR0
}

on *:SOCKREAD:initial: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x

  if ($1-3 == VER 1 MSNP15) {
    sockwrite -n $sockname CVR $trid($sockname) 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1-2 == CVR 2) {
    sockwrite -n $sockname USR $trid($sockname) TWN I bzerk_10@msn.com
  }

  ; redirection (need to use ssl when connecting to switchboard server - sockopen -e)
  elseif ($1 == XFR) {
    var %ip = $gettok($4,1,58), %port = $gettok($4,2,58)

    sockopen notification %ip %port
  }
}

on *:SOCKOPEN:notification: {
  sockwrite -n $sockname VER $trid($sockname) MSNP15 CVR0
}

on *:SOCKREAD:notification: {
  var %x | sockread %x | tokenize 32 %x

  echo -a %x

  if ($1-3 == VER 1 MSNP15) {
    sockwrite -n $sockname CVR $trid($sockname) 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0328 msmsgs bzerk_10@msn.com   
  }

  elseif ($1-2 == CVR 2) {
    sockwrite -n $sockname USR $trid($sockname) TWN I bzerk_10@msn.com
  }

  elseif ($1 == GCF) {
    sockread -f $3 &data
    var %start = $calc($bfind(&data,1,t=) + 7), %end = $calc($bfind(&data,%start,&p=) - 1), %ticket = $bvar(&data,$+(%start,-,%end)).text
    var %start = $calc($bfind(&data,1,&p=) + 9), %end = $calc($bfind(&data,%start,$crlf) - 1), %profile = $bvar(&data,$+(%start,-,%end)).text
    ; Do whatever you need to with %ticket and %profile here.

    echo -a ticket is: %ticket
    echo -a profile is: %profile

    ; sockwrite -n $sockname USR $trid($sockname) TWN S t= $+ %ticket $+ &profile= $+ %profile
  }
}


I'm following this for msn documentation

http://209.85.229.132/search?q=cache:mvF1xSZB0IcJ:www.csse.monash.edu.au/courseware/cse1370/2006/Chat/mosim.doc+msnp14+authentication&cd=8&hl=en&ct=clnk&gl=uk

Last edited by pouncer; 25/05/09 03:48 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I've tried everything and it's not sending the ticket and profile... I have no idea why. It may be some kind of socket limitation.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Could this possibly be a mirc socket bug?

Last edited by pouncer; 25/05/09 09:37 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Possibly yeah. I haven't done a lot of scripting lately so I could just be doing something stupid without realising.

Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
I'm quiet sure this isn't a mIRC socket bug...

And i'm also sure (unless its changed very recently), that you're meant to get the ticket from a HTTP authentication server, and you send that to the MSNPXX servers.

Specifically: sockopen -e msn.authserver login.live.com 443

I'm quiet confident in this, because when MSN Chat was open, it was faster to use the Messenger authentication server to receive the encoded passportticket and passportprofile authentication keys


[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
pouncer's doing it the right way for MSNP15. Well, he's connecting to the right server at least.. but for whatever reason, we're not getting the correct response.

msnfanatic.com might help.. I haven't worked with the MSN Messenger protocol in-depth since MSNP11 so I'm not an expert grin

Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Possibly it's changed as you suggested, but how can he expect to receive the passportprofile and passportticket without first sending a password?

The passportticket and passportprofile can be used to log you into almost any MSN website, so I don't imagine they'd now allow you to get it without connecting to the authentication server first, and even if you can now use the normal servers for auth, you would need to send the password somewhere, wouldn't you?


[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Mar 2006
Posts: 396
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 396
Just went looking for an old passport updater I made when mIRC first enabled SSL.

Unfortunately, the links at http://www.google.com.au/search?q=jd+sslupdatefix have the URL of my old site.


[02:16] * Titanic has quit IRC (Excess Flood)
Page 1 of 2 1 2

Link Copied to Clipboard