• Welcome to Valhalla Legends Archive.
 

0x51 Help using BNCSUtil

Started by Archangel, May 18, 2006, 10:05 PM

Previous topic - Next topic

Archangel

Since, i always get the same response and i havnt programmed a bot since 05 i need some help, i know.. i have tried.

Edit: Response i got "0x200: Invalid CD key" and yes its a valid cd-key.


Private Sub BNCS_SID_Auth_Check(lngLogonType As Long, strMPQNumber As String, lngServerToken As Long, strChecksumFormula As String)
    AddChat frmMain.rtbChat, vbYellow, "Sending Sid_Auth_Check (0x51)."
   
    Dim lngNewMPQNumber As Long
    Dim HashFiles(2) As String
    Dim lngChecksum As Long
    Dim lngEXEVersion As Long
    Dim lngDecoder As Long
    Dim strKeyHash As String
    Dim lngHashLength As Long
    Dim strExeInfo As String
   
    lngNewMPQNumber = extractMPQNumber(strMPQNumber)
   
    If (lngNewMPQNumber < 0) Then
        DisconnectBNCS
        AddChat frmMain.rtbChat, vbRed, "Unrecognized MPQ number."
        Exit Sub
    End If
   
    GetHashFiles HashFiles
   
    If (checkRevision(strChecksumFormula, HashFiles(0), HashFiles(1), _
    HashFiles(2), lngNewMPQNumber, lngChecksum) = False) Then
        DisconnectBNCS
        AddChat frmMain.rtbChat, vbRed, "Error: CheckRevision failed."
        Exit Sub
    End If
   
    lngEXEVersion = getExeInfo(HashFiles(0), strExeInfo)
    If (lngEXEVersion = 0) Then
        DisconnectBNCS
        AddChat frmMain.rtbChat, vbRed, "Error: Failed to get executable hash file information."
        Exit Sub
    End If
   
    Dim Buffer As New clsPacketBuffer
    Set Buffer = New clsPacketBuffer
       
        With Buffer
            .iDWORD Cfg.lngClientToken     'Client token
            .iDWORD lngEXEVersion          'EXE Version
            .iDWORD lngChecksum            'EXE Hash
            .iDWORD &H1                    'Number of keys
            .iDWORD &H0                    'Boolean Spawn Cd-Key
           
        lngDecoder = kd_create(Cfg.strCdKey, Len(Cfg.strCdKey))
        If (lngDecoder = -1) Then
            DisconnectBNCS
            AddChat frmMain.rtbChat, vbRed, "Error: Failed to decode your CD-key."
            Exit Sub
        End If
       
        lngHashLength = kd_calculateHash(lngDecoder, Cfg.lngClientToken, lngServerToken)
        If (lngHashLength = 0) Then
            DisconnectBNCS
            AddChat frmMain.rtbChat, vbRed, "Error: Failed to hash your CD-key."
            Exit Sub
        End If
       
        strKeyHash = String$(lngHashLength, vbNullChar) ' Initialize buffer.
        Call kd_getHash(lngDecoder, strKeyHash)
       
            .iDWORD Len(Cfg.strCdKey)      'Cd-Key Length
            .iDWORD kd_product(lngDecoder) 'Cd-Key Product Value
            .iDWORD kd_val1(lngDecoder)    'Cd-Key Public Value
            .iDWORD &H0                    'Unknown (0)
            .iNonNTString strKeyHash       'Hashed Key Data
           
            .iNTString strExeInfo          'Exe Information
            .iNTString "BNCE"              'Cd-Key Owner
           
            .sPacket SID_Auth_Check        'Send SID_Auth_Info
        End With
       
    Set Buffer = Nothing
End Sub
I'm not an Addict.

Archangel

#1
Ok, i dont know if this might help but when i send the packet strExeInfo it starts with "(null)... " and not with "Starcraft.exe... ", i don't really know if that affects in something.

Here is the packet logging.


