• Welcome to Valhalla Legends Archive.
 

A little help needed...

Started by RedPhoenix, April 15, 2004, 02:00 AM

Previous topic - Next topic

RedPhoenix

First I got a vb 6 source that used the winsock control. Knowing that I couldn't use the winsock control I had to find an alternate route. Search the internet and found the TcpClient class. The samples listed showed only how to connect, not to keep looping and recieving messages as I did with the thread class. Only use I got from the vb 6 source was the server name, port number, and string to connect. Even though I had to alter the string that was in the vb 6 code. I found the majority of the code on MSDN, just had to work with the syntax a little to get it to do something. I have an Associates in Computer Programming if that helps to let you know how my background in programming is.

RedPhoenix

By the way, I know the source I posted looks like plain ol' crap. I felt bad after posting it. It's just a early early skeleton chat client. I built it in less than 24 hours. So please excuse the poor structure.  :-\

Tuberload

Quote from: RedPhoenix on April 15, 2004, 05:27 PM
By the way, I know the source I posted looks like plain ol' crap. I felt bad after posting it. It's just a early early skeleton chat client. I built it in less than 24 hours. So please excuse the poor structure.  :-\

You should see the original prototype of my bot. I like to get things working, and then make them look pretty. There is nothing wrong with that. ;)
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

iago

Quote from: Tuberload on April 15, 2004, 05:34 PM
Quote from: RedPhoenix on April 15, 2004, 05:27 PM
By the way, I know the source I posted looks like plain ol' crap. I felt bad after posting it. It's just a early early skeleton chat client. I built it in less than 24 hours. So please excuse the poor structure.  :-\

You should see the original prototype of my bot. I like to get things working, and then make them look pretty. There is nothing wrong with that. ;)

I tried that and it involves TONS of rewriting later.  I wish I'd done it better from the start.

I've also rewritten tons of code people at work wrote because it was poorly planned and ended up as a mess.  
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


RedPhoenix

Myndfyre, I added you to my msn and icq. Plus I have downloaded an IP packet logger and have been looking it over as compared to the docs.

Tuberload

Quote from: iago on April 15, 2004, 06:03 PM
Quote from: Tuberload on April 15, 2004, 05:34 PM
Quote from: RedPhoenix on April 15, 2004, 05:27 PM
By the way, I know the source I posted looks like plain ol' crap. I felt bad after posting it. It's just a early early skeleton chat client. I built it in less than 24 hours. So please excuse the poor structure.  :-\

You should see the original prototype of my bot. I like to get things working, and then make them look pretty. There is nothing wrong with that. ;)

I tried that and it involves TONS of rewriting later.  I wish I'd done it better from the start.

I've also rewritten tons of code people at work wrote because it was poorly planned and ended up as a mess.  

What I meant by that was, I first get the bot connected in a procedural matter, then I convert it to a more OO event driven system. I do that right after I figure out how to do what it is I am doing. So for me at least, it usually does not end up requiring too much re-writing. More or less it just involves re-organizing and separating functionality to separate classes. I like to build one piece at a time, so when it is complete I don't have to mess with it much, accept maintenance and additions.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

RedPhoenix

I didn't know how far I would get, wasn't going to invest alot of time into it if I couldn't even connect. But, here I am still trying to figure out the binary string to send it lol. The packets I logged, doesn't interpret that easy:

68XIPXES
USA.United States

starcraft.exe 03/28/03 04:21:56

[Server List Version]..VER=1001....[Server Gateways]..1=uswest.battle.net..2=useast.battle.net..3=asia.battle.net..4=europe.battle.net....[uswest.battle.net]..ZONE=8..ENU=U.S. West..FRA=U.S. Ouest....[useast.battle.net]..ZONE=6..ENU=U.S. East..FRA=U.S. Est....[asia.battle.net]..ZONE=-9..ENU=Asia..FRA=Asie....[europe.battle.net]..ZONE=-1..ENU=Europe..FRA=Europe..


**Note: I excluded some data I found due to I don't know how the content of it. Another thing I noticed that looked wierd was this:

A=####### B=####### C=######## 4A=A+S B=B-C C=C^A A=A-B

Where # was a series of numbers. I never messed with network packets before, maybe you all can point me to some material on where to decipher this data. I've tried sending the server the different strings (Converted to Ascii) but, didn't have much luck getting a response. Plus, I can't use Ethreal, it's only for high speed internet users. Me, I'm still in the stoneage with a 56k modem.

MyndFyre

Quote from: RedPhoenix on April 16, 2004, 01:37 AM
I didn't know how far I would get, wasn't going to invest alot of time into it if I couldn't even connect. But, here I am still trying to figure out the binary string to send it lol. The packets I logged, doesn't interpret that easy:

