Valhalla Legends Forums Archive | Battle.net Bot Development | New Bot in Borland Delphi

AuthorMessageTime
werehamster
I will be updating this message as I change things from time to time. Lend me some help from time to time. :)

[quote][BNET Connected]
<BNET Thread Started>
[BNLS Connected]
BNET Waiting: BNLS_REQUESTVERSIONBYTE
<BNLS Thread Started>
BNLS Send: BNLS_REQUESTVERSIONBYTE
BNLS Recv: BNLS_REQUESTVERSIONBYTE
BNLS INFO: Product ID = $07 (Warcraft)
BNLS INFO: Version Byte = $10
BNET Waiting: DONE!
Sent: SID_AUTH_INFO
BNET Recv: SID_PING
BNET Sent: SID_PING
BNET Recv: SID_AUTH_INFO
BNLS Send: BNLS_CHOOSENLSREVISION
BNET Info: Session Key = 00B00100
BNET Info: DLL Revision number = 1
BNET Info: Checksum = "A=143256995 B=515572255 C=472874471 4 A=A-S B=B+C C=C+A A=A^B"
BNLS Send: BNLS_VERSIONCHECK
BNLS Recv: BNLS_CHOOSENLSREVISION
BNLS Info: DLL Revision number Recognized!
BNLS Recv: BNLS_VERSIONCHECK
BNLS Info: Version Check Successful!
BNLS Info: Version = 0026
BNLS Info: CheckSum = 009C
BNLS Info: Version String = "War3.exe 06/28/04 23:37:01 1568211"
BNLS Send: BNLS_CDKEY
BNLS Recv: BNLS_CDKEY
BNLS Info: Successful CD-Key Encryption.
BNLS Info: Session Key = 00F2
BNET Send: SID_AUTH_CHECK[/quote]

[code]unit ClientUnit;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, StdCtrls, PacketConsts;

type
TBNETReadThread = class(TThread)
public
constructor Create(IndyClient: TIdTCPClient);
private
FIndyClient: TIdTCPClient;
FStartPacket: Byte;
FPacketID: Byte;
FPacketLength: Word;
FPacketData: Array[0..64000] of Byte;
FMessage: String;
procedure DisplayString;
procedure ConnectBNLS;
protected
procedure Execute; override;
end;

TBNLSReadThread = class(TThread)
public
FVersionByte : Byte;
FVersion : array[0..3] of Byte;
FVersionString : String;
FSessionKey : Array[0..3] of Byte;
FCheckSum : array[0..3] of Byte;
constructor Create(IndyClient: TIdTCPClient);
private
FIndyClient: TIdTCPClient;
FPacketLength: Word;
FPacketID: Byte;
FPacketData: Array[0..64000] of Byte;
FMessage: String;
procedure DisplayString;
protected
procedure Execute; override;
end;


TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
Memo2: TMemo;
IdTCPClient2: TIdTCPClient;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
procedure IdTCPClient1Connected(Sender: TObject);
procedure IdTCPClient1Disconnected(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure IdTCPClient2Connected(Sender: TObject);
procedure IdTCPClient2Disconnected(Sender: TObject);
private
tr1: TBNETReadThread;
tr2: TBNLSReadThread;
public
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

constructor TBNETReadThread.Create(IndyClient: TIdTCPClient);
begin
FIndyClient := IndyClient;
inherited Create(false);
end;

constructor TBNLSReadThread.Create(IndyClient: TIdTCPClient);
begin
FIndyClient := IndyClient;
FVersionByte := 0;
inherited Create(false);
end;


procedure TBNETReadThread.DisplayString;
begin
Form1.Memo1.Lines.Add(FMessage);
end;

procedure TBNETReadThread.ConnectBNLS;
begin
try
Form1.IdTCPClient2.Host := 'bnls.valhallalegends.com';
Form1.IdTCPClient2.Port := 9367;
Form1.IdTCPClient2.Connect;
except
on E: Exception do
Begin
Form1.Memo1.Lines.Add('BNLS Connection Error: '+E.Message);
try
Form1.IdTCPClient2.Disconnect;
except
on E: Exception do Form1.Memo1.Lines.Add('BNLS Connection Error Part 2: '+E.Message);
end;
Terminate;
End;
end;
end;


procedure TBNLSReadThread.DisplayString;
begin
Form1.Memo1.Lines.Add(FMessage);
end;


procedure TBNETReadThread.Execute;
var
AByte,AByte2,I : Byte;
AString : String;
procedure DoDisplay(S: String);
begin
FMessage := S;
Synchronize(DisplayString);
end;
begin
If not terminated and FIndyClient.Connected then
Begin
DoDisplay('<BNET Thread Started>');
Synchronize(ConnectBNLS);
AByte := 1; // Protocol Byte
FIndyClient.OpenWriteBuffer();
FIndyClient.WriteBuffer(AByte,1,True);
FIndyClient.FlushWriteBuffer();
FIndyClient.OpenWriteBuffer();
If Form1.tr2.FVersionByte = 0 then
Begin
DoDisplay('BNET Waiting: BNLS_REQUESTVERSIONBYTE');
while Form1.IdTCPClient2.Connected and (Form1.tr2.FVersionByte = 0) do
Windows.Sleep(0);
DoDisplay('BNET Waiting: DONE!');
End;
If not Form1.IdTCPClient2.Connected then
Begin
DoDisplay('BNET Terminating: Requires BNLS connection.');
Terminate;
Exit;
End;
For I := $00 to $0F do
FIndyClient.WriteBuffer(SID_AUTH_INFO_Data[I],1);
AByte := Form1.tr2.FVersionByte;
FIndyClient.WriteBuffer(AByte,1);
For I := $11 to $39 do
FIndyClient.WriteBuffer(SID_AUTH_INFO_Data[I],1);
FIndyClient.FlushWriteBuffer();

DoDisplay('Sent: SID_AUTH_INFO');
End;

while not Terminated and FIndyClient.Connected do
try
FIndyClient.ReadBuffer(FStartPacket,1);
FIndyClient.ReadBuffer(FPacketID,1);
FIndyClient.ReadBuffer(AByte,1);
FIndyClient.ReadBuffer(FPacketLength,1);
FPacketLength := (FPacketLength SHL 8) + AByte;
FIndyClient.ReadBuffer(FPacketData,FPacketLength-4);
Case FStartPacket of
$FF :
Case FPacketID of
SID_NULL : DoDisplay('BNET Recv: SID_NULL');
SID_CLIENTID : DoDisplay('BNET Recv: SID_CLIENTID');
SID_STARTVERSIONING : DoDisplay('BNET Recv: SID_STARTVERSIONING');
SID_REPORTVERSION : DoDisplay('BNET Recv: SID_REPORTVERSION');
SID_GETADVLISTEX : DoDisplay('BNET Recv: SID_GETADVLISTEX');
SID_ENTERCHAT : DoDisplay('BNET Recv: SID_ENTERCHAT');
SID_GETCHANNELLIST : DoDisplay('BNET Recv: SID_GETCHANNELLIST');
SID_CHATEVENT : DoDisplay('BNET Recv: SID_CHATEVENT');
SID_FLOODDETECTED : DoDisplay('BNET Recv: SID_FLOODDETECTED');
SID_UDPPINGRESPONSE : DoDisplay('BNET Recv: SID_UDPPINGRESPONSE');
SID_MESSAGEBOX : DoDisplay('BNET Recv: SID_MESSAGEBOX');
SID_PING :
Begin
DoDisplay('BNET Recv: SID_PING');
FIndyClient.OpenWriteBuffer();
FIndyClient.WriteBuffer(FStartPacket,1);
FIndyClient.WriteBuffer(FPacketID,1);
AByte := FPacketLength SHR 8;
FIndyClient.WriteBuffer(AByte,1);
AByte := FPacketLength AND $FF;
FIndyClient.WriteBuffer(AByte,1);
FIndyClient.WriteBuffer(FPacketData,FPacketLength-4);
FIndyClient.FlushWriteBuffer();
DoDisplay('BNET Sent: SID_PING');
End;
SID_READUSERDATA : DoDisplay('BNET Recv: SID_READUSERDATA');
SID_LOGONCHALLENGE : DoDisplay('BNET Recv: SID_LOGONCHALLENGE');
SID_LOGONRESPONSE : DoDisplay('BNET Recv: SID_LOGONRESPONSE');
SID_CREATEACCOUNT : DoDisplay('BNET Recv: SID_CREATEACCOUNT');
SID_CHANGEPASSWORD : DoDisplay('BNET Recv: SID_CHANGEPASSWORD');
SID_CDKEY2 : DoDisplay('BNET Recv: SID_CDKEY2');
SID_CREATEACCOUNT2 : DoDisplay('BNET Recv: SID_CREATEACCOUNT2');
SID_LOGONREALMEX : DoDisplay('BNET Recv: SID_LOGONREALMEX');
SID_AUTH_INFO :
Begin
DoDisplay('BNET Recv: SID_AUTH_INFO');
If not Form1.IdTCPClient2.Connected then
Begin
DoDisplay('BNET: Cannot Continue further without BNLS.');
Terminate;
Exit;
End;
//---BNLS_CHOOSENLSREVISION---
// FPacketData[01..00] = NLS revision
with Form1.IdTCPClient2 do
Begin
OpenWriteBuffer();
Abyte := 7; //Length header
WriteBuffer(AByte,1);
AByte := 0;
WriteBuffer(AByte,1);
AByte := BNLS_CHOOSENLSREVISION;

WriteBuffer(AByte,1);
WriteBuffer(FPacketData[0],2);
AByte := 0;
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
FlushWriteBuffer();
DoDisplay('BNLS Send: BNLS_CHOOSENLSREVISION');
End;
form1.tr2.FSessionKey[0] := FPacketData[8];
form1.tr2.FSessionKey[1] := FPacketData[9];
form1.tr2.FSessionKey[2] := FPacketData[10];
form1.tr2.FSessionKey[0] := FPacketData[11];

DoDisplay('BNET Info: Session Key = '
+IntToHex(form1.tr2.FSessionKey[0],2)
+IntToHex(form1.tr2.FSessionKey[1],2)
+IntToHex(form1.tr2.FSessionKey[2],2)
+IntToHex(form1.tr2.FSessionKey[3],2));

AByte := $11;
AString := '';
AByte2 := 0;
While FPacketData[AByte] <> 0 do
Begin
AString := AString + Char(FPacketData[AByte]);
If Char(FPacketData[AByte]) = '.' then
AByte2 := StrToInt(Char(FPacketData[AByte-1]));
AByte := AByte + 1;
End;
DoDisplay('BNET Info: DLL Revision number = '+IntToStr(AByte2));
AByte := AByte + 1;
AString := '';
While FPacketData[AByte] <> 0 do
Begin
AString := AString + Char(FPacketData[AByte]);
AByte := AByte + 1;
End;
DoDisplay('BNET Info: Checksum = "'+AString+'"');
//---BNLS_VERSIONCHECK---
with Form1.IdTCPClient2 do
Begin
OpenWriteBuffer();
AByte := 11; //header + id + ver
AByte := AByte + Length(AString) + 1;
WriteBuffer(AByte,1);
AByte := 0;
WriteBuffer(AByte,1);
AByte := BNLS_VERSIONCHECK;
WriteBuffer(AByte,1);
AByte := PRODUCT_WARCRAFT3;
WriteBuffer(AByte,1);
AByte := 0;
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte2,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AString[1],Length(AString));
WriteBuffer(AByte,1);
FlushWriteBuffer();
DoDisplay('BNLS Send: BNLS_VERSIONCHECK');
End;
End;
SID_AUTH_CHECK : DoDisplay('BNET Recv: SID_AUTH_CHECK');
SID_FRIENDLIST : DoDisplay('BNET Recv: SID_FRIENDLIST');
SID_FRIENDUPDATE : DoDisplay('BNET Recv: SID_FRIENDUPDATE');
SID_FRIENDADDED : DoDisplay('BNET Recv: SID_FRIENDADDED');
SID_FRIENDREMOVED : DoDisplay('BNET Recv: SID_FRIENDREMOVED');
SID_FRIENDMOVED : DoDisplay('BNET Recv: SID_FRIENDMOVED');
SID_FINDCLANCANDIDATES : DoDisplay('BNET Recv: SID_FINDCLANCANDIDATES');
SID_INVITEMULTIPLEUSERS : DoDisplay('BNET Recv: SID_INVITEMULTIPLEUSERS');
SID_DISBANDCLAN : DoDisplay('BNET Recv: SID_DISBANDCLAN');
SID_CLANINFO : DoDisplay('BNET Recv: SID_CLANINFO');
SID_CLANREQUEST : DoDisplay('BNET Recv: SID_CLANREQUEST');
SID_CLANINVITE : DoDisplay('BNET Recv: SID_CLANINVITE');
SID_CLANMOTD : DoDisplay('BNET Recv: SID_CLANMOTD');
SID_CLANMEMBERLIST : DoDisplay('BNET Recv: SID_CLANMEMBERLIST');
SID_CLANMEMBERUPDATE : DoDisplay('BNET Recv: SID_CLANMEMBERUPDATE');
SID_CLANPROMOTION : DoDisplay('BNET Recv: SID_CLANPROMOTION');
end;
Else
Begin
DoDisplay('BNET Recv: Unknown Packet $'+IntToHex(FPacketID,2));
End;
End;
except on E: Exception do Form1.Memo1.Lines.Add('BNET Thread Error: '+E.Message);
end;
DoDisplay('<BNET Thread Ended>');
end;

