Patch WinMX ::: Developer Center ::: WinMX Encryption  ::: Visual Basic.Net Guide
Patch WinMX ::: Developer Center ::: Encryption ::: Visual Basic.Net Guide

WinMX Encryption For Visual Basic.Net:

 

The Encryption Method:


If you are planning to make a WinMX application in Visual Basic.Net you will be able to use the original MXSock.dll provided by Nushi (2Sen)'s because the .Net language supports all the necessary data types you will need. I have included an Example Chat Client made in VB.Net for you to use, study, and edit the way you want to. You may use any of the code in your own projects as long as your credit www.patchwinmx.com or www.winmxunlimited.net.

Downloads:

Download the MXSock.dll & VB.Net Class Only

Download the Example Chat Client

Decrypting/Encrypting Functions:


Below shows how to use some of the encryption functions provided with the MXSock.dll, the others are pretty easy to figure out yourself. But if you still can't ask in the forum.

 

DecryptFrontCode(ByVal pSrc() As Byte, ByVal pDst() As Byte)
When connecting to a cache server to get 10 primary nodes, they are encrypted and this is what you need to use to decrypt them.

* Input Buffer must always be 132 bytes.
* Output Buffer must always be 120 Bytes. (10 Nodes * 12 Bytes Each)

'ReceivedData excludes the 16 Byte key the cache server sends and the single byte sent at the beginning used to verify it's a WinMX Server.

Dim ReceivedData(132) As Byte

Dim DecryptedData(120) As Byte

Encryption.DecryptFrontCode(ReceivedData, DecryptedData)

 

 

CreateCryptKeyID(wID as UInt16, pBlock() as Byte:
When connecting to any WinMX Server/Client they all use encryption and you must use Encryption keys to communicate with each other to tell what you are.

* The Key Buffer must always be 16 bytes.

Dim KBuff(15) As Byte
Encryption.CreateCryptKeyID(87, KBuff)

Then you just send your byte array.

Key ID's:
80 = Primary Client
81 = Primary Server
82 = Secondary Client
83 = Secondary Server
84 = Cache Server
87 = Chat Client
88 = Chat Server

 

GetCryptKeyID(ByVal pBlock() As Byte) as UInt16:
This checks a key block for the Key ID.

* The Received Key Buffer must always be 16 bytes.

Dim ReceivedKey(15) As Byte

Sock.Receive(ReceivedKey, 16, SocketFlags.None)

Dim KeyResult As UInt16 = Encryption.GetCryptKeyID(ReceivedKey)


 

GetCryptKey(ByVal pBlock() As Byte, ByRef pUpKey As UInt32, ByRef pDwKey As
UInt32) As UInt16:
When establishing the encryption between a client and server for the WinMX network, they need to extract the encryption keys from the key blocks. There is a key for data sent and there is a key for the data received. They both mutate when run through the encryption/decryption algorithm.

* Key Buffer must always be 16 bytes.

Dim ReceivedKey(15) As Byte

Sock.Receive(ReceivedKey, 16, SocketFlags.None)

Dim UPKey As UInt32 = 0

Dim DNKey As UInt32 = 0

Encryption.GetCryptKey(ReceivedKey, UPKey, DNKey)


 

EncryptMXTCP(ByVal pBuf() As Byte, ByVal iLen As Int32, ByVal dwKey As UUnt32):
When communicating with other WinMX clients or servers on a TCP connection the data is encrypted. This function encrypts the data, and the return value is the new encryption key.

'DataBuff is your data you want to encrypt. Above is just filled with random information.

Dim DataBuff() As Byte = {2, 3, 6, 6, 4, 3, 7, 4, 3, 3, 4, 2}

UPKey = Encryption.EncryptMXTCP(DataBuff, DataBuff.Length, UPKey)

Sock.Send(DataBuff, DataBuff.Length, SocketFlags.None


 

DecryptMXTCP(ByVal pBuf As String, ByVal iLen As Long, ByVal dwKey As Long):
When communicating with other WinMX clients or servers on a TCP connection the data is encrypted. This function encrypts the data, and the return value is the new encryption key.

'DataBuff is your data you want to decrypt. Above is just filled with random information.

Dim DataBuff(PacketLength -1) As Byte

 

Sock.Receive(DataBuff, PacketLength, SocketFlags.None)

DNKey = Encryption.DecryptMXTCP(DataBuff, DataBuff.Length, DNKey)

 

 

Note: If you find any errors or have any more questions please post in the forum under the encryption section. Thanks.

 
© Copyright 2008-2009 PatchWinMX.com, All Rights Reserved.