Valhalla Legends Forums Archive | Battle.net Bot Development | handling 0x3E fail.. any help ?

AuthorMessageTime
fataly
[code]
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
[/code]


[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 :

[code]
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
[/code]

[code]
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
[/code]
[code]
Public Sub send0x33()
Call iClear
      Call iNTSTRING("bnserver-D2DV.ini")
    Call iHEADER(&H33)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbRed, "Getting Realmlist.."
End Sub
[/code]
[code]
Public Sub handle0x33(Data As String)
id = GetWORD(Mid$(Data, 2, 2))
FileName = GetSTRING(Mid$(Data, 21, 13))
Call send0x3a
End Sub
[/code]
January 9, 2009, 2:15 PM
FrostWraith
Show your packet log.  Are you sure you are handling endianness correctly?
January 9, 2009, 4:34 PM
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......

January 9, 2009, 5:37 PM
FrostWraith
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.
January 9, 2009, 6:43 PM
Myndfyr
[quote author=FrostWraith link=topic=17778.msg181082#msg181082 date=1231526594]
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.
[/quote]
Ooh, is he putting it in the reverse byte order?
January 9, 2009, 7:05 PM
NiNe
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;

[code]
server = GetDWORD(Mid$(Data, 17, 8))
connectmcp = MakeServer(GetDWORD(Mid$(server, 5, 4)))
[/code]
not
[code]
server = GetDWORD(Mid$(Data, 17, 8))
connectmcp = MakeServer(GetDWORD(Mid$(Data, 5, 4)))
[/code]
January 9, 2009, 10:17 PM
fataly
Bump ( if its allowed here := )
Check first post, i modified code , but i dont get ip..
January 10, 2009, 9:37 AM
Ringo
[quote author=fataly link=topic=17778.msg181079#msg181079 date=1231510536]
[code]
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
[/code]


[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 :

[code]
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
[/code]

[code]
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
[/code]
[code]
Public Sub send0x33()
Call iClear
      Call iNTSTRING("bnserver-D2DV.ini")
    Call iHEADER(&H33)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbRed, "Getting Realmlist.."
End Sub
[/code]
[code]
Public Sub handle0x33(Data As String)
id = GetWORD(Mid$(Data, 2, 2))
FileName = GetSTRING(Mid$(Data, 21, 13))
Call send0x3a
End Sub
[/code]
[/quote]

First, You're not parseing the IP correctly, nore handleing any error (ErrorCode):
[code]
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
[/code]

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)
[code]
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
[/code]
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.
January 10, 2009, 12:24 PM
fataly
ooh i love you ringo ! In this case all is new to me =P
January 10, 2009, 4:29 PM
Barabajagal
A packet buffer/debuffer would help you significantly....
January 10, 2009, 8:37 PM
fataly
Another error, on send0x01:
[code]
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
[/code]
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?
January 11, 2009, 11:39 AM
Ringo
[quote author=fataly link=topic=17778.msg181103#msg181103 date=1231673975]
Another error, on send0x01:
[code]
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
[/code]
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?

[/quote]

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
[tt]
(DWORD[16]) MCP Startup Data
(STRING)    Battle.net Unique Name
[/tt]
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:
[code]
        sumthing1 = Mid$(Data, 5, 16)
        sumthing2 = Mid$(Data, 29, 48)
....
        acc = GetSTRING(Mid$(Data, 77))
[/code]
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:
[code]
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
[/code]
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.
January 11, 2009, 1:13 PM
fataly
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.
January 11, 2009, 1:27 PM
fataly
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:
[code]
.>V...'.`7Tf..jA
..t...j.........
....fH..PX2D68XI
..jA....t....XN}
.....vt.9.HqFata
lybot.
[/code]

my code
[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
[/code]
[code]
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
[/code]
January 11, 2009, 6:59 PM
Ringo
[quote author=fataly link=topic=17778.msg181079#msg181079 date=1231510536]
[code]
        sumthing1 = GetDWORD(Mid$(Data, 5, 16))
        sumthing2 = GetDWORD(Mid$(Data, 29, 48))
[/code]
[/quote]


[quote author=Ringo link=topic=17778.msg181094#msg181094 date=1231590284]
[code]
        sumthing1 = Mid$(Data, 5, 16)
        sumthing2 = Mid$(Data, 29, 48)
[/code]
[/quote]

Looks like you're still useing getdword
GetDWORD(Mid$(Data, 5, 16)) will return the decimal number of Mid$(Data, 5, 4)
January 11, 2009, 7:31 PM
fataly
ahaa, im stupid :D didnt even regonize that ! now its working and i learned little more about mids. i have read whole day my code and functions on ms netsite, but I DIDNT SAW THAT =P maybe time to get glasses--> Btw thanks Again ( x1025 ) :F
January 11, 2009, 7:42 PM
fataly
[quote]
im again (x1026) on troubles, i have now tried almost 4 hours to fix my code:
there is the prob, im sure.:

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim strTemp As String
Call Winsock2.GetData(strTemp, vbString, bytesTotal)
'here must be the defiened place where are headers etc.. ?
Call parsemcp2(strTemp)
End Sub

Im sure this is right : ( or im almost sure , because its call mcp0x01 etc..)

Private Sub parsemcp(ByRef data As String)
Dim PacketID As String
    PacketID = Asc(Mid(data, 3, 1))

Select Case PacketID
Case &H1:           Call modBNET.MCPhandle0x01(data)
Case &H19:          Call modBNET.MCPhandle0x19(data)
Case Else
ShowChat vbRed, "Unparsed Packet: 0x" & Hex(PacketID) & GetLog(data)
End Select
End Sub[/quote]
[quote]
Forgot that, im sure that is correct. I got right data on 0x01 and my handle of 0x19 just suxx, thats is my next mission. / and if some want, i can take tips :)
[/quote]
[quote]
Edit 03:52 -->
0A 00 07 46 61 74 61 6C 79 64  ...Fatalyd

Then disconnect???
[/quote]

Ok now i can log with character (uswest)and join channel, i can talk and other things etc... But if i try logon europe, i get disconnect after joining channel ??? and now if i try log uswest again, i got dissconnect ??? wierd random dissconnects :F
January 12, 2009, 3:53 PM
fataly
Ok, so if i connect normaly without "homechannel" i get in bnet. But if i use "homechannel" when i connect there is 97% change to get Connection closed. And this connection closed happends 15% change without "homechannel"  where  is the prob? it just a that battle.net ?:D
January 13, 2009, 2:20 PM

Search