VB/VB.Net [Resolu] Problème maj source Overedge

Inscrit
10 Mai 2012
Messages
15
Reactions
0
#1
Bonjour à tous,

Après avoir lu plusieurs fois les tutoriaux présent sur ce site je décide de me lancer et , pour commencer, de mettre à jour les sources d'overedge.

Cependant après quelques modifications j'ai déjà un problème car le programme n’envoie pas le packet 4 après avoir reçu le 3.



Voici la classe HelloConnectMessage :

Code:
Namespace Messages.Connection
    Public Class HelloConnectMessage
        Private _isInitialized As Boolean = False
        Public ConnectionType As UInteger = 0
        Private _Salt As String
        Private _Key As New List(Of Integer)()
        Public ProtocolId As UInteger = 3

        Public Function HelloConnectMessage()

            Return Me
        End Function

        Public ReadOnly Property Salt() As String
            Get
                Return _Salt
            End Get
        End Property

        Public ReadOnly Property Key() As List(Of Integer)
            Get
                Return _Key
            End Get
        End Property

        Public Function get_isInitialized() As Boolean

            Return Me._isInitialized
        End Function
        Public Function getMessageId() As UInteger

            Return ProtocolId
        End Function

        'public function pack(ByVal param1 As Client.Dofus.dofuswriter)       
        '    dim _loc_2 as * = new ByteArray()
        '    Me.serialize(_loc_2)
        '    writePacket(param1, Me.getMessageId(), _loc_2)

        '    Return Me
        'End Function
        Public Function unpack(ByVal param1 As Dofus.DofusReader)
            Me.deserialize(param1)

            Return Me
        End Function

        Public Function deserialize(ByVal param1 As Dofus.DofusReader)
            Me.deserializeAs_HelloConnectMessage(param1)

            Return Me
        End Function

        Public Sub deserializeAs_HelloConnectMessage(ByVal reader As Dofus.DofusReader)

            _Salt = reader.ReadString()
            Dim keyCount As UShort = reader.ReadUnSignedshort()

            For i As Integer = 0 To keyCount - 1
                _Key.Add(reader.ReadByte())
            Next
        End Sub
    End Class
End Namespace

Et IdentificationMessage :

Code:
Imports WindowsApplication1.Types.Version
Imports WindowsApplication1.Network.Messages.Connexion