68XIPXES
USA.United States

starcraft.exe 03/28/03 04:21:56

[Server List Version]..VER=1001....[Server Gateways]..1=uswest.battle.net..2=useast.battle.net..3=asia.battle.net..4=europe.battle.net....[uswest.battle.net]..ZONE=8..ENU=U.S. West..FRA=U.S. Ouest....[useast.battle.net]..ZONE=6..ENU=U.S. East..FRA=U.S. Est....[asia.battle.net]..ZONE=-9..ENU=Asia..FRA=Asie....[europe.battle.net]..ZONE=-1..ENU=Europe..FRA=Europe..


**Note: I excluded some data I found due to I don't know how the content of it. Another thing I noticed that looked wierd was this:

A=####### B=####### C=######## 4A=A+S B=B-C C=C^A A=A-B

Where # was a series of numbers. I never messed with network packets before, maybe you all can point me to some material on where to decipher this data. I've tried sending the server the different strings (Converted to Ascii) but, didn't have much luck getting a response. Plus, I can't use Ethreal, it's only for high speed internet users. Me, I'm still in the stoneage with a 56k modem.

From Open Bnetdocs:

C->S SID_AUTH_INFO
Packet id: 0x50 - &H50

Format:
(DWORD) Protocol ID (Use zero)
(DWORD) Platform ID  'IX86', which is what you see as "68XI"
(DWORD) Product ID   'SEXP', which is what you see as "PXES"
(DWORD) Version byte  (I think the present one is 10 dec, so you would see 0a 00 00 00 in hex)
(DWORD) Product language (I think probably 1033 decimal, 09 04 00 00 hex)
(DWORD) Local IP (This is used for NAT translation; it CAN be 0).
(DWORD) Time zone (this is your timezone bias multiplied by -60.  So, I'm GMT -7, the number to send is 420, or A4 01 00 00 as you would see it from a capture)
(DWORD) ?Locale ID (We don't know, probably 0)
(DWORD) ?Language ID (I don't know, you can leave it as 0)
(STRING) Country abreviation (Don't believe Open BnetDocs when it says it's a DWORD.  It's a null-terminated string, "USA" + (char)0.
(STRING) Country name "United States" + (char)0.

That A=, B= junk is the response Checksum Equation for response 0x50, SID_AUTH_INFO

(STRING) Exe information
is what you see in starcraft.exe, blah blah blah :)

Hope that helps.  You never re-IMed me, and I didn't save your name.

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.

RedPhoenix

#23
**Please note I'm not asking for anyone's code. I won't learn anything by that route.

After checking all 59 pages, tell me if I have the right concept.

Connecting with Chr(3) & Chr(4) is telling the server your wanting to join the regular chat. Now to join the private admin chats I would use 0x01 and then the rest of the data. Soon as I can get back on the bnetdocs page. I'll take a look at the order in which to send the data. I also read that the server may not want the data in a specific way each time, that it could change the order in which it wants the user data.

Tuberload

#24
Quote from: RedPhoenix on April 16, 2004, 02:56 AM
Is the site down? http://bnetdocs.valhallalegends.com/ and http://valhallalegends.com/ ?? Hasn't loaded for me in several hours.

Yes, the valhallalegends.com has been up and down for a little while now. I am sure it will be up and running shortly.

As for some of your previous questions:

I recommend getting WPE Pro as a packet sniffer. It is really simple and easy to use, and gets the job done effectively. I have been pleased with it so far.

You do not have to login to the chat gateway to use the binary gateway. They are completely different protocols. When you connect to battle.net, send (byte) 0x01. That will tell the server that you want to use the binary gateway. 0x03 is the chat gateway, and 0x02 is the file server.

Battle.net packets follow the following format (please excuse any errors):
(byte) header (byte) packet id (word) packet length, followed by the packet message.

header: for the majority of the battle.net packets, this will always be 0xFF

packet id: this verifies what the packets purpose is, i.e. is it a chat event,a logon challenge, etc...

packet length: the lenght, in bytes, of the packet including the three byte header

The main data types used in the packet message are BYTE's, WORD's, DWORD's, and NTString's.

BYTE: an 8-bit integer, i.e. 0xFF
WORD: a 16-bit, or two byte integer i.e. 0xFF3A
DWORD: a 32-bit, or four byte integer i.e. 0xFF3AFF3A
NTString: a null (0x0) terminated string, i.e. "Tuberload" == 0x54 0x75 0x62 0x65 0x72 0x6C 0x6F 0x61 0x64 0x0

In the battle.net packets, WORD's and DWORD's are represented little endian, or the least signifigant byte first. So the DWORD 2882400018 (0xABCDEF12) would be stored in the packet as 0x12EFCDAB. WORD's follow the same format. Depending on the language you use, signed integers can be a problem. They can be easily addressed though.

Please excuse the brevity of this post, and I am sorry for any possible falsification's that may be present. You should be able to get an overall idea for what is going on, and I am sure someone will correct any of my mistakes.

As soon as valhallelends.com is back up I would recommend thoroughly reading BnetDocs, and possible looking into BNLS to aid you in the login procedure.

Edit: Fixed an error
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

MyndFyre

Quote from: Tuberload on April 16, 2004, 03:48 AM
Please excuse the brevity of this post, and I am sorry for any possible falsification's that may be present. You should be able to get an overall idea for what is going on, and I am sure someone will correct any of my mistakes.

LoL Tuberload, it's the "cover my ass" qualifier :P

Phoenix:  I recommend that, rather than posting three times in a row, just use "Modify" if nobody has posted since you last did.  It's nicer that way. :)  If you want to chat w/ me, you need to message me, or put your MSN in your profile.
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.

Tuberload

Quote from: Myndfyre on April 16, 2004, 08:26 AM
Quote from: Tuberload on April 16, 2004, 03:48 AM
Please excuse the brevity of this post, and I am sorry for any possible falsification's that may be present. You should be able to get an overall idea for what is going on, and I am sure someone will correct any of my mistakes.
LoL Tuberload, it's the "cover my ass" qualifier :P

Exactly! I didn't have access to any documentation, and I don't have it all 100% committed to memory yet. I don't like being caught with my pants down, so I state right away the possibility of errors. If I was completely correct, great, otherwise I don't look too stupid. ;)
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

RedPhoenix

So I send this first two, and I should recieve a response correct??

SEND ->  Protocol byte (01)
SEND -> SID_AUTH_INFO (0x50)

RECV <- SID_PING (0x25)
RECV <- SID_AUTH_INFO (0x50)


Here's where I'm at:

Public Const GAME_PACKET = "1"

'SID Authorization Info
Public Const PROTOCOL_ID = "0"
Public Const PLATFORM_ID = "68XI"
Public Const PROGRAM_ID = "PXES"
Public Const VERSION_BYTE = "1064960"
Public Const PRODUCT_LANGUAGE = "ENU"
Public Const LOCAL_IP = "0" 'for NAT compatibility
Public Const TIME_ZONE_BIAS = "03/28/03 04:21:56"
Public Const LOCALE_ID = "0"
Public Const LANGUAGE_ID = "0"
Public Const COUNTRY_ABBREVIATION = "USA" & Chr(0)
Public Const COUNTRY = "United States" & Chr(0)

'Send this first, should get a response if correct.
msgStart = Chr(1) & Chr(4) & "68XI" & "SEXP" & "1064960" _
       & "ENU" & Chr(0) & "03/28/03 04:21:56" & Chr(0) & Chr(0) & _
       "USA" & Chr(0) & "United States" & Chr(0)

***Note: I have the data as strings, I'm aware of the binary concept. What I'm thinking is since I can connect and chat on Public servers. That sending data the way I am now, technically should work.

'Convert string to Ascii encoding
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(msgSend)
Dim stream As NetworkStream = client.GetStream()

stream.Write(data, 0, data.Length)

Now with the string I'm sending (msgStart), I'm not sure if there should be (vbCrLf) between each string ("68XI" & vbCrLf & "SEXP"), or if my structure of it is way off.

MyndFyre

You're wrong about time-zone bias; that is the number of hours you are off of GMT multiplied by -60.  I am GMT -7, and so I send the decimal value of 420.  It is a double-word (System.Int32 or System.UInt32), not a string.

Never, ever, ever, EVER do you need to send vbCrLf when using this packet; in fact, I think you will be IP-banned if you do.  (Also, it is now better programming practice to use Environment.NewLine rather than vbCrLf, for cross-platform interoperability, when using .NET).

I also believe that is the incorrect version byte.  I'm pretty sure it's just 0x0a for Starcraft, or &H0a.  Version byte is also a double-word, not a string.

Product language may or may not be "enu" -- you can just use a 0 there as a double-word.
Local IP should be 0, not a string (as that is hex 0x30), but the literal 0 double-word.
Locale ID should be a double-word 0, not a string.
Language ID should be a double-word 0, not a string.
Protocol ID should be a double-word 0, not a string.

That's about it....
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.

iago

He also has some extra chr(0)'s in there.  He has 2 after country code and 2 after country.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


|