procedure TBNLSReadThread.Execute;
var
AByte,I : Byte;
AWord : Word;
AString : String;
PacketHeader : Byte;
PacketLength : Word;
PacketData : Array[0..64000] of Byte;
procedure DoDisplay(S: String);
begin
FMessage := S;
Synchronize(DisplayString);
end;
begin
If not terminated and FIndyClient.Connected then
Begin
DoDisplay('<BNLS Thread Started>');
FIndyClient.OpenWriteBuffer();
AByte := 7; // Length DDWORD;
FIndyClient.WriteBuffer(AByte,1);
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
AByte := BNLS_REQUESTVERSIONBYTE;
FIndyClient.WriteBuffer(AByte,1);
AByte := PRODUCT_WARCRAFT3;
FIndyClient.WriteBuffer(AByte,1);
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
FIndyClient.FlushWriteBuffer();
DoDisplay('BNLS Send: BNLS_REQUESTVERSIONBYTE');
End;
while not Terminated and FIndyClient.Connected do
begin
PacketLength := 0;
FIndyClient.ReadBuffer(AByte,1);
PacketLength := AByte;
FIndyClient.ReadBuffer(AByte,1);
PacketLength := PacketLength + AByte SHL 8;
FIndyClient.ReadBuffer(PacketHeader,1);
If PacketLength > 3 then
FIndyClient.ReadBuffer(PacketData,PacketLength-3);
Case PacketHeader of
BNLS_NULL : DoDisplay('BNLS Recv: BNLS_NULL');
BNLS_CDKEY    :
Begin
DoDisplay('BNLS Recv: BNLS_CDKEY');
If PacketData[0] = 1 then
DoDisplay('BNLS Info: Successful CD-Key Encryption.')
else
Begin
DoDisplay('BNLS Info: Unsuccessful CD-Key Encryption! Halting.');
FIndyClient.Disconnect;
Terminate;
Exit;
End;
FSessionKey[0] := PacketData[4];
FSessionKey[1] := PacketData[5];
FSessionKey[2] := PacketData[6];
FSessionKey[3] := PacketData[7];
DoDisplay('BNLS Info: Session Key = '+IntToHex(DWord(FSessionKey[0]),4));
//---SID_AUTH_CHECK---
with form1.IdTCPClient1 do
Begin
OpenWriteBuffer();
AByte := $FF;
WriteBuffer(AByte,1);
AByte := SID_AUTH_CHECK;
WriteBuffer(AByte,1);
//Length xx 00
AByte := 4 + 4 + 4 + 4 + 4 + 4 + (9*4)
+ Length(Form1.Edit2.text) + 1
+ Length(FVersionString) + 1;
WriteBuffer(AByte,1);
AByte := 0;
WriteBuffer(AByte,1);
//Session Key
WriteBuffer(form1.tr2.FSessionKey[0],4);
//Version
WriteBuffer(form1.tr2.FVersion[0],4);
//Checksum
WriteBuffer(form1.tr2.FCheckSum[0],4);
//# Keys xx 00
AByte := $01;
WriteBuffer(AByte,1);
AByte := $00;
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
//Bool 00 00
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
WriteBuffer(AByte,1);
//9 DWORDS CD-Key Data
WriteBuffer(PacketData[11],36);
//String Version Check Stat String
WriteBuffer(FVersionString[1],Length(FVersionString));
WriteBuffer(AByte,1);
//String CD-Key Owner Name
AString := Form1.Edit2.Text;
WriteBuffer(AString[1],Length(AString));
WriteBuffer(AByte,1);
FlushWriteBuffer();
DoDisplay('BNET Send: SID_AUTH_CHECK');
End;