Namespace Messages.Connection
    Public Class IdentificationMessage
        Private _isInitialized As Boolean = False
        Public version As Types.Version.Version
        Public lang As String = ""
        Public login As String = ""
        Public credentials As New List(Of Integer)
        Public serverId As Integer = 0
        Public certificate As New List(Of TrustCertificate)
        Public autoconnect As Boolean = True
        Public useCertificate As Boolean = False
        Public useLoginToken As Boolean = False
        Public protocolId As UInteger = 4
        Public Function IdentificationMessage()
            Me.Version = New Version()

            Return Me
        End Function
        Public Function get_isInitialized() As Boolean

            Return Me._isInitialized
        End Function
        Public Function getMessageId() As UInteger

            Return ProtocolId
        End Function
        Public Function initIdentificationMessage(ByVal param1 As Types.Version.Version, ByVal param2 As String, ByVal param3 As String, ByVal param4 As List(Of Integer), ByVal param5 As Integer, ByVal param6 As Boolean, ByVal param7 As Boolean, ByVal param8 As Boolean) As IdentificationMessage
            Me.version = param1
            Me.lang = param2
            Me.login = param3
            Me.credentials = param4
            Me.serverId = param5
            Me.autoconnect = param6
            Me.useCertificate = param7
            Me.useLoginToken = param8
            Me._isInitialized = True
            Return Me
        End Function

        Public Function pack()
            Dim _loc_2 As New Dofus.DofusWriter
            Me.serialize(_loc_2)
            Dofus.DofusWriter.Send(protocolId)
            Return Me
        End Function

        Public Function unpack(ByVal param1 As Dofus.DofusReader)
            Me.deserialize(param1)

            Return Me
        End Function
        Public Function serialize(ByVal param1 As Dofus.DofusWriter)
            Me.serializeAs_IdentificationMessage(param1)
            Return Me
        End Function
        Public Function serializeAs_IdentificationMessage(ByVal param1 As Dofus.DofusWriter)

            Dim _loc_2 As Integer = 0
            Dim flag As jerakine.network.utils.BooleanByteWrapper
            flag = New jerakine.network.utils.BooleanByteWrapper

            Me.autoconnect = flag.setFlag(_loc_2, 0, Me.autoconnect)
            Me.useCertificate = flag.setFlag(_loc_2, 1, Me.useCertificate)
            Me.useLoginToken = flag.setFlag(_loc_2, 2, Me.useLoginToken)

            param1.WriteByte(_loc_2)

            Me.version.serializeAs_Version(param1)
            param1.WriteUTF(Me.lang)
            param1.WriteUTF(Me.login)

            param1.WriteShort(Me.credentials.Count)
            Dim lenght As Integer = 0
            While lenght < Me.credentials.Count
                param1.WriteByte(Me.credentials(lenght))
                lenght = lenght + 1
            End While

            param1.WriteShort(Me.serverId)

            Return Me
        End Function
        Public Function deserialize(ByVal param1 As Dofus.DofusReader)
            Me.deserializeAs_IdentificationMessage(param1)

            Return Me
        End Function
        Public Function deserializeAs_IdentificationMessage(ByVal param1 As Dofus.DofusReader)

            Dim _loc_5 As Integer = 0
            Dim _loc_2 As Byte = param1.ReadByte()
            Dim flag As jerakine.network.utils.BooleanByteWrapper
            flag = New jerakine.network.utils.BooleanByteWrapper

            Me.autoconnect = flag.getFlag(_loc_2, 0)
            Me.useCertificate = flag.getFlag(_loc_2, 1)
            Me.useLoginToken = flag.getFlag(_loc_2, 2)

            Me.version = New Version()
            Me.version.deserialize(param1)
            Me.lang = param1.ReadUTF()
            Me.login = param1.ReadUTF()

            Dim _loc_3 As UShort = param1.ReadUnSignedshort()
            Dim _loc_4 As Integer

            For _loc_4 = 0 To _loc_3
                _loc_5 = param1.ReadByte()
                Me.credentials.Add(_loc_5)
            Next

            Me.serverId = param1.ReadShort()

            Return Me
        End Function

        Private Function Sock() As Object
            Throw New NotImplementedException
        End Function

    End Class
End Namespace

Puis le case 3 :

Code:
Case 3

                Dim hcm As New Messages.Connection.HelloConnectMessage
                hcm.deserialize(PacketData)

                ' Récupération de la clef

                Dim key = hcm.Key()
                Dim salt = hcm.Salt()

                ' Cryptage du pass

                Dim Account As String = NdC.Text
                Dim Password As String = MdP.Text
                Dim EncryptedPassword As List(Of Integer) = RSAManager.Encrypt(salt & Password, key)

                ' Création de la version

                Dim Version_ As New Types.Version.Version
                Version_.initVersion(2, 7, 4, 61926, 2, 0)
                Dim certificate As New List(Of TrustCertificate)

                ' Envoi du packet

                Dim Message As New Messages.Connection.IdentificationMessage
                Message.initIdentificationMessage(Version_, "fr", Account, EncryptedPassword, 0, True, False, False)
                Message.pack()

Voici ce que j'obtient :



De plus, j'utilise la classe de Maxou pour le cryptage RSA

Voilà je crois que j'ai tout dit :D
 

ToOnS

Membre Actif
Inscrit
8 Avril 2009
Messages
968
Reactions
0
#2
Re: Problème maj source Overedge

Salut , qu'as tu dans la fenetre "console" (ou "sortie" pour les versions fr) ?
 
Inscrit
10 Mai 2012
Messages
15
Reactions
0
#3
Re: Problème maj source Overedge

Merci de ta réponse rapide, j'avais pas pensé à regarder ce qu'il y avait dans la console
Voilà ce qu'il y a dedans :

