• 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 - mirza911

#1
Battle.net Bot Development / Re: Bot basics (Java)
December 21, 2009, 11:52 AM
lol ive used forums but this is just escaping my mind.
With while running would that be the same thing? setting it to false when they type in "BYE". so it would have the same functionality?
With the BYE you want me to send it to the client and then exit?
#2
Battle.net Bot Development / Re: Bot basics (Java)
December 21, 2009, 02:16 AM
Still am not sure how to use the code tag.

but here is my server

import java.io.*;
import java.net.*;

public class EchoServer
{
    public static void main(String[] args)
    {
        try
        {
            ServerSocket srvrSocket = new ServerSocket(4004);
            while (true)
            {
                Socket incoming = srvrSocket.accept();
                // buffer
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        incoming.getInputStream()));
                // writer
                PrintWriter out = new PrintWriter(new OutputStreamWriter(
                        incoming.getOutputStream()));

                while (true)
                {
                    // read it in
                    String str = in.readLine();
                    if (str == null)
                    {
                        break; // client closed connection
                    }
                    else
                    {
                        // print echo back
                        out.println("Echo: " + str);
                        out.flush();
                        if (str.trim().equals("BYE"))
                            break;
                    }
                }
                incoming.close();
            }
        } catch (Exception e)
        {
            System.out.println("Exception... exiting!");
            System.err.println(e);
            return;
        }
    }
}


and here is my client



import java.net.*;
import java.io.*;

public class EchoClient
{

    public static void main(String[] args)
    {

        String hostname = "localhost";

        if (args.length > 0)
        {
            hostname = args[0];
        }

        PrintWriter out = null;
        BufferedReader networkIn = null;
        try
        {
            Socket clientSocket = new Socket(hostname, 4004);
            networkIn = new BufferedReader(new InputStreamReader(clientSocket
                    .getInputStream()));
            BufferedReader userIn = new BufferedReader(new InputStreamReader(
                    System.in));
            out = new PrintWriter(clientSocket.getOutputStream());
            System.out.println("Connected to echo server");
            System.out.println("Started - Type something to send");
            System.out.println("Enter BYE to exit.");

            while (true)
            {
                String theLine = userIn.readLine();
                if (theLine.equals("BYE"))
                {
                    System.out.println("Exiting");
                    break;
                }
                out.println(theLine);
                out.flush();
                System.out.println(networkIn.readLine());
            }

        } // end try
        catch (IOException e)
        {
            System.out.println("IOException... exiting!");
            System.err.println(e);
            return;
        } finally
        {
            try
            {
                if (networkIn != null)
                    networkIn.close();
                if (out != null)
                    out.close();
            } catch (IOException e)
            {
                System.out.println("IOException... exiting!");
                System.err.println(e);
                return;
            }
        }
    }
}

The variables i know about. i was just kind of rushing through it =P.
what should i use instead of while(true)?
.trim to get rid of whitespaces? and .equals to check if i want to quit or not
Still no sure about the exception more advice on that would be great. how exactly i should handle them.

the return is just for me. sometimes my java programs will stick around if i dont return at the end and i will have to go into the task manager and get rid of them.


I know im still using buffers and pw's but im just taking babysteps. let me know what u think of this now and ill get started on reading the stuff without them. any tips greatly appreciated =)
#3
Battle.net Bot Development / Re: Bot basics (Java)
December 21, 2009, 12:35 AM
This is what i got so far

import java.io.*;
import java.net.*;

public class EchoServer
{
    public static void main(String[] args)
    {
        try
        {
            ServerSocket s = new ServerSocket(6112);
            while (true)
            {
                Socket incoming = s.accept();
                // buffer
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        incoming.getInputStream()));
                // writer
                PrintWriter out = new PrintWriter(new OutputStreamWriter(
                        incoming.getOutputStream()));

                out.println("Started - Type something to send");
                out.println("Enter \"E\" to exit.");
                out.flush();
                while (true)
                {
                    // read it in
                    String str = in.readLine();
                    if (str == null)
                    {
                        break; // client closed connection
                    }
                    else
                    {
                        // print echo back
                        out.println("Echo: " + str);
                        out.flush();
                        if (str.trim().equals("E"))
                            break;
                    }
                }
                incoming.close();
            }
        } catch (Exception e)
        {
            // handle some exceptions not sure how yet
        }
        return;
    }
}