End;
BNLS_LOGONCHALLENGE    : DoDisplay('BNLS Recv: BNLS_LOGONCHALLENGE');
BNLS_LOGONPROOF       : DoDisplay('BNLS Recv: BNLS_LOGONPROOF');
BNLS_CREATEACCOUNT       : DoDisplay('BNLS Recv: BNLS_CREATEACCOUNT');
BNLS_CHANGECHALLENGE       : DoDisplay('BNLS Recv: BNLS_CHANGECHALLENGE');
BNLS_CHANGEPROOF       : DoDisplay('BNLS Recv: BNLS_CHANGEPROOF');
BNLS_UPGRADECHALLENGE       : DoDisplay('BNLS Recv: BNLS_UPGRADECHALLENGE');
BNLS_UPGRADEPROOF       : DoDisplay('BNLS Recv: BNLS_UPGRADEPROOF');
BNLS_VERSIONCHECK       :
Begin
DoDisplay('BNLS Recv: BNLS_VERSIONCHECK');
If PacketData[0] = 1 then
DoDisplay('BNLS Info: Version Check Successful!')
else
Begin
DoDisplay('BNLS Info: Version Check *NOT* Successful! Halting.');
FIndyClient.Disconnect;
Terminate;
Exit;
End;
FVersion[0] := PacketData[4];
FVersion[1] := PacketData[5];
FVersion[2] := PacketData[6];
FVersion[3] := PacketData[7];
DoDisplay('BNLS Info: Version = '+IntToHex(DWord(FVersion[0]),4));

