Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Bot Minecraft

    Non so se tutti conoscono il famoso gioco di Notch, ma in breve posso dirvi che è un fps sandbox in prima persona.
    Screenshot:


    Ed è proprio per questo gioco (ovviamente in multiplayer) che voglio creare un bot, che per il momento ha unico scopo di loggarsi con successo.
    Ovviamente ho un server craccato su cui faccio test, ma non riesco ancora a loggarmi. questo perché la documentazione del protocollo usato da MC è poca e quella che c'è spiega come loggarsi in server classici, cioè con account premium, mentre per i server cosiddetti "craccati", in cui chiunque può entrare, non si dice niente.

    Il server craccato è un classico bukkit, non illegale.

    Per il momento sono solo riuscito a far "stampare" a schermo le info del server.

    Questo è ciò che ho fatto fin'ora, sfruttando le librerie Connections che scrissi un po' di tempo' fa, ma comunque credo che il codice sia capibile:
    codice:
    import TCP.Client;
    import java.util.Arrays;
    
    public class bot {
      
      private static Client client;
    
      // create the TCP socket with the library
      private static void create_socket(String host, int port) {
        client = new Client();
        client.setHost(host);
        client.setPort(port);
        client.start();
      }
    
      // keep alive
      private static void keep_alive() {
        byte bs[] = new byte[1];
        bs[0]=0;
        client.sendBytes(bs);
        client.sendBytes(bs);
      }
    
      private static void handshake() {
         byte bs[] = new byte[41];
         bs[0]=2;
         bs[1]=28;
         client.sendBytes(bs);
         client.send("nomeutente");
         client.send("localhost");
         client.sendInt(25565);
      }
    
      private static String ar2str(byte[] ar) {
        StringBuffer result = new StringBuffer();
        for(int i=0; i<ar.length; i++) {
          result.append((char)ar[i]);
        }
        return result.toString();
      }
    
      private static void info() {
        client.sendInt(0xFE);
        byte[] b = client.receiveBytes();
        if(b[0]!=-1) {System.err.println("ERRORE del SERVER");}
        b[0]=0;
        String s1 = ar2str(b);
        byte[] b1 = null;
        try {
          b1 = s1.getBytes("US-ASCII");
        } catch(Exception ex) {
          ex.printStackTrace();
        }
        String s = ar2str(b1);
        String[] s_ar = s.split("\\?");
        String nome = s_ar[0].substring(4);
        String players = s_ar[1];
        String stacks = s_ar[2];
    
        System.out.println(nome+" "+players+"/"+stacks);
      }
    
      // main
      public static void main(String[] args) {
        String c = "";
        create_socket("localhost", 25565);
        info();
        handshake();
        while(c!=null) {
    	System.out.println(c=client.receive());
        }
      }
    }
    Link alla libreria Connections TCP: http://code.google.com/p/easy-tcp-connections-library/

    Link alle specifiche sul protocollo:http://wiki.vg/Protocol

    Il problema sta nel fatto che quando invio la richiesta di info (0xfe) tutto va liscio, ma non quando invio la richiesta di handshake, che il server non capisce e causa un RST. (reset connection).
    Consigli?

  2. #2
    Codice aggiornato:


    codice:
    import TCP.Client;
    import java.util.Arrays;
    
    public class bot {
      
      private static Client client;
    
      // create the TCP socket with the library
      private static void create_socket(String host, int port) {
        client = new Client();
        client.setHost(host);
        client.setPort(port);
        client.start();
      }
    
      // keep alive
      private static void keep_alive() {
        byte bs[] = new byte[1];
        bs[0]=0;
        client.sendBytes(bs);
        client.sendBytes(bs);
      }
    
      private static void handshake() {
         client.createPacket(59);
         client.addPacket((byte)2);
         client.addPacket(28); // 28 for 1.2.5; 39 for 1.3.1
         try {
           client.addPacket(("shadowyviper;127.0.0.1:25565").getBytes("UTF-16BE"));
         } catch(Exception ex) {
           ex.printStackTrace();
         }
         
         client.sendPacket();
         //client.send("localhost");
         //client.sendInt(25565);
      }
    
      private static String ar2str(byte[] ar) {
        StringBuffer result = new StringBuffer();
        for(int i=0; i<ar.length; i++) {
          result.append((char)ar[i]);
        }
        return result.toString();
      }
    
      private static void info() {
        client.sendInt(0xFE);
        byte[] b = client.receiveBytes();
        if(b[0]!=-1) {System.err.println("ERRORE del SERVER");}
        b[0]=0;
        String s1 = ar2str(b);
        byte[] b1 = null;
        try {
          b1 = s1.getBytes("US-ASCII");
        } catch(Exception ex) {
          ex.printStackTrace();
        }
        String s = ar2str(b1);
        String[] s_ar = s.split("\\?");
        String nome = s_ar[0].substring(4);
        String players = s_ar[1];
        String stacks = s_ar[2];
    
        System.out.println(nome+" "+players+"/"+stacks);
      }
    
      // main
      public static void main(String[] args) {
        String c = "";
        create_socket("localhost", 25565);
        info();
        handshake();
        while(c!=null) {
    	System.out.println(c=client.receive());
        }
      }
    }
    Ma non funziona ancora.... ho controllato con wireshark e il pacchetto che manda il client legittimo contiene esattamente gli stessi dati.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.