Exemplo n.º 1
0
  /**
   * gets the decrypted password
   *
   * @return the decrypted password hash
   */
  public byte[] getDecryptedPasswordHash() {
    byte[] b1 = key.decodeByteArray(password);
    byte[] b2 = Hash.xor(clientNonce, serverNonce);
    if (b2 == null) {
      logger.debug("B2 is null");
      return null;
    }

    byte[] passwordHash = Hash.xor(b1, b2);
    if (password == null) {
      logger.debug("Password is null");
      return null;
    }
    return passwordHash;
  }
Exemplo n.º 2
0
  /** sends id, version and distribution */
  public static void send() {
    String clientid = readID();
    if (clientid == null) {
      clientid = generateRandomString();
      saveID(clientid);
    }

    final RPAction action = new RPAction();

    // compatibility with old servers
    if (RPClass.getRPClass("cstatus") != null) {
      action.put("type", "cstatus");
    } else {
      action.put("type", "cid");
    }

    // a client id to help with the investigation of hacked accounts
    // especially in the common "angry sibling" case.
    if (clientid != null) {
      action.put("cid", clientid);
    }

    // the client version, the server will deactivate certain features that
    // are incompatible with old clients. E. g. changing of light and dark
    // in the current zone is implemented by retransmitting the tileset
    // information. an old client would mistake that for a zone change and
    // hang.
    String version = Debug.VERSION;
    if (Debug.PRE_RELEASE_VERSION != null) {
      version = version + " - " + Debug.PRE_RELEASE_VERSION;
    }
    action.put("version", version);

    // extract the signer of the client, so that we can ask bug
    // reporters to try again with the official client, if they
    // are using an unofficial one.
    try {
      Class<?> clazz = Class.forName("games.stendhal.client.update.Starter");
      if (clazz != null) {
        Object[] objects = clazz.getSigners();
        if (objects instanceof Certificate[]) {
          Certificate[] certs = (Certificate[]) objects;
          if ((certs.length > 0)) {
            byte[] key = certs[0].getPublicKey().getEncoded();
            action.put("dist", Hash.toHexString(Hash.hash(key)));
          }
        }
      }

      // Throwable: both errors and exceptions
    } catch (Throwable e) {
      logger.error(e, e);
    }

    // Get build number. The class is not in CVS to prevent lots of unwanted
    // conflicts. This has, however, the side effect, that it is missing in
    // an IDE (e. g. Eclipes) environment.
    // The build number is especially helpful for pre releases
    try {
      Class<?> clazz = Class.forName("games.stendhal.client.StendhalBuild");
      Object buildNumber = clazz.getMethod("getBuildNumber").invoke(null);
      if (buildNumber != null) {
        action.put("build", buildNumber.toString());
      }
    } catch (Throwable e) {
      logger.debug(e, e);
    }

    ClientSingletonRepository.getClientFramework().send(action);
  }