• Welcome to Valhalla Legends Archive.
 

handling 0x3E fail.. any help ?

Started by fataly, January 09, 2009, 08:15 AM

Previous topic - Next topic

fataly


Public Sub handle0x3e(Data As String)
If Len(Data) > 12 Then
sumthing1 = GetDWORD(Mid$(Data, 5, 16))
sumthing2 = GetDWORD(Mid$(Data, 29, 48))
ip = GetDWORD(Asc(Mid$(Data, 21, 1)) & "." & Asc(Mid$(Data, 22, 1)) & "." & Asc(Mid$(Data, 23, 1)) & "." & Asc(Mid$(Data, 24, 1)))
port = GetWORD(StrReverse(Mid$(Data, 25, 2)))
acc = GetSTRING(Mid$(Data, 77))
Else
ErrorCode = GetDWORD(Mid$(Data, 9, 4))
End If
             ShowChat vbGreen, "Connecting MCP ( " & ip & ":" & port & " ) Now.."
              Form1.Winsock2.Close
              Form1.Winsock2.Connect ip, port
End Sub



[10:47:44] Connecting..
[10:47:44] Connected!
[10:47:44] Sending logon info..
[10:47:44] Accepting cdkey..
[10:47:45] Getting Realmlist..
[10:47:45] Logging Onto Account..
[10:47:46] We are in USEast
[10:47:46] Connecting MCP ( : ) Now..
[10:47:46] Ws 2 Connection Error: Address is not available from the local machine