Also i would like to know how to do that thing where u show the code in green text on posts =)
#4
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 11:09 PM
alright i got an echo server working. and its sending back whatever i send it. so thats why i assume its working...  :) . how can i "learn" to use them?
#5
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 10:41 PM
right that makes sense.  but in little endian would that be 03 02 01 00 or 00 03 02 01?
#6
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 09:30 PM
would the hex not just be 01 02 03 ? since that would be big-endian. And i am not sure that would just be my guess from what i've read up on it from the newcomers sticky.

I really appreciate you posting though and explaining what you have to me.
#7
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 08:24 PM
do you mean just for me because i am so inexperienced? or for anyone?
Why exactly is it so impossible?
#8
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 08:19 PM
well the main goal would be something like a gambling bot or mf bot but right now i want to start small to get the feel for it. something like a log in bot.
#9
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 08:06 PM
i want to make a bot.
#10
Battle.net Bot Development / Re: Bot basics (Java)
December 20, 2009, 07:02 PM
i tried getting javaop but all the links on the javaop homepage dont work. with mozilla or IE.

i thought jpcap would be more useful though why should i just use java sockets?

Also the whole bot thing. Will diablo know how to act based on the packets i send or do i need to send packets and still click on things and type things etc etc.?
#11
Battle.net Bot Development / Bot basics (Java)
December 20, 2009, 06:26 PM
I am very new to bot making but i am pretty comfortable with java and i want to try to write a simple bot in java just to get the feel for it. I have been using bnetdocs, wireshark, and d2 smells to see the communication between battle.net and my computer. but the basics of a bot are still very hard for me to grasp.

-I need some advice on how to take the data from the bnet and read it.
-I need advice on how to send the proper packet back.
-With a packet there is so much to look at. I don't know which part is the most important to me and what i need to modify and send back.

This is the code i found online and added a couple things to it. I just want to try to send the first packet successfully.

import java.net.InetAddress;

import jpcap.*;
import jpcap.packet.EthernetPacket;
import jpcap.packet.IPPacket;
import jpcap.packet.Packet;
import jpcap.packet.TCPPacket;

class SendTCP
{
    public static void main(String[] args) throws java.io.IOException
    {
        NetworkInterface[] devices = JpcapCaptor.getDeviceList();
        if (args.length < 1)
        {
            System.out
                    .println("Usage: java SentTCP <device index (e.g., 0, 1..)>");
            for (int i = 0; i < devices.length; i++)
                System.out.println(i + ":" + devices.name + "("
                        + devices.description + ")");
            // System.exit(0);
        }
        int index = Integer.parseInt(args[0]);
        JpcapSender sender = JpcapSender.openDevice(devices[index]);

        TCPPacket p = new TCPPacket(50371, 6112, 1, 1, false, true, true,
                false, false, false, false, false, 16896, 00);
        p.setIPv4Parameter(0, false, false, false, 0, false, false, false, 0,
                1010101, 128, IPPacket.IPPROTO_TCP, InetAddress.getLocalHost(),
                InetAddress.getByName("useast.battle.net"));
        byte[] by = new byte[]
        { (byte) Integer.parseInt("01", 16) };
        p.data = by;

        EthernetPacket ether = new EthernetPacket();
        ether.frametype = EthernetPacket.ETHERTYPE_IP;
        ether.src_mac = new byte[]
        { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
        ether.dst_mac = new byte[]
        { (byte) 0, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10 };
        p.datalink = ether;

        for (int i = 0; i < 1; i++)
            sender.sendPacket(p);
        sender.close();
        System.out.println("done");
        return;
    }
}

I would be happy with just a logon bot.
Any help will be appreciated.