• Welcome to Valhalla Legends Archive.
 

Actually calling the CheckRevision function in BNCSutil.dll

Started by option, September 23, 2007, 11:14 AM

Previous topic - Next topic

option

Alright. Here's where I am at. I am trying to perform a checkrevision with a D2 Bot I've got, using BNCSutil.dll.

Here's what I've got added to my project:

Public Declare Function extractMPQNumber Lib "bncsutil.dll" (ByVal mpqName As String) As Long
Public Declare Function checkRevision_Raw Lib "bncsutil.dll" Alias "checkRevisionFlat"
(ByVal ValueString As String, ByVal File1 As String, ByVal File2 As String, ByVal File3 As String,
ByVal mpqNumber As Long, ByRef Checksum As Long) As Long
Public Declare Function getExeInfo_Raw Lib "bncsutil.dll" Alias "getExeInfo"
(ByVal Filename As String, ByVal exeInfoString As String, ByVal infoBufferSize As Long, Version As Long,
ByVal Platform As Long) As Long


Public Function checkRevisionA(ValueString As String, Files() As String, mpqNumber As Long, Checksum As Long) As Boolean
    checkRevisionA = (checkRevision_Raw(ValueString, Files(0), Files(1), Files(2), mpqNumber, Checksum) > 0)
End Function
Public Function getExeInfo(EXEFile As String, InfoString As String, Optional ByVal Platform As Long = BNCSUTIL_PLATFORM_WINDOWS) As Long
    Dim Version As Long, InfoSize As Long, Result As Long
    Dim i&
    InfoSize = 256
    InfoString = String$(256, vbNullChar)
    Result = getExeInfo_Raw(EXEFile, InfoString, InfoSize, Version, Platform)
    If Result = 0 Then
        getExeInfo = 0
        Exit Function
    End If
    While Result > InfoSize
        If InfoSize > 1024 Then
            getExeInfo = 0
            Exit Function
        End If
        InfoSize = InfoSize + 256
        InfoString = String$(InfoSize, vbNullChar)
        Result = getExeInfo_Raw(EXEFile, InfoString, InfoSize, Version, Platform)
    Wend
    getExeInfo = Version
    i = InStr(InfoString, vbNullChar)
    If i = 0 Then Exit Function
    InfoString = Left$(InfoString, i - 1)
End Function


'Attribute VB_Name = "BNCSutil"
Option Explicit

'------------------------------------------------------------------------------
'  BNCSutil
'  Battle.Net Utility Library
'
'  Copyright © 2004-2005 Eric Naeseth
'------------------------------------------------------------------------------
'  Visual Basic Declarations
'  November 20, 2004
'------------------------------------------------------------------------------
'  This library is free software; you can redistribute it and/or
'  modify it under the terms of the GNU Lesser General Public
'  License as published by the Free Software Foundation; either
'  version 2.1 of the License, or (at your option) any later version.
'
'  This library is distributed in the hope that it will be useful,
'  but WITHOUT ANY WARRANTY; without even the implied warranty of
'  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
'  Lesser General Public License for more details.
'
'  A copy of the GNU Lesser General Public License is included in the BNCSutil
'  distribution in the file COPYING.  If you did not receive this copy,
'  write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
'  Boston, MA  02111-1307  USA
'------------------------------------------------------------------------------

'  DLL Imports
'---------------------------

' Library Information
Public Declare Function bncsutil_getVersion Lib "bncsutil.dll" () As Long
Public Declare Function bncsutil_getVersionString_Raw Lib "bncsutil.dll" _
    Alias "bncsutil_getVersionString" (ByVal outBuf As String) As Long

' CheckRevision
Public Declare Function extractMPQNumber Lib "bncsutil.dll" _
    (ByVal mpqName As String) As Long
' [!] You should use checkRevision and getExeInfo (see below) instead of their
'     _Raw counterparts.
Public Declare Function checkRevision_Raw Lib "bncsutil.dll" Alias "checkRevisionFlat" _
    (ByVal ValueString As String, ByVal File1 As String, ByVal File2 As String, _
     ByVal File3 As String, ByVal mpqNumber As Long, ByRef Checksum As Long) As Long
Public Declare Function getExeInfo_Raw Lib "bncsutil.dll" Alias "getExeInfo" _
    (ByVal Filename As String, ByVal exeInfoString As String, _
    ByVal infoBufferSize As Long, Version As Long, ByVal Platform As Long) As Long

