• Welcome to Valhalla Legends Archive.
 

MBNCSUtil Step By Step

Started by Fr3DBr, September 17, 2006, 08:34 AM

Previous topic - Next topic

Fr3DBr

Hello, im trying to look for a step by step in how to use it to get on battle.net, i have no problem with C# as well but i dont know wich methods to use first or later of the library... so someone that already knows it could tell me what should be done ? or point me to a manual ? Thanks.

SSKnight

If you've come for help, you've come to the wrong place.

These people help each other and when newcomers are looking for a trickle down of knowledge, they treat you like an idiot.

You'd be better off to just act like you know everything, like everyone else around here.

Fr3DBr

Well i just didnt found any documentation on how to actually use MBNCSUtil to get logged on battle.net, so im asking for some reference, nothing really hard.  ;D

Skywing

I would read the documentation supplied with the library and review the message and logon sequence documentation on BnetDocs (and perhaps some of the topics in the BnetDocs Research and Discussion forum).

MBNCSUtil provides implementations for many of the algorithms referred to by BnetDocs.  You can think of it as a sort of "Battle.net API" that is complementary to whatever other APIs you are using to build your program.

Armed with MBNCSUtil and the information on BnetDocs on the forum, you should have all of the Battle.net-specific information you need to make a basic emulator client.  What remains is then architecting and designing your program, and some knowledge of the APIs you will be using from your program to perform basic tasks like establish TCP connections (e.g. Win32 API, VB, .NET framework) - your development environment more than likely has a great deal of documentation relating to those sort of tasks.

SSKnight

QuoteWell i just didnt found any documentation on how to actually use MBNCSUtil to get logged on battle.net, so im asking for some reference, nothing really hard. 

Yeah I know. It would be awesome to have a starting place for people who haven't ever used winsock to program a bot before. A nice tutorial paper on how to actually set up the simplest of connections between a client and the battle.net server would be wonderful, but I'm afraid that is beyond the scope of what can be provided by this self-righteous community.

If you can't divine the correct programming procedure to connect to BNET using the Bnetdocs or the BNLS protocol paper, well you're just not welcome here.

Skywing

#5
I think that is beyond the scope of these forums, which focus on more Battle.net-specific things.  If you are interested in learning how to do things like use TCP connections with your language of choice, there are topics about that in the archives of most of the language programming forums on these boards.  Alternatively, you can very likely find example code for that sort of thing with quickly and easily with a search engine (or perhaps just by browsing the documentation that comes with your development environment, if applicable).

These forums do assume a basic level of programming competency of the person asking the questions (in whichever language they are using).  There are many resources outside of this particular forum to gain that knowledge.  For instance, there is a C++ discussion forum for questions of that sort if you are using C++.

Fr3DBr

Actually i stated i know C# pretty well... that includes using System.Net.Sockets and other language specific stuff... i dont have difficult with the implementation itself, i just wanted a documentation about the Methods that should be used during the logon sequence, if i never used mbncsutil then it might takes too much time to figure out what should be used or not, having like a testcase would provide alot more of speed in the development proccess, anyways im not asking for a fully working testcase it doesnt even need to really have a client socket object coded in, anyways thanks...

LordNevar

Quote from: Skywing on September 17, 2006, 12:09 PM
I would read the documentation supplied with the library and review the message and logon sequence documentation on BnetDocs (and perhaps some of the topics in the BnetDocs Research and Discussion forum).

MBNCSUtil provides implementations for many of the algorithms referred to by BnetDocs.  You can think of it as a sort of "Battle.net API" that is complementary to whatever other APIs you are using to build your program.

Armed with MBNCSUtil and the information on BnetDocs on the forum, you should have all of the Battle.net-specific information you need to make a basic emulator client.  What remains is then architecting and designing your program, and some knowledge of the APIs you will be using from your program to perform basic tasks like establish TCP connections (e.g. Win32 API, VB, .NET framework) - your development environment more than likely has a great deal of documentation relating to those sort of tasks.


I'd say that all the information you are seeking is inside his last statement. If your looking for someone to hand you a source code it is not likely to happen.

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

MyndFyre

Quote from: Fr3DBr on September 17, 2006, 12:19 PM
Actually i stated i know C# pretty well... that includes using System.Net.Sockets and other language specific stuff... i dont have difficult with the implementation itself, i just wanted a documentation about the Methods that should be used during the logon sequence, if i never used mbncsutil then it might takes too much time to figure out what should be used or not, having like a testcase would provide alot more of speed in the development proccess, anyways im not asking for a fully working testcase it doesnt even need to really have a client socket object coded in, anyways thanks...

