-1

I am using a login method that checks passwords and usernames in a phpbb installation.

i need to make this work to decrypt the phpbb encryption.

i am getting this error:

    vBulletin.java:139: error: non-static method phpbb_hash(String) cannot be referenced from a static context
                    pass2 = PHPBB3Password.phpbb_hash(password);
                                          ^
1 error

This is my code:

returnCodes[1] = group;
String pass2 = "";
if (forum == Type.myBB) {
    pass2 = MD5.MD5(MD5.MD5(salt) + MD5.MD5(password));
} else if (forum == Type.vBulletin) {
    pass2 = MD5.MD5(password);
    pass2 = MD5.MD5(pass2 + salt);
} else if (forum == Type.SMF) {
    pass2 = MD5.SHA((name.toLowerCase()) + password);
} else if (forum == Type.phpBB) {
    pass2 = PHPBB3Password.phpbb_hash(password);
} else if (forum == Type.IPB) {
    pass2 = MD5.MD5(MD5.MD5(salt) + MD5.MD5(password));
}

it is the PhpBB i am using:

public String phpbb_hash(String password) {
      String random_state = unique_id();
      String random = "";
      int count = 6;

      if (random.length() < count) {
         random = "";

         for (int i = 0; i < count; i += 16) {
            random_state = md5(unique_id() + random_state);
            random += pack(md5(random_state));
         }
         random = random.substring(0, count);
      }

      String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
      if (hash.length() == 34)
         return hash;

      return md5(password);
   }

And the old md5 decrypter which worked but wasnt up to date:

    public static String MD5(String text)
        throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest md;
    md = MessageDigest.getInstance("MD5");
    byte[] md5hash = new byte[32];
    md.update(text.getBytes("iso-8859-1"), 0, text.length());
    md5hash = md.digest();
    return convertToHex(md5hash);
}

UPDATE: followed what some kind commenters had to say :D

    PHPBB3Password.java:18: error: non-static method unique_id() cannot be referenced from a static context
      String random_state = unique_id();
                            ^
PHPBB3Password.java:26: error: non-static method unique_id() cannot be referenced from a static context
            random_state = md5(unique_id() + random_state);
                               ^
PHPBB3Password.java:32: error: non-static variable itoa64 cannot be referenced from a static context
      String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                                                                                ^
PHPBB3Password.java:32: error: non-static method _hash_gensalt_private(String,String) cannot be referenced from a static context
      String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                                                  ^
PHPBB3Password.java:32: error: non-static method _hash_crypt_private(String,String) cannot be referenced from a static context
      String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                    ^
5 errors
user2175693
  • 23
  • 1
  • 5
  • In order to expect useful answers, it is appreciated to actually ask a question. It also helps a lot for all the volenters reading your question post if you format your code well. Otherwise people will vote down your question and walk away. So go on an make your question useful for readers, so they able to help you. – Uwe Günther Mar 15 '13 at 22:26
  • I don't see a definition for those functions, where do they come from? (You need another reference to an object with those methods probably). – Motomotes Mar 15 '13 at 22:44

1 Answers1

0

if phpbb_hash uses some class attributes, then you need an instance of PHPBB3Password to access it. So you would do something like :

pass2 = new PHPBB3Password().phpbb_hash(password);

if phpbb_hash does not use some class attribute, then this method should be declared static like this:

public static String phpbb_hash(String password) {
...
}
user2147970
  • 412
  • 2
  • 7