Code:
[recu] : id = 1, taille = 8
0x000508000005AE00
[recu] : id = 3, taille = 330
0x000E014A00206835626A326C357A504B5A212F3C627D526C696A60542A5A7
D40605E71285535012630820122300D06092A864886F70D01010105000382010
F003082010A028201010099E5D0E1864C825DF332CF04E54A9FC6CE191AC91D
0C962F1F0279D66CDC57334C412AD54CB8EE5896548F967F16E53ED9D923E05
34C2FF55C8D0C07B6C86C84AF51F61802D7190AE1AD1E59E22FEFFC802F9D82
6875566CB75BD597F6EFD53F7D0A5D179E650F2FA219B2F2A70DA4CA8569399
137497750D991CABCDEE17AD7CDB631CC20CDC22F26D4CD1ABB9DD1D2CB95F
4E975DA18FDC65A409BE05404A920603B106E4F3455EEA8D183C665BF7308D7
BB951695C437594C0338B2D2563DB8FC7731A1CE578C94917624A86FFD904C3
7CBEF4D953A2E1079C6F999C4D2D9C292C0FD985AE53FA29A3D59A7F5CB007
91FD481A5A4D4F045E6A88F38339EDF02
[envoie] : id = 4, taille = 278
0x00020704F1E60200000266720004746573740100261EE28B305EE2A350A379
04F49194F6925A47D785736CB7AF498F5D375803CAE22242CB672184301C45A
74CC26A83F2D25E10CB78F21B73F1C4F44F0D981B48E9E3A39215ED60004B05
7939A62C29D58A233595A3E17F19A180294413472B71E37381D4D4EEF3EECA3
19F3D347AA4C74B989C588AE8B852E2F2917FC9A605AE2424316D6397B5A37C
59E812E66CF314556BF2588B05AC1722A81B6B817863426882A8193EF18BE209
83770F30F65CF6E0D14ED52D0436CCD72C1B6E18FF1F439EE9D19C5908EAF38
479D5D36ABB9A7C1EAE814F08333668DCAD80CCB9115AAAD3FF7F688C14658
EC8021C7BAFAC36B3735DB78B97DE7754F0CD031B282FC1DA0000
Donc le packet 4 est bien envoyé mais je ne reçois plus rien après, j’envoie mal mon packet ?
 

ToOnS

Membre Actif
Inscrit
8 Avril 2009
Messages
968
Reactions
0
#4
Re: Problème maj source Overedge

je ne sais plus si dans overedge la console affiche le header en octets pour les envois mais la deja y'a pas de header (bon apres peu etre que c'est envoyé et pas ecrit) , si le header est envoyé alors va falloir chercher plus en profondeur , ton pseudo dans le log me parait special , c'est bien le bon ?
essais de mettre autoconnect a 1 (pour que le 1er octet soit 01)
 
Inscrit
10 Mai 2012
Messages
15
Reactions
0
#5
Re: Problème maj source Overedge

J'ai mi l'autoconnect à 1 et maintenant j'obtient ceci :