MBNCSUtil, as Skywing has alluded to, is a toolkit for the algorithms involved in connecting to Battle.net.  Despite having written it, I've never used it myself until this week, and I was actually pleasantly surprised at how much faster it made the development process for a Battle.net client.

As most people have said, we prefer to help people who help themselves - so one of the first things you should do is understand how a socket's byte stream works (if it helps you to do this, check out the NetworkStream class, and you'll realize that sockets are just an underlying transport mechanism for stream-based data).

During the authentication phase, MBNCSUtil is first used when putting together packet 0x51 - SID_AUTH_CHECK - for performing the CheckRevision function (CheckRevision.DoCheckRevision(string, string[], int)) and the CD key hashing (CdKey class).  If you're connecting with a Warcraft III client, your next task will be to use the NLS class, and the details of it are included in the documentation.  Otherwise, you'll want to use the OldAuth.DoubleHashPassword(int, int, string) function to calculate your password hash for the appropriate SID_LOGONRESPONSE or SID_LOGONRESPONSE2 packet (based on your client - see BnetDocs for more information).

MBNCSUtil (as of version 1.2) also provides an implementation of a generalized data buffer (the DataBuffer class) and a specialized-for-Battle.net version of it (the BncsPacket class) that will automatically format your packets based on the data you insert.  The BncsPacket class also prepends the appropriate header for Battle.net.  It additionally provides data reader classes (the generalized DataReader class and specialized BncsReader class) that reads your data in a meaningful way - these classes treat your data like a stream and advance across the stream as you read the data.  For example, if you had the following byte array:

00 01 02 03 04 05 06 07

and you had a DataReader called "rdr" reading that byte array, you could do:

Console.WriteLine("{0:x8}", rdr.ReadInt32());
Console.WriteLine("{0:x8}", rdr.ReadInt32());

And you'd get the following output:

03020100
07060504

These classes are exceptionally useful when reading data in from Battle.net.  In fact, the BncsReader class automates the reading process when using a NetworkStream instead of a socket, by blocking the current thread until all of a packet's data arrives (you use its Stream-based constructor to read the data). 

