• Welcome to Valhalla Legends Archive.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - PhoeNix_FasT

#1
Quote from: Camel on August 18, 2007, 11:30 AM
Have you looked at a packet log of your bot connecting? It's possible that your packet buffer is messed up - you can mange 0x50 pretty bad without getting disconnected.


             public static byte[] Create0x50(String productID, byte versionByte)
            {
               

                CultureInfo ci = CultureInfo.CurrentCulture;
                RegionInfo ri = RegionInfo.CurrentRegion;
                TimeSpan ts = DateTime.UtcNow - DateTime.Now;

                BncsPacket pack = new BncsPacket((byte)BattleNet.PacketID.SID_AUTH_INFO);
                pack.Insert(0);
                pack.InsertDwordString(BattleNet.PlatformCodes.Intel_x86);
                pack.InsertDwordString(productID);
                pack.InsertByte(versionByte);
                pack.Insert(0);
                pack.Insert(0);
                pack.Insert((int)(-ts.TotalMinutes));
                pack.Insert(ci.LCID);
                pack.InsertDwordString(string.Format("{0}{1}", ci.TwoLetterISOLanguageName, ri.TwoLetterISORegionName));
                pack.InsertCString(ri.ThreeLetterWindowsRegionName);
                pack.InsertCString(ri.DisplayName);
                return pack.GetData();
            }


That's my 0x50

and yes i noticed a big diffrence on 0x51

That is the Packet Log from Warcraft III


0000  00 15 0c bc 9f de 00 11  d8 60 88 97 08 00 45 00   ........ .`....E.
0010  00 b8 b3 6e 40 00 80 06  93 d4 c0 a8 b2 17 d5 f8   ...n@... ........
0020  6a 44 0e a9 17 e0 db 30  e3 65 fe 41 51 53 50 18   jD.....0 .e.AQSP.
0030  ff 10 b3 a7 00 00 ff 51  90 00 8f 3d db 01 77 00   .......Q ...=..w.
0040  15 01 68 b2 77 cc 02 00  00 00 00 00 00 00 1a 00   ..h.w... ........
0050  00 00 0e 00 00 00 50 98  2a 00 00 00 00 00 32 18   ......P. *.....2.
0060  db e3 58 91 37 8e c1 00  d7 da 6c 6c 4d ff 4a 6e   ..X.7... ..llM.Jn
0070  3d 5a 1a 00 00 00 12 00  00 00 67 e5 12 00 00 00   =Z...... ..g.....
0080  00 00 33 85 ba dc 19 9b  aa ec 00 f8 e4 ec 05 9d   ..3..... ........
0090  24 b9 2f 7a da 58 77 61  72 33 2e 65 78 65 20 31   $./z.Xwa r3.exe 1
00a0  32 2f 32 38 2f 30 36 20  32 30 3a 33 35 3a 32 31   2/28/06  20:35:21
00b0  20 31 35 37 32 33 30 37  00 50 68 6f 65 4e 69 78    1572307 .PhoeNix
00c0  5f 46 61 53 54 00                                  _FaST.


And this is from my programm


0000  00 15 0c bc 9f de 00 11  d8 60 88 97 08 00 45 00   ........ .`....E.
0010  00 76 b2 a5 40 00 80 06  94 e0 c0 a8 b2 17 d5 f8   .v..@... ........
0020  6a 43 0e a7 17 e0 13 bb  e5 03 c4 0b 8d e9 50 18   jC...... ......P.
0030  ff 0f b3 64 00 00 ff 51  4e 00 a7 c9 dd 0e 15 00   ...d...Q N.......
0040  01 00 1a e2 65 8a 01 00  00 00 00 00 00 00 1a 00   ....e... ........
0050  00 00 0e 00 00 00 50 98  2a 00 00 00 00 00 8f ce   ......P. *.......
0060  c6 06 83 1b 00 66 95 19  ba 03 0a 83 f8 45 1b 0c   .....f.. .....E..
0070  a2 98 77 61 72 33 2e 65  78 65 00 54 65 73 74 20   ..war3.e xe.Test
0080  42 6f 74 00                                        Bot.


So diffrent.... i'll try to work on it
#2
I tried Diablo 2 and Warcraft 3 RoC