' Old Logon System
' [!] You should use doubleHashPassword and hashPassword instead of their
'     _Raw counterparts.  (See below for those functions.)
Public Declare Sub doubleHashPassword_Raw Lib "bncsutil.dll" Alias "doubleHashPassword" _
    (ByVal Password As String, ByVal ClientToken As Long, ByVal ServerToken As Long, _
    ByVal outBuffer As String)
Public Declare Sub hashPassword_Raw Lib "bncsutil.dll" Alias "hashPassword" _
    (ByVal Password As String, ByVal outBuffer As String)

' Broken SHA-1
Public Declare Sub calcHashBuf Lib "bncsutil.dll" _
    (ByVal Data As String, ByVal Length As Long, ByVal Hash As String)

' CD-Key Decoding

' Call kd_init() first to set up the decoding system, unless you are only using kd_quick().
' Then call kd_create() to create a key decoder "handle" each time you want to
' decode a CD-key.  It will return the handle or -1 on failure.  The handle
' should then be passed as the "decoder" argument to all the other kd_ functions.
' Call kd_free() on the handle when finished with the decoder to free the
' memory it is using.

Public Declare Function kd_quick Lib "bncsutil.dll" _
    (ByVal CDKey As String, ByVal ClientToken As Long, ByVal ServerToken As Long, _
    PublicValue As Long, Product As Long, ByVal HashBuffer As String, ByVal BufferLen As Long) As Long
Public Declare Function kd_init Lib "bncsutil.dll" () As Long
Public Declare Function kd_create Lib "bncsutil.dll" _
    (ByVal CDKey As String, ByVal keyLength As Long) As Long
Public Declare Function kd_free Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
Public Declare Function kd_val2Length Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
Public Declare Function kd_product Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
Public Declare Function kd_val1 Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
Public Declare Function kd_val2 Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
Public Declare Function kd_longVal2 Lib "bncsutil.dll" _
    (ByVal decoder As Long, ByVal Out As String) As Long
Public Declare Function kd_calculateHash Lib "bncsutil.dll" _
    (ByVal decoder As Long, ByVal ClientToken As Long, ByVal ServerToken As Long) As Long
Public Declare Function kd_getHash Lib "bncsutil.dll" _
    (ByVal decoder As Long, ByVal Out As String) As Long
Public Declare Function kd_isValid Lib "bncsutil.dll" _
    (ByVal decoder As Long) As Long
   
'New Logon System

' Call nls_init() to get a "handle" to an NLS object (nls_init will return 0
' if it encounters an error).  This "handle" should be passed as the "NLS"
' argument to all the other nls_* functions.  You do not need to change the
' username and password to upper-case as nls_init() will do this for you.
' Call nls_free() on the handle to free the memory it's using.
' nls_account_create() and nls_account_logon() generate the bodies of
' SID_AUTH_ACCOUNTCREATE and SID_AUTH_ACCOUNTLOGIN packets, respectively.

Public Declare Function nls_init Lib "bncsutil.dll" _
    (ByVal Username As String, ByVal Password As String) As Long 'really returns a POINTER!
Public Declare Function nls_init_l Lib "bncsutil.dll" _
    (ByVal Username As String, ByVal Username_Length As Long, _
    ByVal Password As String, ByVal Password_Length As Long) As Long
Public Declare Function nls_reinit Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Username As String, ByVal Password As String) As Long
Public Declare Function nls_reinit_l Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Username As String, ByVal Username_Length As Long, _
    ByVal Password As String, ByVal Password_Length As Long) As Long
Public Declare Sub nls_free Lib "bncsutil.dll" _
    (ByVal NLS As Long)
Public Declare Function nls_account_create Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Buffer As String, ByVal BufLen As Long) As Long
Public Declare Function nls_account_logon Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Buffer As String, ByVal BufLen As Long) As Long
Public Declare Sub nls_get_A Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Out As String)
Public Declare Sub nls_get_M1 Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Out As String, ByVal B As String, ByVal Salt As String)
Public Declare Function nls_check_M2 Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal M2 As String, ByVal B As String, ByVal Salt As String) As Long
Public Declare Function nls_check_signature Lib "bncsutil.dll" _
    (ByVal Address As Long, ByVal Signature As String) As Long