FCheckSum[0] := PacketData[8];
FCheckSum[1] := PacketData[9];
FCheckSum[2] := PacketData[10];
FCheckSum[3] := PacketData[11];
DoDisplay('BNLS Info: CheckSum = '+IntToHex(DWord(FCheckSum[0]),4));

AString := '';
AByte := 12;
While PacketData[AByte] <> 0 do
Begin
AString := AString + Char(PacketData[AByte]);
AByte := AByte + 1;
End;
FVersionString := AString;
DoDisplay('BNLS Info: Version String = "'+FVersionString+'"');


FIndyClient.OpenWriteBuffer();
AString := Form1.Edit4.text;
AByte := 3 + 4 + Length(AString) + 1;
FIndyClient.WriteBuffer(AByte,1);
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
AByte := BNLS_CDKEY;
FIndyClient.WriteBuffer(AByte,1);
FIndyClient.WriteBuffer(form1.tr2.FSessionKey[0],4);
FIndyClient.WriteBuffer(AString[1],Length(AString));
AByte := 0;
FIndyClient.WriteBuffer(AByte,1);
FIndyClient.FlushWriteBuffer();
DoDisplay('BNLS Send: BNLS_CDKEY');
End;
BNLS_CONFIRMLOGON       : DoDisplay('BNLS Recv: BNLS_CONFIRMLOGON');
BNLS_HASHDATA          : DoDisplay('BNLS Recv: BNLS_HASHDATA');
BNLS_CDKEY_EX          : DoDisplay('BNLS Recv: BNLS_CDKEY_EX');
BNLS_CHOOSENLSREVISION    :
Begin
DoDisplay('BNLS Recv: BNLS_CHOOSENLSREVISION');
If PacketData[0] = 1 then
DoDisplay('BNLS Info: DLL Revision number Recognized!')
else
Begin
DoDisplay('BNLS Info: DLL Revision number *NOT* Recognized! Halting.');
FIndyClient.Disconnect;
Terminate;
Exit;
End
End;
BNLS_AUTHORIZE       : DoDisplay('BNLS Recv: BNLS_AUTHORIZE');
BNLS_AUTHORIZEPROOF       : DoDisplay('BNLS Recv: BNLS_AUTHORIZEPROOF');
BNLS_REQUESTVERSIONBYTE    :
Begin
DoDisplay('BNLS Recv: BNLS_REQUESTVERSIONBYTE');
AWord := PacketData[0] + PacketData[1] SHL 8;
Case Aword of
0 :
Begin
DoDisplay('BNLS INFO: Product ID = $'+IntToHex(Aword,2)+' (FAILED)');
DoDisplay('BNLS INFO: Version Byte not recieved.');
End;
7 : //Warcraft
Begin
DoDisplay('BNLS INFO: Product ID = $'+IntToHex(Aword,2)+' (Warcraft)');
DoDisplay('BNLS INFO: Version Byte = $'+IntToHex(PacketData[4],2));
FVersionByte := PacketData[4];
End;
Else
Begin
DoDisplay('BNLS INFO: Product ID = $'+IntToHex(Aword,2)+' (UnSupport Yet)');
DoDisplay('BNLS INFO: Version Byte = $'+IntToHex(PacketData[4],2));
FVersionByte := PacketData[4];
End;
End;
End;
BNLS_VERIFYSERVER       : DoDisplay('BNLS Recv: BNLS_VERIFYSERVER');
BNLS_RESERVESERVERSLOTS    : DoDisplay('BNLS Recv: BNLS_RESERVESERVERSLOTS');
BNLS_SERVERLOGONCHALLENGE: DoDisplay('BNLS Recv: BNLS_SERVERLOGONCHALLENGE');
BNLS_SERVERLOGONPROOF       : DoDisplay('BNLS Recv: BNLS_SERVERLOGONPROOF');
Else
DoDisplay('BNLS Recv: Unknown $'+IntToHex(PacketHeader,2));
End;
end;
DoDisplay('<BNLS Thread Ended>');
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
If Button1.Caption = 'Connect' then
try
Button1.Caption := 'Disconnect';
//IdTCPClient1.Host := '63.240.202.129';
//IdTCPClient1.Host := 'useast.battle.net';
IdTCPClient1.Host := Edit5.Text;
IdTCPClient1.Port := 6112;
IdTCPClient1.Connect;
except
on E: Exception do
Begin
Memo1.Lines.Add('BNET Connection Error: '+E.Message);
Button1.Caption := 'Connect';
End;
end
else
try
Button1.Caption := 'Connect';
IdTCPClient1.Disconnect;
except
on E: Exception do Memo1.Lines.Add('BNET Connection Error (part 2): '+E.Message);
end;
end;

