• Welcome to Valhalla Legends Archive.
 

Implementing BNCS Utility

Started by ### Teh Gnube ###, June 25, 2005, 03:21 PM

Previous topic - Next topic

### Teh Gnube ###

New cannot be written in lowercase, Visual Basic overrides it every time I do... And I had Packet defined incorrectly. I wasn't thinking when I was changing this code to meet my needs, and messed it up. Sorry.

UserLoser.

Is packet defined as a class module?  If not, then it's probably not an object, therefore, cannot use new.

### Teh Gnube ###

UserLoser, you were correct, but I beat you to figuring it out. Packet was SUPPOSE to be a class module. (Yes, I'm probably one of the worst programmers around for not seeing that to begin with), so New was to be used there, I have it all working now... Except for one thing.

My bot cannot pass CheckRevision, it fails every time. I am not 100% sure what this is, but I know for a fact I have the correct hashes and verbyte... ANd I'm trying to log on VIA WarCraft III. Any knowledge as to why this would happen? O_o

UserLoser.

Quote from: ### Teh Gnube ### on July 03, 2005, 07:22 PM
My bot cannot pass CheckRevision, it fails every time. I am not 100% sure what this is, but I know for a fact I have the correct hashes and verbyte... ANd I'm trying to log on VIA WarCraft III. Any knowledge as to why this would happen? O_o

Assuming you're doing everything (as in, building/formatting the message) correctly, outdated game files and/or bad version byte

### Teh Gnube ###

With P
        .InsertDWORD &H0               
        .InsertDWORD ARCH_IX86       
        .InsertDWORD CLIENT_WAR3           
        .InsertDWORD &H12           
        .InsertDWORD &H0               
        .InsertDWORD &H0               
        .InsertDWORD &H0               
        .InsertDWORD &H0               
        .InsertDWORD &H0               
        .InsertString "USA"           
        .InsertString "United States"   
       
        .Send frmMain.wS, SID_AUTH_INFO


And that is what is being sent, I assume it's all correct, it's just like the example (Exact...), unless that's incorrect somehow.

Hdx

That is fine, (Tho I don't like having hardcoded vales...)
But thats only 0x50 we need to see how you handle 0x50 S->c and build 0x51 C->S
~-~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

### Teh Gnube ###

#21
Well, since nothing was specified as to any parts you wanted to see of those things, here is how I handle 0x50:

Private Sub HandleAuthInfo(P As Packet)
    Dim mpqNumber As Long, ChecksumFormula As String
    Dim EXEVersion As Long, Checksum As Long, EXEInfo As String
    Dim HashFiles(2) As String
    Dim decoder As Long ' key decoder handle
    Dim KeyHash As String, HashLength As Long
    Dim ServerSignature As String * 128
    Dim CDKey As String
    Dim KeyOwner As Long
   
    Dim O As Packet
    Set O = New Packet
    On Error GoTo LogonError
    dAdd "[Battle.net] Parsing login information...", vbYelow
    Select Case P.GetDWORD()

        Case 0
            UseNLS = False
        Case 1
            Disconnect
            dAdd "[Local Host] Bad NLS system!", vbRed
            Exit Sub
        Case 2
            UseNLS = True
        Case Else
            Disconnect
            dAdd "[Battle.net] Bad logon sequence!", vbRed
            Exit Sub
    End Select
   
    ServerToken = P.GetDWORD()
    P.Skip 12 'Skip UDPvalue and MPQ filetime.
    mpqNumber = extractMPQNumber(P.GetString())
    If (mpqNumber < 0) Then
        Disconnect
        dAdd "[Battle.net] Bad MPQ number! (Bad hashes!)", vbRed
        Exit Sub
    End If
   
    ChecksumFormula = P.GetString()
   
    If (UseNLS) Then
        ServerSignature = P.GetFixedString(128)
        If (Not nls_check_socket_signature(frmMain.wS.SocketHandle, ServerSignature)) Then
            Disconnect
            dAdd "[Battle.net] Invalid server signature!", vbRed
        End If
    End If
   
    GetHashFiles HashFiles
   
    If (checkRevision(ChecksumFormula, HashFiles(0), HashFiles(1), _
    HashFiles(2), mpqNumber, Checksum) = False) Then
        dAdd "[Battle.net] Check Revision Failed!", vbRed
        Disconnect
        Exit Sub
       
    ElseIf (checkRevision(ChecksumFormula, HashFiles(0), HashFiles(1), _
    HashFiles(2), mpqNumber, Checksum) = True) Then
       dAdd "[Battle.net] Check Revision passed!", vbGreen
    End If
   
    ' Get EXE ver information...
    EXEVersion = getExeInfo(HashFiles(0), EXEInfo)
    If (EXEVersion = 0) Then
        Disconnect
        dAdd "[Battle.net] Failed to retrive hashing/EXE information!", vbRed
        Exit Sub
    End If
   
    ' Build SID_AUTH_CHECK
    With O
        .InsertDWORD ClientToken
        .InsertDWORD EXEVersion
        .InsertDWORD Checksum
        .InsertDWORD 1 'CDKey
        .InsertDWORD 0 ' Not using spawn.
       
        ' Decode the main CD-key.
        decoder = kd_create(CDKey1, Len(CDKey))
        If (decoder = -1) Then
            Disconnect
            dAdd "[Battle.net] Failed to decode your CD-key.", vbRed
            Exit Sub
        End If
       
        ' Calculate key hash.
        HashLength = kd_calculateHash(decoder, ClientToken, ServerToken)
        If (HashLength = 0) Then
            Disconnect
            dAdd "Failed to hash your CD-key.", vbRed
            Exit Sub
        End If
       
        ' Retrieve key hash.
        KeyHash = String$(HashLength, vbNullChar) ' Initialize buffer.
        Call kd_getHash(decoder, KeyHash)
       
        ' Adding to buffer...
        .InsertDWORD Len(CDKey1)
        .InsertDWORD kd_product(decoder)
        .InsertDWORD kd_val1(decoder)
        .InsertDWORD 0
        .InsertNonNTString KeyHash
       
        ' Release the key decoder.
        Call kd_free(decoder)
       
        .InsertString EXEInfo
        .InsertString "Jeremy Fischer"
       
        .Send frmMain.wS, SID_AUTH_CHECK
    End With
End Sub


Mmm, yeah, neat isn't it? It's just about exact as BNCSU Examble bot.

0x51, let's see, shall we? Again, it's exactly BNCSU Example bot's...

Public Sub HandleAuthCheck(P As Packet)
    Dim strTmp As String
   
    Select Case P.GetDWORD() 'Result
        Case &H0
            ' OK.
        Case &H100
            Disconnect
            dAdd "[Battle.net] Outdated game version!", vbRed
            Exit Sub
        Case &H101
            Disconnect
            dAdd "[Battle.net] Invalid game version!", vbRed
            Exit Sub
        Case &H200
            Disconnect
            dAdd "[Battle.net] Invalid CDKey!", vbRed
            Exit Sub
        Case &H201
            Disconnect
            strTmp = P.GetString()
            If LenB(strTmp) > 0 Then
            dAdd "[Battle.net] Key in use by "  & strTmp, vbRed
            Else
            dAdd "[Battle.net] Key is in use by an unknown user!", vbRed
            End If
            Exit Sub
        Case &H202
            Disconnect
            dAdd "[Battle.net] Key is banned!", vbRed
            Exit Sub
        Case &H203
            Disconnect
            dAdd "[Battle.net] Your key is for another game.", vbRed
            Exit Sub
        Case &H210 'IMPOSSIBLE FOR MY USES!
            Disconnect
            dAdd "[Fatal Error] This isn't possible, you aren't using W2XP or D2XP...", vbRed
            Exit Sub
        Case &H211
            Disconnect
            strTmp = P.GetString()
            If LenB(strTmp) > 0 Then 'Ditto
            Else
            End If
            Exit Sub
        Case &H212 'Ditto
            Disconnect
              Exit Sub
        Case &H213 'Ditto
            Disconnect
            Exit Sub
        Case Else
            Disconnect
            dAdd "[Battle.net] Authorization failed for an unknown reason!", vbRed
    End Select
   
        If UseNLS Then
            SendAuthLogon
        Else
            SendLogonResponse
        End If
End Sub


Ok, that's complete... Not original, but complete. If you need 0x53 sender as well (SendAuthLogon), I can post it, but I don't think it's necesary.


Blaze

Quote
dAdd "[Fatal Error] This isn't possible, you aren't using W2XP or D2XP...", vbRed
I didn't know w2xp was online, and that it required a second cdkey...
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

### Teh Gnube ###

Thanks * 10 for finding a typo, but I seriously doubt that one string would cause my bot to fail CRevisions... =/

Hdx

honestly/ that thing should be broken up into atleast 3 diffrent subs. One to get the CRev() info,another to get the CDKey info, another to handel extracting from 0x50 and another to handel building 0x51. It's jsut cleaner IMO.

Show us the values for your vareables, when exiting the Checkrevision() function. Also, Why are you preforming it twice... it's a waist of time.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

### Teh Gnube ###

#25
Hmmm, well, here is where I have pinpointed the error (as you probably have too...).

If (checkRevision(ChecksumFormula, HashFiles(0), HashFiles(1), _
    HashFiles(2), mpqNumber, Checksum) = False) Then
        dAdd "[Battle.net] Check Revision Failed!", vbRed
        Disconnect
        Exit Sub
'HashFiles(0) is "\WAR3\War3.exe"
'HashFiles(1) is "\WAR3\Storm.dll"
'HashFIles(2) is "\WAR3\Game.dll"


Uhhh, I think that's part of what you wanted... I may be wrong, feel free to clarify.

Hdx

Use the full path. (App.Path & "\WAR\______.___")
Also, Don't use it in the if statement. Assighn it to a boolean and then use that.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Archangel


Private Function HashFilesPath(strProduct as String)
    Select Case strProduct
        Case "SEXP", "STAR"
                HashFiles(0) = App.Path & "\STAR\starcraft.exe"
                HashFiles(1) = App.Path & "\STAR\storm.dll"
                HashFiles(2) = App.Path & "\STAR\battle.snp"
        Case "WAR3"
                HashFiles(0) = App.Path & "\WAR3\war3.exe"
                HashFiles(1) = App.Path & "\WAR3\storm.dll"
                HashFiles(2) = App.Path & "\WAR3\game.dll"
        Case "W3XP"
                HashFiles(0) = App.Path & "\W3XP\war3.exe"
                HashFiles(1) = App.Path & "\W3XP\storm.dll"
                HashFiles(2) = App.Path & "\W3XP\game.dll"
    End Select
End Function


This is just an example function of how you can establish the hashfiles.
I'm not an Addict.

shadypalm88

Quote from: Archangel on July 04, 2005, 11:34 AM

Private Function HashFilesPath(strProduct as String)
' [snipped]
End Function


This is just an example function of how you can establish the hashfiles.

Or, if he'd "tweaked" the example bot properly:
'-------------------------------------------------
'  Hash File Paths
'-------------------------------------------------
Public Sub GetHashFiles(Files() As String)
    Select Case GetClient()
        Case CLIENT_STAR, CLIENT_SEXP
            Files(0) = frmMain.txtHashFolder.Text & "\starcraft.exe"
            Files(1) = frmMain.txtHashFolder.Text & "\storm.dll"
            Files(2) = frmMain.txtHashFolder.Text & "\battle.snp"
        Case CLIENT_W2BN
            Files(0) = frmMain.txtHashFolder.Text & "\WarCraft II BNE.exe"
            Files(1) = frmMain.txtHashFolder.Text & "\storm.dll"
            Files(2) = frmMain.txtHashFolder.Text & "\battle.snp"
        Case CLIENT_D2DV, CLIENT_D2XP
            Files(0) = frmMain.txtHashFolder.Text & "\Game.exe"
            Files(1) = frmMain.txtHashFolder.Text & "\Bnclient.dll"
            Files(2) = frmMain.txtHashFolder.Text & "\D2Client.dll"
        Case CLIENT_WAR3, CLIENT_W3XP
            Files(0) = frmMain.txtHashFolder.Text & "\war3.exe"
            Files(1) = frmMain.txtHashFolder.Text & "\Storm.dll"
            Files(2) = frmMain.txtHashFolder.Text & "\Game.dll"
    End Select
End Sub

Archangel

Of you can get that function on older bots source codes. :)
I'm not an Addict.

|