Valhalla Legends Forums Archive | Battle.net Bot Development | A couple of questions (from a newb)

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

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

March 24, 2005, 10:48 PM
Twix
try looking at [url]http://bnetdocs.valhallalegends.com/content.php[/url] 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.
March 24, 2005, 11:05 PM
Quarantine
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.
March 24, 2005, 11:09 PM
Quarantine
You need to decompress ingame packets
March 24, 2005, 11:09 PM
snowstorm
Yes, I have taken a look around bnetdocs.  I'll try to find iago's buffer, maybe that will help.  thanks
March 24, 2005, 11:11 PM
Quarantine
It's in JavaOp2 which is public domain @ www.javaop.com
March 24, 2005, 11:12 PM
iago
www.javaop.com/javaop2/src if you want to browse the source
March 24, 2005, 11:13 PM
Myndfyr
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.
March 25, 2005, 12:09 AM
snowstorm
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
[code]
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
[/code]
March 25, 2005, 1:03 AM
Quarantine
Ethereal confuses me, I use WPE :P
March 25, 2005, 1:07 AM

Search