procedure TForm1.IdTCPClient1Connected(Sender: TObject);
begin
Memo1.Lines.Add('[BNET Connected]');
Button1.Caption := 'Disconnect';
tr1 := TBNETReadThread.Create(IdTCPClient1);
end;

procedure TForm1.IdTCPClient2Connected(Sender: TObject);
begin
Memo1.Lines.Add('[BNLS Connected]');
tr2 := TBNLSReadThread.Create(IdTCPClient2);
end;


procedure TForm1.IdTCPClient1Disconnected(Sender: TObject);
begin
if IdTCPClient1.ClosedGracefully then
Memo1.Lines.Add('[BNET Disconnected gracefully]')
else
Memo1.Lines.Add('[BNET Disconnected abruptly]');
tr1.Free;
Button1.Caption := 'Connect';
end;

procedure TForm1.IdTCPClient2Disconnected(Sender: TObject);
begin
if IdTCPClient2.ClosedGracefully then
Memo1.Lines.Add('[BNLS Disconnected gracefully]')
else
Memo1.Lines.Add('[BNLS Disconnected abruptly]');
tr2.Free;
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (key = #13) then
begin
// IdTCPClient1.Write(Edit1.Text);
end;
end;
end.
[/code]
August 31, 2004, 10:12 AM
St0rm.iD
Do you know about BnetDocs yet?
August 31, 2004, 2:55 PM
Arta
Yes - and did you have a specific question? You can read the BNLS spec if you need info on that.
August 31, 2004, 4:56 PM
UserLoser.
Open BnetDocs has hardly any packets documented compared to BnetDocs. It doesn't have realm, Storm UDP, or other stuff either. But comparing it's BNCS list to BnetDoc's is still quite a big difference
August 31, 2004, 8:03 PM
werehamster
Obviousely I am using BNETDocs if I am using their constants and stuff. ;)

Anyway, BNET docs does not explain the sequence of BNLS all that much. There is a little bit of logon sequence for starcraft and war2bne, but not much for WC3.

My question involve the next step. I know I have to send SID_AUTH_INFO data to BNLS and then take that info and send it back to BNET. I am looking for details on this...
August 31, 2004, 9:25 PM
TangoFour
So far, the WarCraft 3 Login Sequence is:

C->S: 0x50
S->C: 0x25
S->C: 0x50
C->S: 0x25 (optional)
C->S: 0x51
S->C: 0x51

After that, it depends on what you want to do - usually log in, but you can also create an account at this point.