I fixed whole packed and now i dont got ip.. ( i know i get ip from 0x3E , and its is based to 21 , 22 ,23 ,24 : port 25 and 26is there change i have build another packet wrong?

I put here some packets :


Public Sub send0x3E()
Dim strSHA1     As String * 20
    strSHA1 = BSHA1(MakeDWORD(hClientToken) & MakeDWORD(hServerToken) & BSHA1(LCase(hPassword), False, False), False, False)
    Call iClear
    Call iDWORD(hClientToken)
    Call iSTRING(strSHA1)
    Call iNTSTRING("Europe")
    Call iHEADER(&H3E)
    Call iPacket(Form1.Winsock1.SocketHandle)
End Sub



Public Sub handle0x40(Data As String)
     Dim Count  As Long
    Dim realmtitle  As String
   Dim realmdescription  As String
Count = GetDWORD(Mid$(Data, 2, 2))
realmtitle = GetSTRING(Mid$(Data, 17, 6))
realmdescription = GetSTRING(Mid$(Data, 25, 17))
ShowChat vbYellow, "We are in " & realmtitle
Call send0x3E
End Sub


Public Sub send0x33()
Call iClear
      Call iNTSTRING("bnserver-D2DV.ini")
    Call iHEADER(&H33)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbRed, "Getting Realmlist.."
End Sub


Public Sub handle0x33(Data As String)
id = GetWORD(Mid$(Data, 2, 2))
FileName = GetSTRING(Mid$(Data, 21, 13))
Call send0x3a
End Sub

FrostWraith

Show your packet log.  Are you sure you are handling endianness correctly?

fataly

send : 0x3A

FF 3A 2A 00 35 32 D6 04 EA 24 E6 72 07 8D B0 58 F8 F9 3D C5 01 42 22 04 79 AF B2 9B 10 B3 96 ED 46 61 74 61 6C 79 62 6F 74 00  .:*.52...$.r...X..=..B".y.......Fatalybot.

recv: 0x3A
FF 3A 08 00 00 00 00 00  .:......


send : 0x3e
FF 3E 23 00 35 32 D6 04 07 8D B0 58 F8 F9 3D C5  .>#.52.....X..=.
01 42 22 04 79 AF B2 9B 10 B3 96 ED 45 75 72 6F  .B".y.......Euro
70 65 00 pe.

recv 0x3E:
FF 3E 0C 00 35 32 D6 04 01 00 00 80 .>..52......


FrostWraith

#3
You are receiving the message:
0x80000001: Realm is unavailable

http://www.bnetdocs.org/?op=packet&pid=237

Where are you getting the ip from?  You might not be extracting it correctly from the packet in which you receive it.

MyndFyre

Quote from: FrostWraith on January 09, 2009, 12:43 PM
You are receiving the message:
0x80000001: Realm is unavailable

http://www.bnetdocs.org/?op=packet&pid=237

Where are you getting the ip from?  You might not be extracting it correctly from the packet in which you receive it.
Ooh, is he putting it in the reverse byte order?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

NiNe

#5
Your prob is you don't check if the packet has the significant amount of Data.

So if it contains all the right data connect to the realm, if not Use the status code.

Oh and also, your code is a bit off, looking at bnetdocs it should be;


server = GetDWORD(Mid$(Data, 17, 8))
connectmcp = MakeServer(GetDWORD(Mid$(server, 5, 4)))

not

server = GetDWORD(Mid$(Data, 17, 8))
connectmcp = MakeServer(GetDWORD(Mid$(Data, 5, 4)))

fataly

Bump ( if its allowed here := )
Check first post, i modified code , but i dont get ip..

Ringo

#7
Quote from: fataly on January 09, 2009, 08:15 AM

Public Sub handle0x3e(Data As String)
If Len(Data) > 12 Then
sumthing1 = GetDWORD(Mid$(Data, 5, 16))
sumthing2 = GetDWORD(Mid$(Data, 29, 48))
ip = GetDWORD(Asc(Mid$(Data, 21, 1)) & "." & Asc(Mid$(Data, 22, 1)) & "." & Asc(Mid$(Data, 23, 1)) & "." & Asc(Mid$(Data, 24, 1)))
port = GetWORD(StrReverse(Mid$(Data, 25, 2)))
acc = GetSTRING(Mid$(Data, 77))
Else
ErrorCode = GetDWORD(Mid$(Data, 9, 4))
End If
             ShowChat vbGreen, "Connecting MCP ( " & ip & ":" & port & " ) Now.."
              Form1.Winsock2.Close
              Form1.Winsock2.Connect ip, port
End Sub



[10:47:44] Connecting..
[10:47:44] Connected!
[10:47:44] Sending logon info..
[10:47:44] Accepting cdkey..
[10:47:45] Getting Realmlist..
[10:47:45] Logging Onto Account..
[10:47:46] We are in USEast
[10:47:46] Connecting MCP ( : ) Now..
[10:47:46] Ws 2 Connection Error: Address is not available from the local machine

I fixed whole packed and now i dont got ip.. ( i know i get ip from 0x3E , and its is based to 21 , 22 ,23 ,24 : port 25 and 26is there change i have build another packet wrong?

I put here some packets :


Public Sub send0x3E()
Dim strSHA1     As String * 20
    strSHA1 = BSHA1(MakeDWORD(hClientToken) & MakeDWORD(hServerToken) & BSHA1(LCase(hPassword), False, False), False, False)
    Call iClear
    Call iDWORD(hClientToken)
    Call iSTRING(strSHA1)
    Call iNTSTRING("Europe")
    Call iHEADER(&H3E)
    Call iPacket(Form1.Winsock1.SocketHandle)
End Sub



Public Sub handle0x40(Data As String)
     Dim Count  As Long
    Dim realmtitle  As String
   Dim realmdescription  As String
Count = GetDWORD(Mid$(Data, 2, 2))
realmtitle = GetSTRING(Mid$(Data, 17, 6))
realmdescription = GetSTRING(Mid$(Data, 25, 17))
ShowChat vbYellow, "We are in " & realmtitle
Call send0x3E
End Sub


Public Sub send0x33()
Call iClear
      Call iNTSTRING("bnserver-D2DV.ini")
    Call iHEADER(&H33)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbRed, "Getting Realmlist.."
End Sub


Public Sub handle0x33(Data As String)
id = GetWORD(Mid$(Data, 2, 2))
FileName = GetSTRING(Mid$(Data, 21, 13))
Call send0x3a
End Sub


First, You're not parseing the IP correctly, nore handleing any error (ErrorCode):

Public Sub handle0x3e(Data As String)
    dim IP as string
    dim Port as integer
    dim ErrorCode as long
    If Len(Data) > 12 Then
        sumthing1 = Mid$(Data, 5, 16)
        sumthing2 = Mid$(Data, 29, 48)
        ip = Asc(Mid$(Data, 21, 1)) & "." & Asc(Mid$(Data, 22, 1)) & "." & Asc(Mid$(Data, 23, 1)) & "." & Asc(Mid$(Data, 24, 1))
        port = GetWORD(StrReverse(Mid$(Data, 25, 2)))
        acc = GetSTRING(Mid$(Data, 77))
        ShowChat vbGreen, "Connecting MCP ( " & ip & ":" & port & " ) Now.."
        Form1.Winsock2.Close
        Form1.Winsock2.Connect ip, port
    Else
        ErrorCode = GetDWORD(Mid$(Data, 9, 4))
        if ErrorCode = &H80000001 then
            ShowChat vbred, "Realm Is Unavailable."
        else
            ShowChat vbred, "Realm Logon Failed: 0x" & right("00000000" & hex(errorcode), 8)
        end if
    End If
End Sub


Second, the reassion you're probly failing to logon the realm, is because you're not hashing the correct password (Note: for 0x3E, the password is "password", not you're account password)

Public Sub send0x3E()
Dim strSHA1     As String * 20
    strSHA1 = BSHA1(MakeDWORD(hClientToken) & MakeDWORD(hServerToken) & BSHA1("password"))
    Call iClear
    Call iDWORD(hClientToken)
    Call iSTRING(strSHA1)
    Call iNTSTRING("Europe")
    Call iHEADER(&H3E)
    Call iPacket(Form1.Winsock1.SocketHandle)
End Sub

Looking at the other stuff, it looks like you don't understand data types, bytes, words, dwords, strings etc.
Here is some info on the string function mid()
http://msdn.microsoft.com/en-us/library/05e63829(VS.71).aspx

BYTE is 1 byte, compareable to the VB6 Byte data type.
WORD is 2 bytes, compareable to the VB6 integer data type.
DWORD is 4 bytes, compareable to the VB6 long data type.
STRING is a variable array lengh set of characters, terminated with a null character (byte 0x00)
Theres many places on the web where you can read up on data types, VB6 functions and everything else you will need to know.

Hope this helps.

fataly

ooh i love you ringo ! In this case all is new to me =P

Barabajagal

A packet buffer/debuffer would help you significantly....

fataly

Another error, on send0x01:

Public Sub MCPsend0x01()
    Call iClear
    Call iDWORD(hClientToken)
    Call iDWORD(errorcode)
    Call iDWORD(mcpchunk1)
    Call iDWORD(mcpchunk2)
    Call iNTSTRING(acc)
    Call iHEADER(&O1, BNRS_HEADER)
     Call iPacket(Form1.Winsock2.SocketHandle)
        ShowChat vbBlue, "Send 0x01"
End Sub

1D 00 01 6E 65 3F 00 28 F3 12 82 6E 65 3F 00 00      ...ne?.(...ne?..
00 06 00 46 61 74 61 6C 79 62 6F 74 00                    ...Fatalybot..


Whats wrong? Do i need convert MCPchunks to other data or something?

Ringo

#11
Quote from: fataly on January 11, 2009, 05:39 AM
Another error, on send0x01:

Public Sub MCPsend0x01()
    Call iClear
    Call iDWORD(hClientToken)
    Call iDWORD(errorcode)
    Call iDWORD(mcpchunk1)
    Call iDWORD(mcpchunk2)
    Call iNTSTRING(acc)
    Call iHEADER(&O1, BNRS_HEADER)
     Call iPacket(Form1.Winsock2.SocketHandle)
        ShowChat vbBlue, "Send 0x01"
End Sub

1D 00 01 6E 65 3F 00 28 F3 12 82 6E 65 3F 00 00      ...ne?.(...ne?..
00 06 00 46 61 74 61 6C 79 62 6F 74 00                    ...Fatalybot..


Whats wrong? Do i need convert MCPchunks to other data or something?


I'm going to assume you ignored my advise of reading up about data types etc.
Idk where to start -- you should really learn the language you're useing before you even started attempting this..

Why are you sending the client token and the error code?
The error code is simply that, an error code.
If you recv an error code in BNCS 0x3E (IE; lengh of data is <= 12) then you should never be connecting to the realm server, since you wont even have an IP to connect to.
read this:
http://ersan.us/src/bnetdocs/contentafa6.html?Section=m&Code=93

(DWORD[16])    MCP Startup Data
(STRING)       Battle.net Unique Name

There is 16 DWORD's copyed over (aka 64 bytes) and the account name.
The client token doesnt even come into it.
Looking at you're packet log, the dword where are you inserting the error code, is filled out, so god knows what you're doing in the 0x3E handler.
It would seem you ignored the example I give you, of 0x3E handler, a few posts above.
If you look at my above post:

        sumthing1 = Mid$(Data, 5, 16)
        sumthing2 = Mid$(Data, 29, 48)
....
        acc = GetSTRING(Mid$(Data, 77))

That is the body of the realm 0x01 packet.
16+48 = the 64 bytes you copy over.
the account name is the string you also copy over.
Example:

Public Sub MCPsend0x01()
    Call iClear
    Call iSTRING(sumthing1)
    Call iSTRING(sumthing2)
    Call iNTSTRING(acc)
    Call iHEADER(&H1, BNRS_HEADER)
    Call iPacket(Form1.Winsock2.SocketHandle)
    ShowChat vbBlue, "Send 0x01"
End Sub

Assuming sumthing1, sumthing2 and acc are global variables.

Also, I really don't know why you were useing &O, unles you like counting in base of 8.
&H denotes Hexadecimal, &O denotes Octal.

fataly

#12
http://ersan.us/src/bnetdocs/contentafa6.html?Section=m&Code=93 are little diffrent than http://www.bnetdocs.org/?op=packet&pid=320. But thanks for answer <>

Updated again:
15 00 01 C2 E4 B5 00 00 00 06 00 46 61 74 61 6C ...........Fatal
79 62 6F 74 00                                                         ybot.

fataly

#13
now i send 0x01:
1B 00 01 31 37 38 36 36 35 36 32 33 39 33 32 31 ...1786656239321
36 46 61 74 61 6C 79 62 6F 74 00                          6Fatalybot.

I regonize that " 31 37 38 36 36 35 36 32 33 39 33 32 31 36" is 17866562393216, and other packets is my name. But what i did wrong if i overcopy sumthing1 and 2 from 0x3E  ? im little confused again :) I cant undersunt why its shows @ numbers if i over copy recv data in this case:

.>V...'.`7Tf..jA
..t...j.........
....fH..PX2D68XI
..jA....t....XN}
.....vt.9.HqFata
lybot.


my code

these are top of code:
Public sumthing1 As String ' they must be string if i have undersunt right
Public sumthing2 As String ' they must be string if i have undersunt right
Public acc As String


Public Sub MCPsend0x01(ByVal sumthing1 As String, ByVal sumthing2 As String, ByVal acc As String)
    Call iClear
     Call iSTRING(sumthing1)
   Call iSTRING(sumthing2)
    Call iNTSTRING(acc)
    Call iHEADER(&H1, BNRS_HEADER)
    Call iPacket(Form1.Winsock2.SocketHandle)
    ShowChat vbBlue, "Send 0x01"
End Sub


Ringo

Quote from: fataly on January 09, 2009, 08:15 AM

        sumthing1 = GetDWORD(Mid$(Data, 5, 16))
        sumthing2 = GetDWORD(Mid$(Data, 29, 48))



Quote from: Ringo on January 10, 2009, 06:24 AM

        sumthing1 = Mid$(Data, 5, 16)
        sumthing2 = Mid$(Data, 29, 48)


Looks like you're still useing getdword
GetDWORD(Mid$(Data, 5, 16)) will return the decimal number of Mid$(Data, 5, 4)