Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: snowstorm on March 24, 2005, 04:48 PM

Title: A couple of questions (from a newb)
Post by: snowstorm on March 24, 2005, 04:48 PM
I debated about whether or not to post this as I am a complete newb and did not want to be ill met.

Anyway,
I've started trying to create a d2 bot.  So far I've been able to establish a connection:

protected Socket connect (int port) throws IOException
{
String server = "uswest.battle.net";
// Connect method
System.out.println ("\nConnecting to " + server + " on port " + port + "\n");
Socket socket = new Socket (server, port);
OutputStream rawOut = socket.getOutputStream ();
InputStream rawIn = socket.getInputStream ();
BufferedOutputStream buffOut = new BufferedOutputStream (rawOut);
out = new DataOutputStream (buffOut);
in = new DataInputStream (rawIn);
return socket;
} // END connect


But have not been able to find any useful information/tutorials about sending and receiving packets.  Could someone possibly give me the url of a tutorial on this?  (i found one on this site, but the link was broken)
I captured all the packets I need using ethereal, I'm trying to work with the first one a bit:

0000  00 30 bd c5 95 3e 00 11  11 28 42 7f 08 00 45 00   .0...>.. .(B...E.
0010  00 30 73 d9 40 00 80 06  30 a0 c0 a8 02 47 3f f1   .0s.@... 0....G?.
0020  53 6e 0d cd 17 e0 4d 0f  7c b2 00 00 00 00 70 02   Sn....M. |.....p.
0030  ff ff 3d 62 00 00 02 04  05 b4 01 01 04 02         ..=b.... ...... 

00 30 bd c5 95 3e 00 11  <-- this looks like it might be the header, because it is in a few of the other packets and it's at the beginning

I guess my main question is what type is this in?
00 30 bd c5 95 3e 00 11  11 28 42 7f 08 00 45 00
00 30 73 d9 40 00 80 06  30 a0 c0 a8 02 47 3f f1 
53 6e 0d cd 17 e0 4d 0f  7c b2 00 00 00 00 70 02
ff ff 3d 62 00 00 02 04  05 b4 01 01 04 02
I mean if I some how create a byte array consisting of this data and send it to bnet with out.write(b, 0, 20) for example.  Is that the packet?  How would I get this info into a byte array?
I've been looking on google for about an hour and can not really find any useful info so i was hoping someone could help.

Thanks!

Title: Re: A couple of questions (from a newb)
Post by: DeTaiLs on March 24, 2005, 05:05 PM
try looking at http://bnetdocs.valhallalegends.com/content.php that might help you understand more about the packets also try doing a search i am sure this been talked about befor. also i think u need to decomprise d2 packets.
Title: Re: A couple of questions (from a newb)
Post by: Warrior on March 24, 2005, 05:09 PM
Well first if you are going to emulate the client you must send a byte containing 1 to get the server's attention. iago wrote a very good Buffer to make sending packet's easy and it's what I use in JChat (unfinished btw) . You're going to want to use bnetdocs.valhallalegends.com since this is a extremely useful resource as it lists all the packets needed to logon and then some. You're going to want to look at the logon sequence link once you get there and look up the appropriate packets.
Title: Re: A couple of questions (from a newb)
Post by: Warrior on March 24, 2005, 05:09 PM
You need to decompress ingame packets
Title: Re: A couple of questions (from a newb)
Post by: snowstorm on March 24, 2005, 05:11 PM
Yes, I have taken a look around bnetdocs.  I'll try to find iago's buffer, maybe that will help.  thanks
Title: Re: A couple of questions (from a newb)
Post by: Warrior on March 24, 2005, 05:12 PM
It's in JavaOp2 which is public domain @ www.javaop.com
Title: Re: A couple of questions (from a newb)
Post by: iago on March 24, 2005, 05:13 PM
www.javaop.com/javaop2/src if you want to browse the source
Title: Re: A couple of questions (from a newb)
Post by: MyndFyre on March 24, 2005, 06:09 PM
Also, snowstorm, it looks like you're expecting to see the entire packet that Ethereal captures, where in fact a lot of that implements the TCP/IP protocol stack.  In Ethereal, in the middle pane, click on the "Data" section to see what is actually the data your program will send/receive.  If there is no data section, then it's just there to maintain connection state.
Title: Re: A couple of questions (from a newb)
Post by: snowstorm on March 24, 2005, 07:03 PM
OH!!! Thats it lol I've been looking in the complete wrong place for the last hour.  I was wondering why nothing was matching up right.  Anyway do you think you could help me with this error when I connect?  It says the port is unreachable, any idea why that would be?  thanks

No.     Time        Source                Destination           Protocol Info
      1 0.000000    192.168.2.68          192.168.2.1           DNS      Standard query A uswest.battle.net

Frame 1 (77 bytes on wire, 77 bytes captured)
Ethernet II, Src: 00:50:da:1a:40:ad, Dst: 00:30:bd:c5:95:3e
Internet Protocol, Src Addr: 192.168.2.68 (192.168.2.68), Dst Addr: 192.168.2.1 (192.168.2.1)
User Datagram Protocol, Src Port: 1109 (1109), Dst Port: domain (53)
Domain Name System (query)

No.     Time        Source                Destination           Protocol Info
      2 0.058109    192.168.2.1           192.168.2.68          DNS      Standard query response A 63.241.83.112 A 63.241.83.111 A 63.241.83.7 A 63.241.83.110 A 63.241.83.109 A 63.241.83.108 A 63.241.83.12 A 63.241.83.107 A 63.241.83.11 A 63.241.83.9 A 63.241.83.13 A 63.241.83.8

Frame 2 (429 bytes on wire, 429 bytes captured)
Ethernet II, Src: 00:30:bd:c5:95:3e, Dst: 00:50:da:1a:40:ad
Internet Protocol, Src Addr: 192.168.2.1 (192.168.2.1), Dst Addr: 192.168.2.68 (192.168.2.68)
User Datagram Protocol, Src Port: domain (53), Dst Port: 1109 (1109)
Domain Name System (response)

No.     Time        Source                Destination           Protocol Info
      3 0.062293    192.168.2.1           192.168.2.68          DNS      Standard query response A 63.241.83.8 A 63.241.83.112 A 63.241.83.111 A 63.241.83.7 A 63.241.83.110 A 63.241.83.109 A 63.241.83.108 A 63.241.83.12 A 63.241.83.107 A 63.241.83.11 A 63.241.83.9 A 63.241.83.13

Frame 3 (429 bytes on wire, 429 bytes captured)
Ethernet II, Src: 00:30:bd:c5:95:3e, Dst: 00:50:da:1a:40:ad
Internet Protocol, Src Addr: 192.168.2.1 (192.168.2.1), Dst Addr: 192.168.2.68 (192.168.2.68)
User Datagram Protocol, Src Port: domain (53), Dst Port: 1109 (1109)
Domain Name System (response)

No.     Time        Source                Destination           Protocol Info
      4 0.062449    192.168.2.68          192.168.2.1           ICMP     Destination unreachable (Port unreachable)

Frame 4 (70 bytes on wire, 70 bytes captured)
Ethernet II, Src: 00:50:da:1a:40:ad, Dst: 00:30:bd:c5:95:3e
Internet Protocol, Src Addr: 192.168.2.68 (192.168.2.68), Dst Addr: 192.168.2.1 (192.168.2.1)
Internet Control Message Protocol

No.     Time        Source                Destination           Protocol Info
      5 0.133623    192.168.2.68          63.241.83.112         TCP      1110 > 6112 [SYN] Seq=0 Ack=0 Win=8192 Len=0 MSS=1460

Frame 5 (62 bytes on wire, 62 bytes captured)
Ethernet II, Src: 00:50:da:1a:40:ad, Dst: 00:30:bd:c5:95:3e
Internet Protocol, Src Addr: 192.168.2.68 (192.168.2.68), Dst Addr: 63.241.83.112 (63.241.83.112)
Transmission Control Protocol, Src Port: 1110 (1110), Dst Port: 6112 (6112), Seq: 0, Ack: 0, Len: 0

No.     Time        Source                Destination           Protocol Info
      6 0.184184    63.241.83.112         192.168.2.68          TCP      6112 > 1110 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460

Frame 6 (62 bytes on wire, 62 bytes captured)
Ethernet II, Src: 00:30:bd:c5:95:3e, Dst: 00:50:da:1a:40:ad
Internet Protocol, Src Addr: 63.241.83.112 (63.241.83.112), Dst Addr: 192.168.2.68 (192.168.2.68)
Transmission Control Protocol, Src Port: 6112 (6112), Dst Port: 1110 (1110), Seq: 0, Ack: 1, Len: 0

No.     Time        Source                Destination           Protocol Info
      7 0.184373    192.168.2.68          63.241.83.112         TCP      1110 > 6112 [ACK] Seq=1 Ack=1 Win=8760 Len=0

Frame 7 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:50:da:1a:40:ad, Dst: 00:30:bd:c5:95:3e
Internet Protocol, Src Addr: 192.168.2.68 (192.168.2.68), Dst Addr: 63.241.83.112 (63.241.83.112)
Transmission Control Protocol, Src Port: 1110 (1110), Dst Port: 6112 (6112), Seq: 1, Ack: 1, Len: 0

No.     Time        Source                Destination           Protocol Info
      8 0.247094    192.168.2.68          63.241.83.112         TCP      1110 > 6112 [RST] Seq=1 Ack=1 Win=0 Len=0

Frame 8 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:50:da:1a:40:ad, Dst: 00:30:bd:c5:95:3e
Internet Protocol, Src Addr: 192.168.2.68 (192.168.2.68), Dst Addr: 63.241.83.112 (63.241.83.112)
Transmission Control Protocol, Src Port: 1110 (1110), Dst Port: 6112 (6112), Seq: 1, Ack: 1, Len: 0
Title: Re: A couple of questions (from a newb)
Post by: Warrior on March 24, 2005, 07:07 PM
Ethereal confuses me, I use WPE :P