After being logged in - the packets get a bit blurry (for instance, I'm haven't figured out what exactly 0x44 does, the documentation I've found at this forum is sketchy at best).
August 31, 2004, 9:46 PM
werehamster
Anyway, I can't get BNET to reply with SID_AUTH_CHECK for some reason.


[code]2 24.186.0.166:1592 63.240.202.139:6112 1 Send
0000 01 .

3 24.186.0.166:1593 63.161.183.202:9367 7 Send
0000 07 00 10 07 00 00 00 .......

4 63.161.183.202:9367 24.186.0.166:1593 11 Recv
0000 0B 00 10 07 00 00 00 10 00 00 00 ...........

5 24.186.0.166:1592 63.240.202.139:6112 58 Send
0000 FF 50 3A 00 00 00 00 00 36 38 58 49 50 58 33 57 .P:.....68XIPX3W
0010 10 00 00 00 53 55 6E 65 18 BA 00 A6 F0 00 00 00 ....SUne........
0020 09 04 00 00 09 04 00 00 55 53 41 00 55 6E 69 74 ........USA.Unit
0030 65 64 20 53 74 61 74 65 73 00 ed States.

6 63.240.202.139:6112 24.186.0.166:1592 235 Recv
0000 FF 25 08 00 0E 25 15 D0

FF 50 E3 00 02 00 00 00 .%...%...P......
0010 95 39 A9 89 5D A6 01 00 00 95 2E 62 91 E7 C3 01 .9..]......b....
0020 49 58 38 36 76 65 72 30 2E 6D 70 71 00 41 3D 32 IX86ver0.mpq.A=2
0030 31 35 36 36 31 31 37 33 20 42 3D 31 37 33 30 38 15661173 B=17308
0040 30 37 35 38 20 43 3D 34 30 39 30 32 38 38 39 38 0758 C=409028898
0050 20 34 20 41 3D 41 2D 53 20 42 3D 42 2B 43 20 43 4 A=A-S B=B+C C
0060 3D 43 5E 41 20 41 3D 41 2B 42 00 BD A0 92 6C 5C =C^A A=A+B....l\
0070 B5 07 30 C3 A9 6A EB 3A EA 96 DA 52 B2 DF D4 BD ..0..j.:...R....
0080 CE 7C 7B 83 4D D1 19 97 15 94 71 D9 98 01 2A 67 .|{.M.....q...*g
0090 C8 7C A5 8E 5E 4E 68 E1 FF B0 B6 56 3A 0B AE 09 .|..^Nh....V:...
00A0 43 2E 23 29 4E 83 AC 60 FE 12 8A 95 F7 DF 04 6F C.#)N..`.......o
00B0 F3 BF A5 FA 06 43 D2 4E 18 FE DD D6 A2 EF DC 9D .....C.N........
00C0 E9 80 BE A1 87 20 A0 4F 47 A2 B2 57 4F 5F 5B 67 ..... .OG..WO_[g
00D0 7E 1F 8B 19 A0 EB 6F 45 18 EE 94 56 BB A9 73 6B ~.....oE...V..sk
00E0 31 34 8A A3 74 F0 EE 0F DA 25 5A 14..t....%Z

7 24.186.0.166:1592 63.240.202.139:6112 8 Send
0000 FF 25 00 08 0E 25 15 D0 .%...%..

8 24.186.0.166:1593 63.161.183.202:9367 7 Send
0000 07 00 0D 02 00 00 00 .......

9 24.186.0.166:1593 63.161.183.202:9367 73 Send
0000 49 00 09 07 00 00 00 00 00 00 00 41 3D 32 31 35 I..........A=215
0010 36 36 31 31 37 33 20 42 3D 31 37 33 30 38 30 37 661173 B=1730807
0020 35 38 20 43 3D 34 30 39 30 32 38 38 39 38 20 34 58 C=409028898 4
0030 20 41 3D 41 2D 53 20 42 3D 42 2B 43 20 43 3D 43 A=A-S B=B+C C=C
0040 5E 41 20 41 3D 41 2B 42 00 ^A A=A+B.

10 63.161.183.202:9367 24.186.0.166:1593 7 Recv
0000 07 00 0D 01 00 00 00 .......

11 63.161.183.202:9367 24.186.0.166:1593 50 Recv
0000 32 00 09 01 00 00 00 26 10 00 01 20 D6 F1 5D 57 2......&... ..]W
0010 61 72 33 2E 65 78 65 20 30 36 2F 32 38 2F 30 34 ar3.exe 06/28/04
0020 20 32 33 3A 33 37 3A 30 31 20 31 35 36 38 32 31 23:37:01 156821
0030 31 00 1.

12 24.186.0.166:1593 63.161.183.202:9367 34 Send
0000 22 00 01 00 A6 01 00 65 6E 63 65 68 63 63 79 65 "......encehccye
0010 72 68 77 6B 65 77 6E 36 xx xx xx xx xx xx xx xx rhwkewn6!!!!!!!!
0020 38 00 8.

13 63.161.183.202:9367 24.186.0.166:1593 47 Recv
0000 2F 00 01 01 00 00 00 DC 52 45 43 1A 00 00 00 0E /.......REC.....
0010 00 00 00 80 4E 20 00 00 00 00 00 79 EE 3E 23 30 ....N .....y.>#0
0020 88 A5 75 3D 3D 1F 74 5E 76 00 88 32 0A C6 D9 ..u==.t^v..2...

14 24.186.0.166:1592 63.240.202.139:6112 104 Send
0000 FF 51 68 00 DC 52 45 43 26 10 00 01 20 D6 F1 5D .Qh..REC&... ..]
0010 01 00 00 00 00 00 00 00 00 0E 00 00 00 80 4E 20 ..............N
0020 00 00 00 00 00 79 EE 3E 23 30 88 A5 75 3D 3D 1F .....y.>#0..u==.
0030 74 5E 76 00 88 32 0A C6 D9 31 31 00 57 61 72 33 t^v..2...11.War3
0040 2E 65 78 65 20 30 36 2F 32 38 2F 30 34 20 32 33 .exe 06/28/04 23
0050 3A 33 37 3A 30 31 20 31 35 36 38 32 31 31 00 54 :37:01 1568211.T
0060 44 41 2D 42 6F 74 32 00 DA-Bot2.[/code]