Public Declare Function nls_account_change_proof Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Buffer As String, ByVal NewPassword As String, _
    ByVal B As String, ByVal Salt As String) As Long 'returns a new NLS pointer for the new password
Public Declare Sub nls_get_S Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Out As String, ByVal B As String, ByVal Salt As String)
Public Declare Sub nls_get_K Lib "bncsutil.dll" _
    (ByVal NLS As Long, ByVal Out As String, ByVal S As String)
   
Private Declare Function bncsutil_debug_status Lib "bncsutil.dll" () As Long
Private Declare Function bncsutil_set_debug_status Lib "bncsutil.dll" (ByVal NewStatus As Long) As Long
Private Declare Sub bncsutil_debug_message Lib "bncsutil.dll" (ByVal Message As String)
Private Declare Sub bncsutil_debug_dump Lib "bncsutil.dll" (ByVal Message As String, ByVal Length As Long)
Private Declare Function bncsutil_internal_debug_messages Lib "bncsutil.dll" () As Long
   
'  Constants
'---------------------------
Public Const BNCSUTIL_PLATFORM_X86& = &H1
Public Const BNCSUTIL_PLATFORM_WINDOWS& = &H1
Public Const BNCSUTIL_PLATFORM_WIN& = &H1

Public Const BNCSUTIL_PLATFORM_PPC& = &H2
Public Const BNCSUTIL_PLATFORM_MAC& = &H2

Public Const BNCSUTIL_PLATFORM_OSX& = &H3

'  Winsock
'---------------------------
Private Type sockaddr_in
    Family As Integer
    Port As Integer
    Address As Long
    Filler As String * 8
End Type

Private Declare Function getsockname Lib "ws2_32.dll" (ByVal S As Long, Name As sockaddr_in, NameLen As Long) As Long


'---------------------------------------'
'  VB-Specifc Functions and Properties  '
'---------------------------------------'

Public Property Get Version() As String
    Version = bncsutil_getVersionString()
End Property

Public Property Get DebugMode() As Boolean
    DebugMode = (bncsutil_debug_status() <> 0)
End Property

Public Property Let DebugMode(ByVal NewValue As Boolean)
    If (NewValue) Then
        bncsutil_set_debug_status 1
    Else
        bncsutil_set_debug_status 0
    End If
End Property

Public Property Get InternalDebugMessages() As Boolean
    InternalDebugMessages = (bncsutil_internal_debug_messages() <> 0)
End Property

Public Sub DebugMessage(Message As String)
    bncsutil_debug_message Message
End Sub

Public Sub DebugHexDump(Data As String, Optional ByVal Length As Long = -1)
    If (Length = -1) Then
        Length = Len(Data)
    End If
   
    bncsutil_debug_dump Data, Length
End Sub


' RequiredVersion must be a version as a.b.c
' Returns True if the current BNCSutil version is sufficent, False if not.
Public Function bncsutil_checkVersion(ByVal RequiredVersion As String) As Boolean
    Dim i&, j&
    Dim Frag() As String
    Dim Req As Long, Check As Long
    bncsutil_checkVersion = False
    Frag = Split(RequiredVersion, ".")
    j = 0
    For i = UBound(Frag) To 0 Step -1
        Check = Check + (CLng(Val(Frag(i))) * (100 ^ j))
        j = j + 1
    Next i
    Check = bncsutil_getVersion()
    If (Check >= Req) Then
        bncsutil_checkVersion = True
    End If
End Function

Public Function bncsutil_getVersionString() As String
    Dim S As String * 12
    Dim Length As Long
    Length = bncsutil_getVersionString_Raw(S)
    bncsutil_getVersionString = Left$(S, Length)
End Function

'CheckRevision
Public Function checkRevision(ValueString As String, File1$, File2$, File3$, mpqNumber As Long, Checksum As Long) As Boolean
    checkRevision = (checkRevision_Raw(ValueString, File1, File2, File3, mpqNumber, Checksum) > 0)
End Function

Public Function checkRevisionA(ValueString As String, Files() As String, mpqNumber As Long, Checksum As Long) As Boolean
    checkRevisionA = (checkRevision_Raw(ValueString, Files(0), Files(1), Files(2), mpqNumber, Checksum) > 0)
End Function