EDIT : Maybe it helps if i show the code too


         private void HandleAuthInfo(DataReader dr)
         {
             m_loginType = dr.ReadUInt32();
             m_srvToken = dr.ReadUInt32();
             m_udpVal = dr.ReadUInt32();
             m_mpqFiletime = dr.ReadInt64();
             m_verFilename = dr.ReadCString();
             m_valString = dr.ReadCString();

             richTextBox1.AppendText("\n0x50 Packet Content:\n");
             richTextBox1.AppendText("------------------------------------\n");
             richTextBox1.AppendText("m_loginType: " + m_loginType + "\n");
             richTextBox1.AppendText("m_srvToken: " + m_srvToken + "\n");
             richTextBox1.AppendText("m_udpVal: " + m_udpVal + "\n");
             richTextBox1.AppendText("m_mpqFiletime: " + m_mpqFiletime + "\n");
             richTextBox1.AppendText("m_verFilename: " + m_verFilename + "\n\n");
     
             int crResult, exeVer;
             string exeInfo = null;
             string strLocalGamePath = "C:\\Programme\\Warcraft III\\";
             string[] files = GetFileListForCheckRevision(strLocalGamePath, "WAR3");

             if (files == null)
                 return;

             int mpqNum = Bot.CheckRevisionNew.ExtractMPQNumber(m_verFilename);
             richTextBox1.AppendText("\nMPQ Number = " + mpqNum +"\n");
             crResult = Bot.CheckRevisionNew.DoCheckRevision(m_valString, files, mpqNum);
             richTextBox1.AppendText("\ncrResult = " + crResult + "\n");
             exeVer = Bot.CheckRevisionNew.GetExeInfo(files[0], out exeInfo);
             richTextBox1.AppendText("\nexeVer = " + exeVer + "\n");

             CdKey key1, key2 = null;
             key1 = new CdKey("MY CODE HERE IN UPPERCASE WITHOUT DASHES"); // Warcraft III RoC

             m_clientToken = unchecked((uint)new Random().Next());

             BncsPacket pck0x51 = new BncsPacket((byte)0x51);
             pck0x51.Insert(m_clientToken);
             pck0x51.Insert(exeVer);
             pck0x51.Insert(crResult);
             pck0x51.Insert(1);
             pck0x51.Insert(false);
             pck0x51.Insert(key1.Key.Length);
             pck0x51.Insert(key1.Product);
             pck0x51.Insert(key1.Value1);
             pck0x51.Insert(0);
             pck0x51.Insert(key1.GetHash(m_clientToken, m_srvToken));
             pck0x51.InsertCString(exeInfo);
             pck0x51.InsertCString("Test Bot");

             m_clientSocket.Send(pck0x51.GetData(), SocketFlags.None);
         }

#3
SEND -> (0x01) Protocol Byte  1 Bytes sent
SEND -> (0x50) SID_AUTH_INFO  53 Bytes sent
RECV <- (0x25) : 8 Bytes received
RECV <- (0x50) : 232 Bytes received

0x50 Packet Content:
------------------------------------
m_loginType: 2
m_srvToken: 1572257005
m_udpVal: 13964044
m_mpqFiletime: 128013499540000000
m_verFilename: ver-IX86-5.mpq

MPQ Number = 5
crResult = 1864902118
exeVer = 65557

RECV <- (0x51) : 9 Bytes received


Packet 0x51 Content:
------------------------------
result : 0x101
extraInfo :

RECV <- (0x00) : 4 Bytes received



How to fix that 0x101 ?  ???
I've searched the forum already and i found that MPQNumber Problem which is fixed already
#4
Ok... i dont give up  :-\
So i updated the 0x50 Packet.
iRes = 58 Bytes (ok seems the packet reached the server)
i still = 0

to brew : FD_CLOSE and WSAGetLastError() is C++ not C#

Here's my Code now

            IPHostEntry ip = Dns.GetHostByName("useast.battle.net");
            IPAddress[] ips = ip.AddressList;
            IPAddress battleNetIP = ips[0];

            m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint ipEnd = new IPEndPoint(battleNetIP, battleNetPort);
            m_clientSocket.Connect(ipEnd);

            BncsPacket pck0x50 = new BncsPacket((byte)0x50);
            pck0x50.InsertDwordString("0");          // (DWORD)       Protocol ID (0)           
            pck0x50.InsertDwordString("IX86");      // (DWORD)       Platform ID
            pck0x50.InsertDwordString("D2XP");      // (DWORD)       Product ID
            pck0x50.InsertDwordString("0x0b");      // (DWORD)       Version Byte
            pck0x50.InsertDwordString("");          // (DWORD)       Product language
            pck0x50.InsertDwordString("");          // (DWORD)       Local IP for NAT compatibility
            pck0x50.InsertDwordString("");          // (DWORD)       Time zone bias
            pck0x50.InsertDwordString("");          // (DWORD)       Locale ID           
            pck0x50.InsertDwordString("");          // (DWORD)       Language ID
            pck0x50.InsertCString("USA");           // (STRING)     Country abreviation   
            pck0x50.InsertCString("United States"); // (STRING)     Country

            byte[] byteData = new byte[511];

            try
            {
                int iRes = m_clientSocket.Send(pck0x50.GetData(), SocketFlags.None);
                richTextBox1.AppendText("0x50 : " + iRes + " Bytes sent\n");
            }

            catch (Exception exp)
            {
                richTextBox1.AppendText("Exception : " + exp.Message + "\n");
                return;
            }

            int i = m_clientSocket.Receive(byteData);
            richTextBox1.AppendText("Bytes Received : " + i + "\n");