Now I don't get a response. Some help? All I am getting are SID_NULLs every minute or so.
September 1, 2004, 10:34 AM
Soul Taker
After looking for quite a while, I think I found it:
[quote]
13 63.161.183.202:9367 24.186.0.166:1593 47 Recv
0000 2F 00 01 01 00 00 00 DC 52 45 43 1A 00 00 00 0E /.......REC.....
0010 00 00 00 80 4E 20 00 00 00 00 00 79 EE 3E 23 30 ....N .....y.>#0
0020 88 A5 75 3D 3D 1F 74 5E 76 00 88 32 0A C6 D9 ..u==.t^v..2...

The bold part is the CD-key hash.

14 24.186.0.166:1592 63.240.202.139:6112 104 Send
0000 FF 51 68 00 DC 52 45 43 26 10 00 01 20 D6 F1 5D .Qh..REC&... ..]
0010 01 00 00 00 00 00 00 00 00 0E 00 00 00 80 4E 20 ..............N
0020 00 00 00 00 00 79 EE 3E 23 30 88 A5 75 3D 3D 1F .....y.>#0..u==.
0030 74 5E 76 00 88 32 0A C6 D9 31 31 00 57 61 72 33 t^v..2...11.War3
0040 2E 65 78 65 20 30 36 2F 32 38 2F 30 34 20 32 33 .exe 06/28/04 23
0050 3A 33 37 3A 30 31 20 31 35 36 38 32 31 31 00 54 :37:01 1568211.T
0060 44 41 2D 42 6F 74 32 00 DA-Bot2.

The bold part here is what you are sending for your CD-key hash. It looks like you extracting and/or storing it improperly.
[/quote]

GRRRR, why can't you use bold in code blocks!
September 1, 2004, 3:22 PM
Kp
This one's easy. You botched a length field. :) Check out your SID_PING response:

[quote author=werehamster link=board=17;threadid=8487;start=0#msg78525 date=1094034863][code]7 24.186.0.166:1592 63.240.202.139:6112 8 Send
0000 FF 25 00 08 0E 25 15 D0 .%...%..[/code]Now I don't get a response. Some help? All I am getting are SID_NULLs every minute or so.[/quote]

You're claiming to send a message which is 0x0800 = 2048 bytes long. So, it will eventually respond if you keep answering long enough. ;) Reverse the bytes in your header, so that you properly stated the message to be 0x0008 bytes long, instead of 0x0800.
September 1, 2004, 3:30 PM
werehamster
[quote]
This one's easy. You botched a length field. :) Check out your SID_PING response:
[/quote]

Ah, how did I miss that! :)

Though I think BNET may have that packet coded as a fixed length cause I think I got a response after that.

[quote]... sending for your CD-key hash. It looks like you extracting and/or storing it improperly.[/quote]

I will have to take another look at this. I thought I checked it 3 times. I'm at work now so I don't really have time to check the references, but I thought I got this part right. Anyone want to confirm it for me? :)

Anyway, thanks guys. I will see if these will fix my problems when I get home. :)
September 1, 2004, 3:48 PM
werehamster
After fixing the Ping, I did get a response, but I got a 203 failure. The other problem listed seems like I did it right. Any confirmations?
September 2, 2004, 5:45 AM

Search