'EXE Information
'Information string (file name, date, time, and size) will be placed in InfoString.
'InfoString does NOT need to be initialized (e.g. InfoString = String$(255, vbNullChar))
'Returns the file version or 0 on failure.
Public Function getExeInfo(EXEFile As String, InfoString As String, Optional ByVal Platform As Long = BNCSUTIL_PLATFORM_WINDOWS) As Long
    Dim Version As Long, InfoSize As Long, Result As Long
    Dim i&
    InfoSize = 256
    InfoString = String$(256, vbNullChar)
    Result = getExeInfo_Raw(EXEFile, InfoString, InfoSize, Version, Platform)
    If Result = 0 Then
        getExeInfo = 0
        Exit Function
    End If
    While Result > InfoSize
        If InfoSize > 1024 Then
            getExeInfo = 0
            Exit Function
        End If
        InfoSize = InfoSize + 256
        InfoString = String$(InfoSize, vbNullChar)
        Result = getExeInfo_Raw(EXEFile, InfoString, InfoSize, Version, Platform)
    Wend
    getExeInfo = Version
    i = InStr(InfoString, vbNullChar)
    If i = 0 Then Exit Function
    InfoString = Left$(InfoString, i - 1)
End Function

'OLS Password Hashing
Public Function doubleHashPassword(Password As String, ByVal ClientToken&, ByVal ServerToken&) As String
    Dim Hash As String * 20
    doubleHashPassword_Raw Password, ClientToken, ServerToken, Hash
    doubleHashPassword = Hash
End Function

Public Function hashPassword(Password As String) As String
    Dim Hash As String * 20
    hashPassword_Raw Password, Hash
    hashPassword = Hash
End Function

Public Function nls_check_socket_signature(ByVal SocketHandle As Long, Signature As String) As Boolean
    Dim NameLen As Long, Name As sockaddr_in
   
    NameLen = 16
    getsockname SocketHandle, Name, NameLen
   
    nls_check_socket_signature = (nls_check_signature(Name.Address, Signature) <> 0)
End Function


Thanks to andy for providing the code above as well as the BNCSutil.dll file.