EDIT : Is it better to use Network Stream instead of this what i am doing here ?
#5
            BncsPacket pck0x50 = new BncsPacket((byte)0x50);
            pck0x50.InsertInt32(0);             
            pck0x50.InsertDwordString("IX86"); 
            pck0x50.InsertDwordString("D2XP");
            pck0x50.InsertByte(0x0A);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertDwordString("", 0);   
            pck0x50.InsertCString("USA");       
            pck0x50.InsertCString("United States");

            byte[] byteData = new byte[511];

            try
            {
                m_clientSocket.Send(pck0x50.GetData(), SocketFlags.None);
                richTextBox1.AppendText("Sending 0x50\n");
            }

            catch (Exception exp)
            {
                richTextBox1.AppendText("Exception : " + exp.Message + "\n");
                return;
            }

            int i = m_clientSocket.Receive(byteData);
            richTextBox1.AppendText("Bytes Received :" + i + "\n");


i is still 0 ..  >:(
#6
0x01 ? Sorry didnt find that
I had a look right here : http://ersan.us/src/bnetdocs/sequence.html

it says:

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

So would it be enough with

BncsPacket pck0x01 = new BncsPacket((byte)0x01);

and then send this packet ?
#7
Battle.net Bot Development / 0x50 with C# Problem
August 15, 2007, 01:10 PM
Im new to C# (learning it for 2 Month now) and i tried the simpliest thing : Sending 0x50 and receive an answer.
For this i use MBNCSUtil ( using MBNCSUtil; )
This is what i wrote

            IPHostEntry ip = Dns.GetHostByName("useast.battle.net");
            IPAddress[] ips = ip.AddressList;
            IPAddress battleNetIP = ips[0];

            richTextBox1.AppendText("Address of useast.battle.net : " + battleNetIP + "\n");

            m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint ipEnd = new IPEndPoint(battleNetIP, battleNetPort);
            try
            {
                m_clientSocket.Connect(ipEnd);
            }
            catch (Exception exp)
            {
                richTextBox1.AppendText("Exception : " + exp.Message + "\n");
                return;
            }

            if(m_clientSocket.Connected)
                richTextBox1.AppendText("Connected\n");

            BncsPacket pck0x50 = new BncsPacket((byte)0x50);
            pck0x50.InsertInt32(0);             
            pck0x50.InsertDwordString("IX86"); 
            pck0x50.InsertDwordString("D2XP"); 
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertInt32(0);             
            pck0x50.InsertDwordString("", 0);   
            pck0x50.InsertCString("USA");       
            pck0x50.InsertCString("United States");

            byte[] byteData = new byte[32];

            try
            {
                m_clientSocket.Send(pck0x50.GetData(), SocketFlags.None);   
            }

            catch (Exception exp)
            {
                richTextBox1.AppendText("Exception : " + exp.Message + "\n");
                return;
            }

            int i = m_clientSocket.Receive(byteData);
            richTextBox1.AppendText("Bytes Received :" + i + "\n");

Its my first time i try to use Sockets in C#. Anyways .. i = 0, means i received 0 bytes.
What did i do wrong ?
#8
Battle.net Bot Development / Need Help
September 15, 2006, 04:26 PM
Ok first im programming with C++ and i simply want to connect to europe.battle.net and did this so far :


#include <winsock2.h>
#include <windows.h>
#include <iostream.h>
#include <string.h>

#pragma comment(lib,"wsock32.lib")

int main()
{
char *ip;
long rc;

WSADATA wsa;
WSAStartup(MAKEWORD(2,0),&wsa);
SOCKET s;
SOCKADDR_IN addr;
HOSTENT* EuropeBattleNet;

memset(&addr,0,sizeof(SOCKADDR_IN));
s=socket(AF_INET,SOCK_STREAM,0);
he=gethostbyname("europe.battle.net");
ip = inet_ntoa( *(LPIN_ADDR)*EuropeBattleNet->h_addr_list );

addr.sin_family=AF_INET;
addr.sin_port=htons(6112);
addr.sin_addr.s_addr=inet_addr(ip);

cout<<"Trying to connect to europe.battle.net "<< ip <<"\n\n";

rc=connect(s,(SOCKADDR*)&addr,sizeof(SOCKADDR));

if(rc==SOCKET_ERROR)
cout<<"Error";
else
cout<<"Connected !\n";

return 0;
}


Now i read about SID_AUTH_INFO ( http://bnetdocs.valhallalegends.com/content.php?Section=m&Code=2 )

(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

Now i have to use send(socket,thingtosend,MAX_PATH,0); for every thing ? ( i mean for every listed thing (protocol id etc) )
Its so hard to understand for me :(