/** * * @param domain * @param username * @param password * * @return the caclulated mac */ public static byte[] nTOWFv2 ( String domain, String username, String password ) { MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(password)); MessageDigest hmac = Crypto.getHMACT64(md4.digest()); hmac.update(Strings.getUNIBytes(username.toUpperCase())); hmac.update(Strings.getUNIBytes(domain)); return hmac.digest(); }
/** * * @param password * @return the calculated hash */ public static byte[] nTOWFv1 ( String password ) { if ( password == null ) throw new NullPointerException("Password parameter is required"); MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(password)); return md4.digest(); }
/** * * @param password * @return the calculated hash */ public static byte[] nTOWFv1 ( String password ) { if ( password == null ) throw new NullPointerException("Password parameter is required"); MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(password)); return md4.digest(); }
/** * * @param domain * @param username * @param password * * @return the caclulated mac */ public static byte[] nTOWFv2 ( String domain, String username, String password ) { MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(password)); MessageDigest hmac = Crypto.getHMACT64(md4.digest()); hmac.update(Strings.getUNIBytes(username.toUpperCase())); hmac.update(Strings.getUNIBytes(domain)); return hmac.digest(); }
/** * Generate the Unicode MD4 hash for the password associated with these credentials. * * @param password * @param challenge * @return the calculated response * @throws GeneralSecurityException */ static public byte[] getNTLMResponse ( String password, byte[] challenge ) throws GeneralSecurityException { byte[] p21 = new byte[21]; byte[] p24 = new byte[24]; byte[] uni = Strings.getUNIBytes(password); MessageDigest md4 = Crypto.getMD4(); md4.update(uni); md4.digest(p21, 0, 16); NtlmUtil.E(p21, challenge, p24); return p24; }
protected int writeString ( String str, byte[] dst, int dstIndex, boolean unicode ) { int start = dstIndex; if ( unicode ) { // Unicode requires word alignment if ( ( ( dstIndex - this.headerStart ) % 2 ) != 0 ) { dst[ dstIndex++ ] = (byte) '\0'; } System.arraycopy(Strings.getUNIBytes(str), 0, dst, dstIndex, str.length() * 2); dstIndex += str.length() * 2; dst[ dstIndex++ ] = (byte) '\0'; dst[ dstIndex++ ] = (byte) '\0'; } else { byte[] b = Strings.getOEMBytes(str, this.getConfig()); System.arraycopy(b, 0, dst, dstIndex, b.length); dstIndex += b.length; dst[ dstIndex++ ] = (byte) '\0'; } return dstIndex - start; }
md4.update(Strings.getUNIBytes(password)); MessageDigest hmac = Crypto.getHMACT64(md4.digest()); hmac.update(Strings.getUNIBytes(user.toUpperCase())); hmac.update(Strings.getUNIBytes(domain.toUpperCase())); hmac = Crypto.getHMACT64(hmac.digest()); hmac.update(challenge);
protected int writeString ( String str, byte[] dst, int dstIndex, boolean unicode ) { int start = dstIndex; if ( unicode ) { // Unicode requires word alignment if ( ( ( dstIndex - this.headerStart ) % 2 ) != 0 ) { dst[ dstIndex++ ] = (byte) '\0'; } System.arraycopy(Strings.getUNIBytes(str), 0, dst, dstIndex, str.length() * 2); dstIndex += str.length() * 2; dst[ dstIndex++ ] = (byte) '\0'; dst[ dstIndex++ ] = (byte) '\0'; } else { byte[] b = Strings.getOEMBytes(str, this.getConfig()); System.arraycopy(b, 0, dst, dstIndex, b.length); dstIndex += b.length; dst[ dstIndex++ ] = (byte) '\0'; } return dstIndex - start; }
md4.update(Strings.getUNIBytes(password)); MessageDigest hmac = Crypto.getHMACT64(md4.digest()); hmac.update(Strings.getUNIBytes(user.toUpperCase())); hmac.update(Strings.getUNIBytes(domain.toUpperCase())); hmac = Crypto.getHMACT64(hmac.digest()); hmac.update(challenge);
/** * Generate the Unicode MD4 hash for the password associated with these credentials. * * @param password * @param challenge * @return the calculated response * @throws GeneralSecurityException */ static public byte[] getNTLMResponse ( String password, byte[] challenge ) throws GeneralSecurityException { byte[] p21 = new byte[21]; byte[] p24 = new byte[24]; byte[] uni = Strings.getUNIBytes(password); MessageDigest md4 = Crypto.getMD4(); md4.update(uni); md4.digest(p21, 0, 16); NtlmUtil.E(p21, challenge, p24); return p24; }
try { MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(this.password)); switch ( tc.getConfig().getLanManCompatibility() ) { case 0: hmac.update(Strings.getUNIBytes(this.username.toUpperCase())); hmac.update(Strings.getUNIBytes(this.domain.toUpperCase())); byte[] ntlmv2Hash = hmac.digest(); hmac = Crypto.getHMACT64(ntlmv2Hash);
try { MessageDigest md4 = Crypto.getMD4(); md4.update(Strings.getUNIBytes(this.password)); switch ( tc.getConfig().getLanManCompatibility() ) { case 0: hmac.update(Strings.getUNIBytes(this.username.toUpperCase())); hmac.update(Strings.getUNIBytes(this.domain.toUpperCase())); byte[] ntlmv2Hash = hmac.digest(); hmac = Crypto.getHMACT64(ntlmv2Hash);
public void enc_ndr_string ( String s ) { align(4); int i = this.index; int len = s.length(); Encdec.enc_uint32le(len + 1, this.buf, i); i += 4; Encdec.enc_uint32le(0, this.buf, i); i += 4; Encdec.enc_uint32le(len + 1, this.buf, i); i += 4; System.arraycopy(Strings.getUNIBytes(s), 0, this.buf, i, len * 2); i += len * 2; this.buf[ i++ ] = (byte) '\0'; this.buf[ i++ ] = (byte) '\0'; advance(i - this.index); }
public void enc_ndr_string ( String s ) { align(4); int i = this.index; int len = s.length(); Encdec.enc_uint32le(len + 1, this.buf, i); i += 4; Encdec.enc_uint32le(0, this.buf, i); i += 4; Encdec.enc_uint32le(len + 1, this.buf, i); i += 4; System.arraycopy(Strings.getUNIBytes(s), 0, this.buf, i, len * 2); i += len * 2; this.buf[ i++ ] = (byte) '\0'; this.buf[ i++ ] = (byte) '\0'; advance(i - this.index); }