Code:
[recu] : id = 1, taille = 8, Header = 5
0x000508000005AE00
[recu] : id = 3, taille = 330, Header = 14
0x000E014A0020683562706D6162764247506E5A575E2C6E223466546461
39217660442625723E012630820122300D06092A864886F70D0101010500
0382010F003082010A028201010095489AF091037386F4DD588614C361E0
EA50838692346ABC6AD802186252D41751890E7CFD449C3078A6AE6564B
5FA56862DE49C914237D92D56AF3F7CB81E97E15CD96F8F2446475C3F04
B95DAD8E17423CB5DC2A445616F441CAD5D4E0DBF9EF0F5E7F84AC3A9E
C92B1ACA4992079E740E764CB88ACCB38E54CCA9009E1655ED36C52593
EDA4A44D4D4A6EA89616933A7FA24D882B68E33BAFE85BBB5327027B42
2628DCADF59ADA55EE28B22B773C889AF1443B452A6C1D0B2C14E7B9EB
F312D85FAFAEB352E66B577DB697F7E2092118795947DD68E5642CA040A
FA5257162E450706E84E5F0E7EE7A0366D60E27EC6175115268354BB160
943966648CED02
[envoie] : id = 4, taille = 282, Header = 18
0x01020704F1E60200000266720008656E756D756C653101004EF234DE84
09955BCB57574EC0A7B1EB5DFFB07513AA222EB53B6749AC6D6DE84A442
25ADCC1487F442AE1C58D738FB07280531882160E657F0F714EA03DA16A
F84B74FC4507F76556A3E8A10B48A96FA8BF01A8137A7A967157AD63B4A
14578EB49AD230ECB1726535DEDDFFB8D683E6A016BE847C757E5169C0A
948160D443C642E244F87388963898C03928FE0E28DFF201354C9EB121D
AD484858EF22A3D2ACFFD3A45FC68D09FFF156325B5C32480E71A43BF4
7E442A17FFF2BEFF7805D6D6A5360FC02F4E22C1245A2E3294E8537B9E9
33A592B972BE4D6E233CB895C4DF6127DA7516D1CFFF785B165955458FD
51E31EEDB4CD4BB1B88DE45C9831DB40000
Le header me semble bon mais je ne reçois toujours pas d'autre packet.

J'ai ajouter l'affichage de la valeur du header au cas ou ça pourrai t'aider à identifier le problème.
 
Inscrit
29 Septembre 2011
Messages
393
Reactions
3
#6
Re: Problème maj source Overedge

Sa doit surement venir de ton cryptage.
 
Inscrit
10 Mai 2012
Messages
15
Reactions
0
#7
Re: Problème maj source Overedge

J'ai copier collé le cryptage de Maxou, il est pas bon ?

Je vous le met au cas ou :
Code:
Imports System.Collections.Generic
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text

Public Class RSAManager

    Private Shared Function CompareByteArrays(ByVal a As Byte(), ByVal b As Byte()) As Boolean
        If a.Length <> b.Length Then
            Return False
        End If
        Dim i As Integer = 0
        For Each c As Byte In a
            If c <> b(i) Then
                Return False
            End If
            i += 1
        Next
        Return True
    End Function

    Private Shared Function DecodeX509PublicKey(ByVal x509Key As Byte()) As RSACryptoServiceProvider

        Dim seqID As Byte() = {&H30, &HD, &H6, &H9, &H2A, &H86, _
         &H48, &H86, &HF7, &HD, &H1, &H1, _
         &H1, &H5, &H0}

        Dim mem As New MemoryStream(x509Key)
        Dim binr As New BinaryReader(mem)

        Try

            Dim twobytes As UShort = binr.ReadUInt16()

            Select Case twobytes
                Case &H8130
                    binr.ReadByte()
                Case &H8230
                    binr.ReadInt16()
                Case Else
                    Return Nothing
            End Select

            Dim seq As Byte() = binr.ReadBytes(15)
            If Not CompareByteArrays(seq, seqID) Then
                Return Nothing
            End If

            twobytes = binr.ReadUInt16()

            Select Case twobytes
                Case &H8103
                    binr.ReadByte()
                Case &H8203
                    binr.ReadInt16()
                Case Else
                    Return Nothing
            End Select

            Dim bt As Byte = binr.ReadByte()
            If bt <> &H0 Then
                Return Nothing
            End If

            twobytes = binr.ReadUInt16()

            Select Case twobytes
                Case &H8130
                    binr.ReadByte()
                Case &H8230
                    binr.ReadInt16()
                Case Else
                    Return Nothing
            End Select

            twobytes = binr.ReadUInt16()
            Dim lowbyte As Byte
            Dim highbyte As Byte = &H0

            Select Case twobytes
                Case &H8102
                    lowbyte = binr.ReadByte()
                Case &H8202
                    highbyte = binr.ReadByte()
                    lowbyte = binr.ReadByte()
                Case Else
                    Return Nothing
            End Select

            Dim modint As Byte() = {lowbyte, highbyte, &H0, &H0}
            Dim modsize As Integer = BitConverter.ToInt32(modint, 0)

            Dim firstbyte As Byte = binr.ReadByte()
            binr.BaseStream.Seek(-1, SeekOrigin.Current)

            If firstbyte = &H0 Then
                binr.ReadByte()
                modsize -= 1
            End If

            Dim modulus As Byte() = binr.ReadBytes(modsize)

            If binr.ReadByte() <> &H2 Then
                Return Nothing
            End If

            Dim expbytes As Integer = Convert.ToInt32(binr.ReadByte())
            Dim exponent As Byte() = binr.ReadBytes(expbytes)

            Dim RSA As New RSACryptoServiceProvider()

            Dim RSAKeyInfo As New RSAParameters() With { _
             .Modulus = modulus, _
             .Exponent = exponent _
            }

            RSA.ImportParameters(RSAKeyInfo)

            Return RSA

        Catch ex As Exception
            Return Nothing
        Finally
            binr.Close()
        End Try

    End Function

    Public Shared Function Encrypt(ByVal text As String, ByVal key As List(Of Integer)) As List(Of Integer)

        Dim array As Byte() = New Byte(key.Count - 1) {}
        For i As Integer = 0 To key.Count - 1
            array(i) = CByte(key(i))
        Next

        Dim rsa As RSACryptoServiceProvider = DecodeX509PublicKey(array)

        If rsa Is Nothing Then
            Return Nothing
        End If

        Dim result As Byte() = rsa.Encrypt(Encoding.UTF8.GetBytes(text), False)

        Dim intArray As New List(Of Integer)
        For Each b As Byte In result
            intArray.Add(b)
        Next

        Return intArray

    End Function

