Valhalla Legends Forums Archive | Battle.net Bot Development | MBNCSUtil Step By Step

AuthorMessageTime
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.
September 17, 2006, 1:34 PM
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.
September 17, 2006, 5:01 PM
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
September 17, 2006, 5:05 PM
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.
September 17, 2006, 5:09 PM
SSKnight
[quote]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.  [/quote]

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.
September 17, 2006, 5:10 PM
Skywing
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++.
September 17, 2006, 5:12 PM
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...
September 17, 2006, 5:19 PM
LordNevar
[quote author=Skywing link=topic=15726.msg158261#msg158261 date=1158512976]
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.
[/quote]


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.
September 17, 2006, 5:44 PM
Myndfyr
[quote author=Fr3DBr link=topic=15726.msg158264#msg158264 date=1158513560]
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...
[/quote]

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:
[code]
00 01 02 03 04 05 06 07
[/code]
and you had a DataReader called "rdr" reading that byte array, you could do:
[code]
Console.WriteLine("{0:x8}", rdr.ReadInt32());
Console.WriteLine("{0:x8}", rdr.ReadInt32());
[/code]
And you'd get the following output:
[code]
03020100
07060504
[/code]
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.
September 17, 2006, 9:05 PM
Fr3DBr
Well actually i have my own packet class :

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

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

And you get something like :

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

(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 :[
September 17, 2006, 9:37 PM
Fr3DBr
Updated Again !
September 18, 2006, 1:05 AM
Ersan
[code]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.  [/code]

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.
September 18, 2006, 3:42 AM

Search