4  Hide  Hide  98  Send 
0000  FF 51 62 00 6B 10 05 02 0B 03 01 01 C6 E5 B0 C3    .Qb.k...........
0010  01 00 00 00 00 00 00 00 0D 00 00 00 01 00 00 00    ................
0020  43 98 58 00 00 00 00 00 EF 43 16 82 C9 DE 00 60    C.X......C.....`
0030  B9 E1 1F D6 75 67 37 E6 A9 04 43 30 28 6E 75 6C    ....ug7...C0(nul
0040  6C 29 20 30 35 2F 31 39 2F 30 36 20 30 32 3A 33    l) 05/19/06 02:3
0050  32 3A 30 35 20 31 31 34 36 39 33 39 00 42 4E 43    2:05 1146939.BNC
0060  45 00                                              E.

5  Hide  Hide  9  Recv 
0000  FF 51 09 00 00 02 00 00 00                         .Q.......
I'm not an Addict.

pianka

You may want to double check your value of HashFiles(0)--and probably the others--before passing it to checkRevision().

MysT_DooM

Maybe when your sending the

.iDWORD kd_product(lngDecoder) 'Cd-Key Product Value
            .iDWORD kd_val1(lngDecoder)    'Cd-Key Public Value


its not getting the right values; like try doin

.iDWORD Mid$(kd_product(lngDecoder), 1, 2) 'product
.iDWORD Mid$(kd_val1(lngDecoder),  3, 7) 'public


i think that might be the problem


vb6, something about that combination of numbers and letters is sexy

warz

You may also want to note that it's not starting with a null byte.

Quote
0030  B9 E1 1F D6 75 67 37 E6 A9 04 43 30 28 6E 75 6C    ....ug7...C0(nul

Archangel

#5
Quote from: MysT_DooM on May 19, 2006, 08:21 AM
Maybe when your sending the

.iDWORD kd_product(lngDecoder) 'Cd-Key Product Value
            .iDWORD kd_val1(lngDecoder)    'Cd-Key Public Value


its not getting the right values; like try doin

.iDWORD Mid$(kd_product(lngDecoder), 1, 2) 'product
.iDWORD Mid$(kd_val1(lngDecoder),  3, 7) 'public


i think that might be the problem


Tried is not this.

Quote from: warz on May 19, 2006, 08:33 AM
You may also want to note that it's not starting with a null byte.

Quote
0030 B9 E1 1F D6 75 67 37 E6 A9 04 43 30 28 6E 75 6C ....ug7...C0(nul

I dont understand what u mean by is not starting with a null byte? what is not starting with a null byte?

------------


[13:41:37] Disconnected.
[13:41:37] Connecting...
[13:41:37] Connected!
[13:41:37] Sending protocol byte: Game (0x01).
[13:41:37] Sending Sid_Auth_Info (0x50).
[13:41:38] Handeling packet: Sid_Auth_Info (0x50)
[13:41:38] Sending Sid_Auth_Check (0x51).
[13:41:38] MPQNumber: IX86ver3.mpq
[13:41:38] ServerToken: -7284
[13:41:38] Checksum Formula: A=502971062 B=688582030 C=933114557 4 A=A^S B=B^C C=C+A A=A-B
[13:41:38] NewMPQNumber: 3
[13:41:38] HashFile(0): C:\Documents and Settings\Naruto.KONOHA-48E3F658\Escritorio\DaN\Visual Basic\BNCE\STAR\Starcraft.exe
[13:41:38] HashFile(1): C:\Documents and Settings\Naruto.KONOHA-48E3F658\Escritorio\DaN\Visual Basic\BNCE\STAR\Storm.dll
[13:41:38] HashFile(2): C:\Documents and Settings\Naruto.KONOHA-48E3F658\Escritorio\DaN\Visual Basic\BNCE\STAR\Battle.snp
[13:41:38] Checksum: -2099924186
[13:41:38] ExeVersion: 16843531
[13:41:38] ExeInfo: (null) 05/19/06 02:32:05 1146939
[13:41:38] Decoder: 0
[13:41:38] Hash Length: 20
I'm not an Addict.

Ringo

Quote from: Archangel on May 19, 2006, 01:27 PM
[13:41:38] ServerToken: -7284
hi, that seems abit small for an average server token, could you be reading it as a WORD rather than a DWORD?

l2k-Shadow

Seems like the function is fine, perhaps post your GetHashFiles() function and the function from which you call this so we can have a better understanding about your issues with incorrect values for the variables.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

warz

Oh, does it literally have "(null)" in the packet log / file information string, or did you put that in there telling us that it's a 0x00 byte? If it's literally in there, I think I remember while looking at the BNCSutil source code one time, it does supply a string with "(null)" in it if there's an error in one of the functions. Maybe not, though, this is just a faint memory that this thread triggered.

Archangel

Yah im using BNCSUtil and (null) should be starcraft, here is my gethashfile funtion:


Public Sub GetHashFiles(Files() As String)
    Select Case Cfg.strProduct
        Case "STAR", "SEXP"
            Files(0) = App.Path & "\STAR\Starcraft.exe"
            Files(1) = App.Path & "\STAR\Storm.dll"
            Files(2) = App.Path & "\STAR\Battle.snp"
    End Select
End Sub


Since i cant get this done im trying to use example code to see if i can fix it, but im not doing any good.
I'm not an Addict.

l2k-Shadow

Post the function from which you call BNCS_SID_Auth_Check().
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

Archangel

#11
Quote from: l2k-Shadow on May 19, 2006, 05:32 PM
Post the function from which you call BNCS_SID_Auth_Check().


Private Sub Handle_BNCS_Sid_Auth_Info(strBuffer As clsPacketBuffer)
    AddChat frmMain.rtbChat, vbYellow, "Handleling packet: Sid_Auth_Info (0x50)"
   
    Dim lngLogonType As Long
    Dim lngServerToken As Long
    Dim lngUDPValue As Long
    'FILETIME 8 BYTES SKIP :P
    Dim strMPQNumber As String
    Dim strChecksumFormula As String
   
    lngLogonType = strBuffer.gDWORD()
    lngServerToken = strBuffer.gDWORD()
    lngUDPValue = strBuffer.gDWORD()
    strBuffer.sBytes 8
    strMPQNumber = strBuffer.gString()
    strChecksumFormula = strBuffer.gString()
   
    BNCS_SID_Auth_Check lngLogonType, strMPQNumber, lngServerToken, strChecksumFormula
End Sub
I'm not an Addict.

pianka

First: LOL@strBuffer.gString

Second: you are calling kd_init() at the beginning of your program, correct?

Archangel

Quote from: PiaNKA on May 20, 2006, 09:34 AM
First: LOL@strBuffer.gString

Second: you are calling kd_init() at the beginning of your program, correct?

im using example bot code for calling kd_init()

    On Error GoTo Startup_Error
    If (kd_init() = 0) Then
        MsgBox "The BNCSutil CD-key decoder could not be initialized, " & _
            "and the bot must close.", vbCritical, "Example Bot"
        End
    End If
I'm not an Addict.

l)ragon

Public Function CheckRev(ByVal FileExe As String, ByVal FileStormDll As String, ByVal FileBnetDll As String, ByVal HashText As String, ByRef Version As Long, ByRef Checksum As Long, ByRef exeinfo As String, ByVal mpqName As String, ByVal MyClient As String)
Dim MpqNumber As Long
Dim CRev As Boolean
    MpqNumber = extractMPQNumber(mpqName)
    CRev = (checkRevision_Raw(HashText, FileExe, FileStormDll, FileBnetDll, MpqNumber, Checksum) > 0)
    Version = getExeInfo(FileExe, exeinfo)
    If InStr(1, exeinfo, "(null)") <> 0 Then
        exeinfo = Replace(exeinfo, "(null)", GetExe(MyClient))
    End If
    Debug.Print exeinfo
End Function

Private Function GetExe(ByVal MyClient As String) As String
    Select Case MyClient
        Case "RATS", "PXES", "RHSS"
            GetExe = "Starcraft.exe"
        Case "VD2D", "PX2D"
            GetExe = "Game.exe"
        Case "3RAW", "PX3W"
            GetExe = "WAR3.exe"
        Case "RHSD"
            GetExe = "Diablo_s.exe"
        Case "RTSJ"
            GetExe = "StarcraftJ.exe"
        Case "LTRD"
            GetExe = "Diablo.exe"
        Case "NB3W"
            GetExe = "Warcraft II BNE.exe"
        Case "MD3W"
            GetExe = "War3Demo.exe"
        Case Else
            GetExe = MyClient
    End Select
End Function


here.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*