我正在使用一种登录方法来检查 phpbb 安装中的密码和用户名。
我需要做这项工作来解密 phpbb 加密。
我收到此错误:
vBulletin.java:139: error: non-static method phpbb_hash(String) cannot be referenced from a static context
pass2 = PHPBB3Password.phpbb_hash(password);
^
1 error
这是我的代码:
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));
}
这是我正在使用的 PhpBB:
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);
}
旧的 md5 解密器可以工作但不是最新的:
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);
}
更新:遵循一些评论者不得不说的话: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