upasword: ajout des mot de passe javamonitor de webobjects
This commit is contained in:
parent
a75b91e2e9
commit
ba8e1a1dcc
87
upassword
87
upassword
|
@ -19,6 +19,7 @@ import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
|
@ -138,6 +139,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class Base64 {
|
public static class Base64 {
|
||||||
public final static int NO_OPTIONS = 0;
|
public final static int NO_OPTIONS = 0;
|
||||||
|
|
||||||
|
@ -966,6 +968,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class DES {
|
public static class DES {
|
||||||
private int[] encryptKeys = new int[32];
|
private int[] encryptKeys = new int[32];
|
||||||
|
|
||||||
|
@ -1870,6 +1873,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class MD4 extends MessageDigest implements Cloneable {
|
public static class MD4 extends MessageDigest implements Cloneable {
|
||||||
private static final int BLOCK_LENGTH = 64;
|
private static final int BLOCK_LENGTH = 64;
|
||||||
|
|
||||||
|
@ -2026,6 +2030,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class jcrypt {
|
public static class jcrypt {
|
||||||
private jcrypt() {
|
private jcrypt() {
|
||||||
}
|
}
|
||||||
|
@ -3655,6 +3660,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class Salt {
|
public static class Salt {
|
||||||
public static final String getCryptSalt(String pw) {
|
public static final String getCryptSalt(String pw) {
|
||||||
if (pw == null) return null;
|
if (pw == null) return null;
|
||||||
|
@ -3752,6 +3758,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class Password {
|
public static class Password {
|
||||||
public static final String CLEARTEXT = "", CRYPT = "CRYPT", MD5 = "MD5", SMD5 = "SMD5",
|
public static final String CLEARTEXT = "", CRYPT = "CRYPT", MD5 = "MD5", SMD5 = "SMD5",
|
||||||
SHA = "SHA", XSHA = "XSHA", SSHA = "SSHA";
|
SHA = "SHA", XSHA = "XSHA", SSHA = "SSHA";
|
||||||
|
@ -4186,6 +4193,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class PasswordChecker {
|
public static class PasswordChecker {
|
||||||
public PasswordChecker(int minLen, int minUpper, int minLower, int minAlpha, int minNumber,
|
public PasswordChecker(int minLen, int minUpper, int minLower, int minAlpha, int minNumber,
|
||||||
int minSymbol, int minSpecial, boolean allowMultibytes) {
|
int minSymbol, int minSpecial, boolean allowMultibytes) {
|
||||||
|
@ -4621,6 +4629,7 @@ public class upassword {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public static class AESEnc {
|
public static class AESEnc {
|
||||||
private static final String AES = "AES";
|
private static final String AES = "AES";
|
||||||
|
|
||||||
|
@ -4712,6 +4721,76 @@ public class upassword {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public static class WOJavaMonitorPassword {
|
||||||
|
public static long myrand() {
|
||||||
|
long nextLong = ThreadLocalRandom.current().nextLong();
|
||||||
|
while (nextLong == Long.MIN_VALUE) {
|
||||||
|
nextLong = ThreadLocalRandom.current().nextLong();
|
||||||
|
}
|
||||||
|
return Math.abs(nextLong);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String encryptStringWithKey(String to_be_encrypted, String aKey) {
|
||||||
|
String encrypted_value = "";
|
||||||
|
char xdigit[] = { '0' , '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
|
MessageDigest messageDigest;
|
||||||
|
|
||||||
|
try {
|
||||||
|
messageDigest = MessageDigest.getInstance("MD5");
|
||||||
|
} catch (NoSuchAlgorithmException exc) {
|
||||||
|
throw new AssertionError("MD5 n'est pas disponible: " + getSummary(exc));
|
||||||
|
}
|
||||||
|
if (to_be_encrypted != null) {
|
||||||
|
byte digest[];
|
||||||
|
byte fudge_constant[];
|
||||||
|
try {
|
||||||
|
fudge_constant = ("X#@!").getBytes("UTF8");
|
||||||
|
} catch (UnsupportedEncodingException uee) {
|
||||||
|
fudge_constant = ("X#@!").getBytes();
|
||||||
|
}
|
||||||
|
byte fudgetoo_part[] = {
|
||||||
|
(byte)xdigit[(int)(myrand() % 16)] ,
|
||||||
|
(byte)xdigit[(int)(myrand() % 16)] ,
|
||||||
|
(byte)xdigit[(int)(myrand() % 16)] ,
|
||||||
|
(byte)xdigit[(int)(myrand() % 16)]
|
||||||
|
};
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (aKey != null) {
|
||||||
|
try {
|
||||||
|
fudgetoo_part = aKey.getBytes("UTF8");
|
||||||
|
} catch (UnsupportedEncodingException uee) {
|
||||||
|
fudgetoo_part = aKey.getBytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageDigest.update(fudge_constant);
|
||||||
|
try {
|
||||||
|
messageDigest.update(to_be_encrypted.getBytes("UTF8"));
|
||||||
|
} catch (UnsupportedEncodingException uee) {
|
||||||
|
messageDigest.update(to_be_encrypted.getBytes());
|
||||||
|
}
|
||||||
|
messageDigest.update(fudgetoo_part);
|
||||||
|
digest = messageDigest.digest();
|
||||||
|
encrypted_value = new String(fudgetoo_part);
|
||||||
|
for (i = 0; i < digest.length; i++) {
|
||||||
|
int mashed;
|
||||||
|
char temp[] = new char[2];
|
||||||
|
if (digest[i] < 0) {
|
||||||
|
mashed = 127 + ( -1 * digest[i]);
|
||||||
|
} else {
|
||||||
|
mashed = digest[i];
|
||||||
|
}
|
||||||
|
temp[0] = xdigit[mashed / 16];
|
||||||
|
temp[1] = xdigit[mashed % 16];
|
||||||
|
encrypted_value = encrypted_value + (new String(temp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return encrypted_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
private Password getPasswordAnySalt(String clear, String scheme, final String anySalt) {
|
private Password getPasswordAnySalt(String clear, String scheme, final String anySalt) {
|
||||||
return new Password(clear, scheme) {
|
return new Password(clear, scheme) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -4958,13 +5037,13 @@ public class upassword {
|
||||||
}
|
}
|
||||||
i += shift;
|
i += shift;
|
||||||
codEtu = true;
|
codEtu = true;
|
||||||
} else if (arg.equals("-k") || args.equals("--clear-is-crypted")) {
|
} else if (arg.equals("-k") || arg.equals("--clear-is-crypted")) {
|
||||||
crypted = true;
|
crypted = true;
|
||||||
i++;
|
i++;
|
||||||
} else if (arg.equals("-m") || args.equals("--salt-check-match-hash")) {
|
} else if (arg.equals("-m") || arg.equals("--salt-check-match-hash")) {
|
||||||
hashAction = EHashAction.CHECK_MATCH;
|
hashAction = EHashAction.CHECK_MATCH;
|
||||||
i++;
|
i++;
|
||||||
} else if (arg.equals("-n") || args.equals("--salt-same-or-new-hash")) {
|
} else if (arg.equals("-n") || arg.equals("--salt-same-or-new-hash")) {
|
||||||
hashAction = EHashAction.SAME_OR_NEW;
|
hashAction = EHashAction.SAME_OR_NEW;
|
||||||
i++;
|
i++;
|
||||||
} else if (arg.equals("-G") || arg.equals("--aes-genkey")) {
|
} else if (arg.equals("-G") || arg.equals("--aes-genkey")) {
|
||||||
|
@ -5107,6 +5186,7 @@ public class upassword {
|
||||||
String md5 = getPasswordAnySalt(clear, Password.MD5, null).getNormalized();
|
String md5 = getPasswordAnySalt(clear, Password.MD5, null).getNormalized();
|
||||||
String smd5 = getPasswordBinarySalt(clear, Password.SMD5, newBinarySalt)
|
String smd5 = getPasswordBinarySalt(clear, Password.SMD5, newBinarySalt)
|
||||||
.getNormalized();
|
.getNormalized();
|
||||||
|
String wojmp = WOJavaMonitorPassword.encryptStringWithKey(clear, null);
|
||||||
String aes = null;
|
String aes = null;
|
||||||
if (aeskey != null) {
|
if (aeskey != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -5125,6 +5205,7 @@ public class upassword {
|
||||||
printvar("ssha", ssha, shell);
|
printvar("ssha", ssha, shell);
|
||||||
printvar("md5", md5, shell);
|
printvar("md5", md5, shell);
|
||||||
printvar("smd5", smd5, shell);
|
printvar("smd5", smd5, shell);
|
||||||
|
printvar("wojmp", wojmp, shell);
|
||||||
if (aes != null) printvar("aes", aes, shell);
|
if (aes != null) printvar("aes", aes, shell);
|
||||||
} else if (hashAction == EHashAction.CHECK_MATCH) {
|
} else if (hashAction == EHashAction.CHECK_MATCH) {
|
||||||
// Afficher uniquement les versions cryptées des mots de passe avec
|
// Afficher uniquement les versions cryptées des mots de passe avec
|
||||||
|
|
Loading…
Reference in New Issue