0 Members and 1 Guest are viewing this topic.
Private Sub W_Connect()Text1.SelStart = Len(Text1.Text)Text1.SelText = "Connected to Channel..." & vbCrLf''''''''' Below is from CSock - Socket1_OnConnect'''HELLLLLLLLLLLLLLLLLLLLLLLLP Dim buffer() As Byte Dim wLen As Long Const m_bOldJoin As Boolean = False m_bListen = False 'Wait for first "1" Do While RecvBufferLength = 0 DoEvents Loop buffer = RecvBufferGet(1) If (buffer(0) = &H31) Then ReDim Preserve buffer(1024) Call MXSock.CreateCryptKeyID(&H57, buffer()) 'Send UP Key Block' Call Socket1.SendData(buffer())W.SendData buffer() 'Recv DW Key Block 'Get KeyBlock (16 bytes, just a lil gamble) Do While RecvBufferLength < 16 DoEvents Loop buffer = RecvBufferGet(16) 'Check Cryptkey If (GetCryptKeyID(buffer()) <> &H58) Then 'this was not crypt key from Chatserver :-(Text1.SelText = "Error Negotiating" & vbCrLf W.Close Exit Sub End If 'Get the keys Call GetCryptKey(buffer(), m_dwUPKey, m_dwDWKey) 'Prepare login buffer... ReDim buffer(5) 'Send new pre-login packet 'ED 13 01 00 31 wLen = 5 If (Not m_bOldJoin) Then buffer(0) = &HED buffer(1) = &H13 buffer(2) = &H1 buffer(3) = &H0 buffer(4) = &H31 wLen = 5 m_dwUPKey = EncryptMXTCP(buffer(), wLen, m_dwUPKey) W.SendData buffer() End If 'Login-Request: (Client) '0x0064][00:1][RoomName:N][LineType:2][Room-IP-Address:4][UDP-Port:2][SharedFiles:4][Username:N][00:1] buffer = CreateLogin(buffer()) 'put this somewhere else because it looks ugly m_dwUPKey = EncryptMXTCP(buffer(), wLen, m_dwUPKey) W.SendData buffer() Do While RecvBufferLength < 5 DoEvents Loop buffer = RecvBufferGet(5) m_dwDWKey = DecryptMXTCP(buffer(), 5, m_dwDWKey) If (buffer(0) + (buffer(1) * 256)) = &H66 Then Text1.SelText = "Login Rejected" & vbCrLf W.Close Exit Sub End If m_wNumUsers = buffer(2) + (buffer(3) * 256) Text1.SelText = "Login Granted!" & vbCrLf m_bListen = True TIMER_PING.Interval = (5 * 60) * 1000 TIMER_PING.Enabled = True 'main recv loop PacketHandling = True ' now automatically everything ends up in DispatchPacket End Ifend sub
Do While RecvBufferLength < 5 DoEvents Loop buffer = RecvBufferGet(5)
Public Declare Sub DecryptFrontCode Lib "MXSock.dll" Alias "DecryptFrontCode@8" (ByVal pSrc As String, ByVal pDst As String) Public Declare Sub DecryptMXUDP Lib "MXSock.dll" Alias "DecryptMXUDP@8" (ByVal pBuf As String, ByVal iLen As Integer) Public Declare Function GetFileHash Lib "MXSock.dll" Alias "GetFileHash@12" (ByVal lpszFileName As String, ByRef pHash As Integer, ByRef pFileLen As Long) As Integer Public Declare Sub CreateCryptKeyID Lib "MXSock.dll" Alias "CreateCryptKeyID@8" (ByVal wID As Integer, ByVal pBlock As String) Public Declare Function GetCryptKey Lib "MXSock.dll" Alias "GetCryptKey@12" (ByVal pBlock As String, ByRef pUpKey As Integer, ByRef pDwKey As Integer) As Integer Public Declare Function GetCryptKeyID Lib "MXSock.dll" Alias "GetCryptKeyID@4" (ByVal pBlock As String) As Integer Public Declare Function EncryptMXTCP Lib "MXSock.dll" Alias "EncryptMXTCP@12" (ByVal pBuf As String, ByVal iLen As Integer, ByVal dwKey As Integer) As Integer Public Declare Function DecryptMXTCP Lib "MXSock.dll" Alias "DecryptMXTCP@12" (ByVal pBuf As String, ByVal iLen As Integer, ByVal dwKey As Integer) As Integer