• Welcome to Valhalla Legends Archive.
 

Java Code for Bot

Started by snowstorm, April 14, 2005, 09:02 PM

Previous topic - Next topic

snowstorm

Can someone help me out? 
I have no idea why this won't work.  I am just connecting to bnet sending the protocol byte and then packet 0x50, but it only sends the first byte and after that it says [TCP Window Full] and the connection terminates:

byte[] b = new byte[] {0x01};

byte[] t = {(byte)0xff, 0x50, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x38, 
0x58, 0x49, 0x50, 0x58, 0x32, 0x44, 0x0a, 0x00, 0x00, 0x00, 0x53, 0x55, 0x6e, 0x65, (byte)0xC0, (byte)0xA8, 
0x02, 0x44,(byte)0xA4, 0x01, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x55, 0x53, 
0x41, 0x00, 0x55, 0x6e, 0x69, 0x74, 0x65, 0x64, 0x20, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x00};

out.write(b, 0, b.length);
out.flush();
out.write(t, 0, t.length);
out.flush();


These are the packets as captured directly from running d2.

Thanks for any help!

iago

That looks fine; not good, but fine :P

Post the code where you open the connection, please.

(http://www.javaop.com/javaop2/src if you wanna see a sample of Java bot code, BNetLogin looks after building the 0x50 packet)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


snowstorm


// Input and output streams for TCP socket
protected DataInputStream in;
protected DataOutputStream out;

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

Thanks for the help

iago

Hmm, I've never tried using a DataInputStream/OutputStream.  Try using a standard OutputStream (not buffered, not data) since that can be sent an array of bytes.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*