Short of giving you the code to get online, which is, simply put, not very difficult if you understand the basic networking concepts behind it (don't feel bad; it took me about 6 months to really understand what was going on behind the scenes, and I struggled the whole time), this is an excellent overview.  Just don't be lazy, and don't try to cut corners - it will be a much more worthwhile experience if you work it out the hard way.
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.

Fr3DBr

#9
Well actually i have my own packet class :


                #region [0x50 SID_AUTH_INFO C->S]
                // SEND 0x50 AFTER CONNETING !!
                //(BYTE)     Always 0xFF
                //(BYTE)     Opcode 0x50
                //(WORD)     Lenght 4 Bytes + Data Size.
                //(DWORD) Protocol ID (0)
                //(DWORD) Platform ID
                //(DWORD) Product ID
                //(DWORD) Version Byte
                //(DWORD) Product language
                //(DWORD) Local IP for NAT compatibility*
                //(DWORD) Time zone bias*
                //(DWORD) Locale ID*
                //(DWORD) Language ID*
                //(STRING) Country abreviation
                //(STRING) Country

                UInt32 ProtocolID         = 0;              // Can be set to zero without breaking the logon
                String PlataformID        = "68XI";
                String ProductID          = "VD2D";
                UInt32 VersionByte        = 0x0B;
                UInt32 ProductLanguage    = 0;              // Can be set to zero without breaking the logon
                UInt32 LocalIP            = 0;              // Can be set to zero without breaking the logon
                UInt32 TimeZone           = 0;              // Can be set to zero without breaking the logon
                UInt32 LocalID            = 0;              // Can be set to zero without breaking the logon
                UInt32 LanguageID         = (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID;
                String Country            = (System.Globalization.CultureInfo.CurrentCulture.EnglishName.Split('(')[1]).Split(')')[0];
                String CountryAbreviation = (Country.ToUpper()).Substring(0,3);

                Packet pkt = new Packet();
                pkt.Opcode = 0x50;
                pkt.Write(ProtocolID);
                pkt.Write(PlataformID);
                pkt.Write(ProductID);
                pkt.Write(VersionByte);
                pkt.Write(ProductLanguage);
                pkt.Write(LocalIP);
                pkt.Write(TimeZone);
                pkt.Write(LocalID);
                pkt.Write(LanguageID);
                pkt.Write(CountryAbreviation); pkt.Write((Byte)0x00);
                pkt.Write(Country); pkt.Write((Byte)0x00);
               
                PacketPrinting.PrintPacket(pkt, false);
                Send(pkt, 0);
                #endregion


then you can do like a socket.send(Packet);

And you get something like :


[Log 17/9/2006 22:03:02]-> D2 Bot By Fr3DBr v1.0
[Log 17/9/2006 22:03:02]-> Connected in : useast.battle.net : 6112
[C->S] [OPCODE : 0x50] [LENGHT : 000052 BYTES]
OFFSET  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | 0123456789ABCDEF
--------------------------------------------------------------------------
000010  01 FF 50 33 00 00 00 00 00 36 38 58 49 56 44 32   ..P3.....68XIVD2 
000020  44 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00   D............... 
000030  00 00 00 00 00 16 04 00 00 42 52 41 00 42 72 61   .........BRA.Bra 
000040  7A 69 6C 00                                       zil. 
--------------------------------------------------------------------------
[S->C] [OPCODE : 0x25] [LENGHT : 000008 BYTES]
OFFSET  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | 0123456789ABCDEF
--------------------------------------------------------------------------
000010  FF 25 08 00 C5 15 6A 6B                           .%....jk
--------------------------------------------------------------------------
[C->S] [OPCODE : 0x25] [LENGHT : 000008 BYTES]
OFFSET  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | 0123456789ABCDEF
--------------------------------------------------------------------------
000010  FF 25 08 00 C5 15 6A 6B                           .%....jk
--------------------------------------------------------------------------
[S->C] [OPCODE : 0x50] [LENGHT : 000103 BYTES]
OFFSET  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | 0123456789ABCDEF
--------------------------------------------------------------------------
000010  FF 50 67 00 00 00 00 00 8B 19 C8 26 FD 5D 05 00   .Pg........&.].. 
000020  00 20 58 7D 99 CB C6 01 76 65 72 2D 49 58 38 36   . X}....ver-IX86 
000030  2D 33 2E 6D 70 71 00 41 3D 31 34 33 38 37 31 33   -3.mpq.A=1438713 
000040  39 31 31 20 43 3D 34 36 32 34 32 30 34 31 38 20   911 C=462420418   
000050  42 3D 32 35 33 35 38 36 30 38 38 32 20 34 20 41   B=2535860882 4 A 
000060  3D 41 2D 53 20 42 3D 42 2B 43 20 43 3D 43 2B 41   =A-S B=B+C C=C+A 
000070  20 41 3D 41 2B 42 00                               A=A+B. 
--------------------------------------------------------------------------
Received 0x50 | LT : 0 ST : 650647947 UDPV: 351741 MPQFT: 29/8/2006 18:32:32 IX86FN: ver-IX86-3.mpq
VS: A=1438713911 C=462420418 B=2535860882 4 A=A-S B=B+C C=C+A A=A+B


(of course you need to wrap the send function in order to it parse the packet object) :P

Yea would be cool to talk to you online :)

At all, im not really that donkey :[

Fr3DBr


Ersan

#11
000010  FF 50 67 00 00 00 00 00 8B 19 C8 26 FD 5D 05 00   .Pg........&.]..
000020  00 20 58 7D 99 CB C6 01 76 65 72 2D 49 58 38 36   . X}....ver-IX86
000030  2D 33 2E 6D 70 71 00 41 3D 31 34 33 38 37 31 33   -3.mpq.A=1438713
000040  39 31 31 20 43 3D 34 36 32 34 32 30 34 31 38 20   911 C=462420418   
000050  42 3D 32 35 33 35 38 36 30 38 38 32 20 34 20 41   B=2535860882 4 A
000060  3D 41 2D 53 20 42 3D 42 2B 43 20 43 3D 43 2B 41   =A-S B=B+C C=C+A
000070  20 41 3D 41 2B 42 00                               A=A+B. 


This is where MBNCSutil would be used, you send the information you recieve in this packet to MBNCSutil's checkrevision function, as well as a few other things, and use the information you get to send the next packet.

IM me I can probably help you more.