End Class
Et je l'appelle comme sa :

Code:
Dim EncryptedPassword As List(Of Integer) = RSAManager.Encrypt(salt & Password, key)
 
Inscrit
29 Septembre 2011
Messages
393
Reactions
3
#8
Re: Problème maj source Overedge

je n'utilise pas la fonction de Maxou,
essaye avec sa :
Code:
      Public Function Crypt_Pass(ByVal Input As String, ByVal Key As List(Of Integer)) As List(Of Integer)
            Dim buffer4 As Byte() = New Byte(3 - 1) {}
            buffer4(0) = 1
            buffer4(2) = 1
            Dim buffer As Byte() = buffer4
            Dim buffer2 As Byte() = New Byte(256 - 1) {}
            Dim i As Integer
            For i = 33 To 289 - 1
                buffer2((i - 33)) = CByte(Key.Item(i))
            Next i
            Dim bytes As Byte() = Encoding.UTF8.GetBytes(Input)
            Dim parameters As New RSAParameters
            Dim provider As New RSACryptoServiceProvider
            parameters.Modulus = buffer2
            parameters.Exponent = buffer
            provider.ImportParameters(parameters)
            Dim list As New List(Of Integer)
            Dim num2 As Byte
            For Each num2 In provider.Encrypt(bytes, False)
                list.Add(num2)
            Next
            Return list
        End Function
 
Inscrit
10 Mai 2012
Messages
15
Reactions
0
#9
Re: Problème maj source Overedge

Toujours rien avec ton cryptage :(

EDIT :

J'ai trouvé la solution !

En faite en comparant ce que j’envoyai et ce qu'envoyé le client, il manqué 2 octet juste après la version ( je ne sais pas d'ou il viennent par contre ...) donc j'ai juste ajouter dans Serialize de IdentificationMessage :

Code:
param1.WriteByte(1)
param1.WriteByte(1)
Quelqu'un sais à quoi servent ces 2 octets ?
 
A

Anonymous

Invité
#10
Re: Problème maj source Overedge

C'est normal, maintenant depuis une recente MAJ tu envois versionextented et non version.

Voila d'ou venait ce souci donc go traduire versionextented et modifier ton code.
 
Inscrit
10 Mai 2012
Messages
15
Reactions
0
#11
Re: Problème maj source Overedge

Ok merci je pensais pas qu'il aurais modifier cette classe :)
 
Haut Bas