Alright, what's next? What is ACTUALLY involved in the process of local hashing, using the functions above? I've got the files, just need to know what to do with em. I have no clue how the process works. After I get some input, I will attempt to write something and then post it here (if it doesn't work :P)

Thanks in advance.

[Kp edit: split long lines.]
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

l2k-Shadow

call CheckRevision() to retrieve checksum. call getExeInfo(..) to retrieve version and exe information.
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.

option

Alright, yeah I kind of figured that was how it's done, but what's the deal with getExeInfo? What is that information needed for? Do you need that stuff FOR the checkrevision?

And for crev function, you say it's checkrevision(), but I thought it was checkrevisionA? And for inputs, it takes files(0), files(1), files (2), which are the hash files, Game.exe, Bnclient.dll, and D2client.dll. What about mpqNumber and Checksum, the two parts at the end?

Also does it matter where I declare the files(2) array? Do I put the path to the files or just the name of the files?
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

Hdx

checksum is a long that the result of checkrevision will be put into.
It's the checksum thats sent in C->S 0x51
As for exe info, thats the exeinfo thats sent in c->s 0x51
Please note that local hashing only works for d2/wc3 and only if you have the latest bncsutil.dll. (if you got ti from andy then you should have the latest)
take a look at the signatures of checkrevision and checkrevisiona
1 takes an array
the other takes the names.
Just depends on how you want to do it.
And the files have to be the FULL path.
~Hdx

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

option

Quote from: Hdx on September 23, 2007, 12:01 PM
checksum is a long that the result of checkrevision will be put into.
It's the checksum thats sent in C->S 0x51
As for exe info, thats the exeinfo thats sent in c->s 0x51
Please note that local hashing only works for d2/wc3 and only if you have the latest bncsutil.dll. (if you got ti from andy then you should have the latest)
take a look at the signatures of checkrevision and checkrevisiona
1 takes an array
the other takes the names.
Just depends on how you want to do it.
And the files have to be the FULL path.
~Hdx

Alright that was helpful. What about mpqNumber?

EDIT: and ValueString?
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

Hdx

Thats the data you get from s->c 0x50.
You pass in the archive name to the extractMQNNumber function (or w/e its name is.)
or you could do it yourself.
"ver-IX86-1.mpq" you grab the 1, but you have to remember "1" != 1 so you need to asc() it and then - asc("0")
As for the value string, thats the string thats like "A=12345 B=12345 C=12345 4 A=A*b ....." you get from S->C 0x50.
~Hdx

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

brew

Quote from: Hdx on September 23, 2007, 12:16 PM
Thats the data you get from s->c 0x50.
You pass in the archive name to the extractMQNNumber function (or w/e its name is.)
or you could do it yourself.
"ver-IX86-1.mpq" you grab the 1, but you have to remember "1" != 1 so you need to asc() it and then - asc("0")
As for the value string, thats the string thats like "A=12345 B=12345 C=12345 4 A=A*b ....." you get from S->C 0x50.
~Hdx
um, it's been a while, but doesn't asc() return the ascii character code?... he wants the binary value 1 for the mpqnumber, not 0x31. he should use CLng() if he can provide the string without any other goofy characters messing it up, or Val() (if he didn't get rid of the ".mpq" at the end or whatever.)
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

option

mpqNumber isn't the issue, ValueString is. I'm confused how to parse that in VB.
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

l2k-Shadow

it's just a string. take it out of the message and put it into a string variable then send it to bncsutil.
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.

Hdx

You're right, val() would work. Sorry I haven't used VB in a long ass time.
Java it's archive.charAt(pos) - '0'
~Hdx

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

option

Alright so in VB, something along these lines?

Dim ValueString As String: ValueString = Mid(Data, (start as Long), [Length])

Data is the packet, 0x50.

EDIT: Maybe this will help clarify. I have this VB control that was given to me by a friend, called BNETLogon, written by some dude that makes bots, penguin or something along those lines.

Hdx told me the best way to learn was to do, so having this code, I've been trying to pick it apart and get the checkrevision working again, so I can code a program to work with this control, to get a handle on functions and how they work before I start coding in C++. The old checkrevision it had didn't work, so I thought that I'd learn a thing or two by adding BNCSutil's checkrevision but I am failing miserably.

Here's the code where &H50 (0x50) is parsed:
Private Sub ParseBNET(Data As String)
On Error Resume Next

Dim Result As Integer

Select Case Asc(Mid(Data, 2, 1))

Case &H50
Servers = Val("&h" & StrToHex(StrReverse(Mid(Data, 9, 4))))
Hash = Mid$(Mid$(Data, 34), InStr(Mid$(Data, 34), vbNullChar) + 1, InStr(Mid$(Mid$(Data, 34), InStr(Data, vbNullChar) + 1), vbNullChar))
Hash = Replace(Hash, vbNullChar, vbNullString)
Dim ExeInfo As String
ExeInfo = Space(256)
DBLKey = GetTickCount()
Dim mpqName As String: mpqName = Mid(Data, 25, 12)


Select Case Product
Case "VD2D"
Result = checkRevision(ValueString, HashPath & "Game.exe", HashPath & "Bnclient.dll", HashPath & "d2client.dll", mpqNumber, Checksum)
Case "PX2D"
Result = checkRevision(ValueString, HashPath & "Game.exe", HashPath & "Bnclient.dll", HashPath & "d2client.dll", mpqNumber, Checksum)
End Select

If Result = 0 Then
RaiseEvent CheckRevisionResult(False, vbNullString, "Hashes could not be found.")
sckBNET.CloseSck
Exit Sub
End If

ExeInfo = Mid(ExeInfo, 1, InStr(ExeInfo, vbNullChar) - 1)

Call AddToBuffer(3, DBLKey)
Call AddToBuffer(3, Version)
Call AddToBuffer(3, Checksum)
If Product = "PX2D" Then Call AddToBuffer(3, &H2)
If Not Product = "PX2D" Then Call AddToBuffer(3, &H1)
Call AddToBuffer(3, &H0)

'CDKey #1
Dim ProdID As Long, Value1 As Long, Value2 As Long
Decode.DecodeCDKey UCase(CDKey), ProdID, Value1, Value2

Call AddToBuffer(3, Len(CDKey))
Call AddToBuffer(3, ProdID)
Call AddToBuffer(3, Value1)
Call AddToBuffer(3, &H0)

Dim outBuf As String, tmpBuf As String, CDKeyHashBuf(6) As String
CDKeyHashBuf(0) = MakeDWORD(DBLKey)
CDKeyHashBuf(1) = MakeDWORD(Servers)
CDKeyHashBuf(2) = MakeDWORD(ProdID)
CDKeyHashBuf(3) = MakeDWORD(Value1)
CDKeyHashBuf(4) = MakeDWORD(&H0)
CDKeyHashBuf(5) = MakeDWORD(Value2)
tmpBuf = Join(CDKeyHashBuf(), vbNullString)
outBuf = String(20, vbNullChar)
Call CopyMemory(outBuf, BrokenSHA.calcHashBuf(tmpBuf), 5 * 4)
Call AddToBuffer(4, outBuf)

'CDKey #2 is applicable
Dim ProdID2 As Long, Value12 As Long, Value22 As Long
Decode.DecodeCDKey UCase(CDKey2), ProdID2, Value12, Value22

If Product = "PX2D" Then
Call AddToBuffer(3, Len(CDKey2))
Call AddToBuffer(3, ProdID2)
Call AddToBuffer(3, Value12)
Call AddToBuffer(3, &H0)

Dim OutBuf2 As String, tmpBuf2 As String, CDKeyHashBuf2(6) As String
CDKeyHashBuf2(0) = MakeDWORD(DBLKey)
CDKeyHashBuf2(1) = MakeDWORD(Servers)
CDKeyHashBuf2(2) = MakeDWORD(ProdID2)
CDKeyHashBuf2(3) = MakeDWORD(Value12)
CDKeyHashBuf2(4) = MakeDWORD(&H0)
CDKeyHashBuf2(5) = MakeDWORD(Value22)
tmpBuf2 = Join(CDKeyHashBuf2(), vbNullString)
OutBuf2 = String(20, vbNullChar)
Call CopyMemory(OutBuf2, BrokenSHA.calcHashBuf(tmpBuf2), 5 * 4)
Call AddToBuffer(4, OutBuf2)
End If

Call AddToBuffer(5, ExeInfo)
Call AddToBuffer(5, CDKeyOwner)
Call SendPacket("BNCS", &H51)

Case &H25
If Use0msPing = False Then
Call AddToBuffer(4, Mid(Data, 5, 4))
Call SendPacket("BNCS", &H25)
End If

Case &H26
Dim SplitProfile() As String
SplitProfile = Split(Mid$(Data, 17), vbNullChar)

Select Case ProfileRequest
Case "Profile"
RaiseEvent ReceiveProfile(ProfiledUser, SplitProfile(0), SplitProfile(1), SplitProfile(2), SplitProfile(3))
Case "Account"
RaiseEvent ReceiveAccountInfo(SplitProfile(1), Functions.Convert_time(SplitProfile(2)),
Functions.Convert_time(SplitProfile(0)), Functions.Convert_time(SplitProfile(3)), FormatC(SplitProfile(4)))
Case Else: GoTo OtherPacket
End Select

ProfiledUser = vbNullString
ProfileRequest = vbNullString

Case &H51
Select Case GetWORD(Mid(Data, 5, 2))
Case &H0
RaiseEvent CheckRevisionResult(True, vbNullString, vbNullString)
If UsePlug = False Then
Call AddToBuffer(4, "tenb")
Call SendPacket("BNCS", &H14)
Else
Call AddToBuffer(4, "bnet")
Call SendPacket("BNCS", &H14)
End If
If ChangePassword = True Then
Dim OutB5 As String * 20, TmpOutBuf5 As String, PWHashBuf5(2) As String
Dim OutB6 As String * 20
Call AddToBuffer(3, DBLKey)
Call AddToBuffer(3, Servers)
PWHashBuf5(0) = MakeDWORD(DBLKey)
PWHashBuf5(1) = MakeDWORD(Servers)
TmpOutBuf5 = Join(PWHashBuf5, vbNullString) & BrokenSHA.calcHashBuf(Password)
OutB5 = BrokenSHA.calcHashBuf(TmpOutBuf5)
Call AddToBuffer(4, OutB5)
Call CopyMemory(OutB6, BrokenSHA.calcHashBuf(NewPassword), 5 * 4)
Call AddToBuffer(4, OutB6)
Call SendPacket("BNCS", &H31)
Else
Dim OutB As String * 20, TmpOutBuf As String, PWHashBuf(2) As String
Call AddToBuffer(3, DBLKey)
Call AddToBuffer(3, Servers)
PWHashBuf(0) = MakeDWORD(DBLKey)
PWHashBuf(1) = MakeDWORD(Servers)
TmpOutBuf = Join(PWHashBuf, vbNullString) & BrokenSHA.calcHashBuf(Password)
OutB = BrokenSHA.calcHashBuf(TmpOutBuf)
Call AddToBuffer(4, OutB)
Call AddToBuffer(5, Username)
Call SendPacket("BNCS", &H3A)
End If

Case &H101: RaiseEvent CheckRevisionResult(False, &H101, "Invalid game version!")
Case &H100: RaiseEvent CheckRevisionResult(False, &H100, "Game version out of date!")
Case &H200: RaiseEvent CheckRevisionResult(False, &H200, "Invalid CD-Key!")
Case &H201: RaiseEvent CheckRevisionResult(False, &H201, "Your CD-Key is in use by " &
Mid(Data, 9, InStr(Mid(Data, 9), vbNullChar) - 1))
Case &H202: RaiseEvent CheckRevisionResult(False, &H202, "Your CD-Key is banned by Battle.net!")
Case &H203: RaiseEvent CheckRevisionResult(False, &H203, "Your CD-Key is for a different product!")
Case &H210: RaiseEvent CheckRevisionResult(False, &H210, "Invalid Expansion CD-Key!")
Case &H211: RaiseEvent CheckRevisionResult(False, &H211, "Your Expansion CD-Key is in use by " &
Mid(Data, 9, InStr(Mid(Data, 9), vbNullChar) - 1))
Case &H212: RaiseEvent CheckRevisionResult(False, &H212, "Your Expansion CD-Key is banned by Battle.net!")
Case &H213: RaiseEvent CheckRevisionResult(False, &H213, "Your Expansion CD-key has invalid product code.")
End Select

Case &H3A
Select Case Asc(Mid(Data, 5, 1))
Case &H0
RaiseEvent PasswordHashResult(True, vbNullString)
If UseRealm = True Then
If Product = "PX2D" Or Product = "VD2D" Then
Call AddToBuffer(3, &H0)
Call AddToBuffer(3, &H0)
Call AddToBuffer(1, &H0)
Call SendPacket("BNCS", &H34)
End If
Else
Call AddToBuffer(5, Username)
Call AddToBuffer(1, &H0)
Call SendPacket("BNCS", &HA)
Call AddToBuffer(4, Product)
Call SendPacket("BNCS", &HB)
Call AddToBuffer(3, &H1)
Call AddToBuffer(5, "L")
Call SendPacket("BNCS", &HC)
End If
Case &H1
Result = MsgBox("Account does not exist, would you like to create?", vbYesNo + vbQuestion)
If Result = vbYes Then
Dim CreateBuf As String * 20
Call CopyMemory(CreateBuf, BrokenSHA.calcHashBuf(Password), 5 * 4)
Call AddToBuffer(4, CreateBuf)
Call AddToBuffer(5, Username)
Call SendPacket("BNCS", &H3D)
Else
RaiseEvent PasswordHashResult(False, "Failed to logon! Account Does Not exist!")
End If
Case &H2: RaiseEvent PasswordHashResult(False, "Failed to logon! An incorrect password was supplied!")
End Select

Case &H3D
Select Case Asc(Mid(Data, 5, 1))
Case &H0
RaiseEvent CreateAccountResult(True, vbNullString)
Dim OutB2 As String * 20, TmpOutBuf2 As String, PWHashBuf2(2) As String
Call AddToBuffer(3, DBLKey)
Call AddToBuffer(3, Servers)
PWHashBuf2(0) = MakeDWORD(DBLKey)
PWHashBuf2(1) = MakeDWORD(Servers)
TmpOutBuf2 = Join(PWHashBuf2, vbNullString) & BrokenSHA.calcHashBuf(Password)
OutB2 = BrokenSHA.calcHashBuf(TmpOutBuf2)
Call AddToBuffer(4, OutB2)
Call AddToBuffer(5, Username)
Call SendPacket("BNCS", &H3A)
Case &H1: RaiseEvent CreateAccountResult(False, "Error: Too short, must be atleast 3 characters long!")
Case &H2: RaiseEvent CreateAccountResult(False, "Error: Invalid characters in the name!")
Case &H3: RaiseEvent CreateAccountResult(False, "Error: Invalid words!")
Case &H4: RaiseEvent CreateAccountResult(False, "Error: That account already exists!")
Case &H6: RaiseEvent CreateAccountResult(False, "Name did not contain enough alphanumeric characters")
Case Else: RaiseEvent CreateAccountResult(False, "Error: Unknown Failure!")
End Select

Case &H31
Select Case Asc(Mid(Data, 5, 1))
Case &H1
RaiseEvent ChangePasswordResult(True, vbNullString)
Dim OutB3 As String * 20, TmpOutBuf3 As String, PWHashBuf3(2) As String
Call AddToBuffer(3, DBLKey)
Call AddToBuffer(3, Servers)
PWHashBuf3(0) = MakeDWORD(DBLKey)
PWHashBuf3(1) = MakeDWORD(Servers)
TmpOutBuf3 = Join(PWHashBuf3, vbNullString) & BrokenSHA.calcHashBuf(NewPassword)
OutB3 = BrokenSHA.calcHashBuf(TmpOutBuf3)
Call AddToBuffer(4, OutB3)
Call AddToBuffer(5, Username)
Call SendPacket("BNCS", &H3A)
Case &H0
RaiseEvent ChangePasswordResult(False, "Failed to change password")
End Select

Case &H34
Call AddToBuffer(3, &H1)
Dim OutB4 As String * 20, TmpOutBuf4 As String, PWHashBuf4(2) As String
PWHashBuf4(0) = MakeDWORD(&H1)
PWHashBuf4(1) = MakeDWORD(Servers)
TmpOutBuf4 = Join(PWHashBuf4, vbNullString) & BrokenSHA.calcHashBuf("password")
OutB4 = BrokenSHA.calcHashBuf(TmpOutBuf4)
Call AddToBuffer(4, OutB4)
Call AddToBuffer(5, RealmServer)
Call SendPacket("BNCS", &H3E)

Case &H3E
If Len(Data) > 12 Then
RaiseEvent RealmLogon(True, vbNullString)
BNCSName = Mid$(Data, 77, Len(Mid$(Data, 77)) - 3)
StartupData = Mid$(Data, 5, 16) & Mid$(Data, 29, 48)
RaiseEvent RealmConnecting
sckRealm.CloseSck

sckRealm.Connect MakeServer(Mid$(Data, 21, 4)), 6112
'sckRealm.Connect "Blazeingfire.com", 6112

Else
Select Case GetDWORD(Mid$(Data, 9, 4))
Case &H80000001: RaiseEvent RealmLogon(False, "Error: Realm is unavailable")
Case &H80000002: RaiseEvent RealmLogon(False, "Error: Realm logon failed")
Case Else: RaiseEvent RealmLogon(False, "Error: Realm failure")
End Select
End If

Case &HA
Dim split0xA() As String
split0xA = Split(Mid(Data, 5), vbNullChar)
RaiseEvent LoggedOn(split0xA(0), ParseStats(split0xA(1)), Mid(Data, 5))

If HomeChannel <> vbNullString Then
    Call AddToBuffer(5, "/join " & HomeChannel)
    Call SendPacket("BNCS", &HE)
End If

Case &HB
RaiseEvent ReceivedChannels(Mid(Data, 5))

Case &HF
ParseChat (Data)

Case Else
OtherPacket:
RaiseEvent HandlePackets(Data)

End Select

End Sub


EDIT: The call to checkRevision that's in there is what I added, the BNCSutil hashing function, but I just can't figure out how to get the data you need IN the crev function.

[Kp edit: split long lines.]
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

Hdx

OH MY FUCKING GOD
Delete that control this instant.
I know who wrote it and its the worst piece of shit I have ever seen.
DELETE DELETE DELETE.
What you need to do is get a decent buffer class.
And use the data correctly.
My personal opinion, Bnetdocs +  buffer class = all you need to get started.
~Hdx

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

l2k-Shadow

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.

option

Alright Hdx I'm going to take your word for it, I don't know who wrote that class but I thought it was a good reference, I guess I was wrong!

Starting from scratch is going to be a bitch only because it seems I lack so much knowledge and things aren't coming together for me. Anyways I saw in the BNBDR, a RealBasic Packet Builder, is that what you mean by buffer?
option's BNET Development Blog
Current project: Fully-modular 100% C++ SCBW ChatBot
Current Task: Write the Packet Debuffer
New to BNET development like myself? Read and learn.
http://bnetdev.tech-vault.net/

Hdx


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