public String generateType3Msg(final String username, final String password, final String domain, final String workstation, final String challenge) throws NtlmEngineException { final Type2Message t2m = new Type2Message(challenge); return getType3Message(username, password, workstation, domain, t2m.getChallenge(), t2m.getFlags(), t2m.getTarget(), t2m.getTargetInfo()); }
/** Get NTLMUserSessionKey */ public byte[] getNTLMUserSessionKey() throws NtlmEngineException { if (ntlmUserSessionKey == null) { final MD4 md4 = new MD4(); md4.update(getNTLMHash()); ntlmUserSessionKey = md4.getOutput(); } return ntlmUserSessionKey; }
/** Calculate the NTLMv2Blob */ public byte[] getNTLMv2Blob() throws NtlmEngineException { if (ntlmv2Blob == null) { ntlmv2Blob = createBlob(getClientChallenge2(), targetInformation, getTimestamp()); } return ntlmv2Blob; }
private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NtlmEngineException { final int length = readUShort(src, index); final int offset = readULong(src, index + 4); if (src.length < offset + length) { throw new NtlmEngineException("NTLM authentication - buffer too small for data item"); } final byte[] buffer = new byte[length]; System.arraycopy(src, offset, buffer, 0, length); return buffer; }
/** Get NTLM2SessionResponse */ public byte[] getNTLM2SessionResponse() throws NtlmEngineException { if (ntlm2SessionResponse == null) { ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(), challenge, getClientChallenge()); } return ntlm2SessionResponse; }
/** Calculate the NTLMv2Response */ public byte[] getNTLMv2Response() throws NtlmEngineException { if (ntlmv2Response == null) { ntlmv2Response = lmv2Response(getNTLMv2Hash(), challenge, getNTLMv2Blob()); } return ntlmv2Response; }
/** Calculate the LMv2Response */ public byte[] getLMv2Response() throws NtlmEngineException { if (lmv2Response == null) { lmv2Response = lmv2Response(getLMv2Hash(), challenge, getClientChallenge()); } return lmv2Response; }
/** * Prepares the object to create a response of the given length. * * @param maxlength * the maximum length of the response to prepare, not * including the type and the signature (which this method * adds). */ protected void prepareResponse(final int maxlength, final int messageType) { messageContents = new byte[maxlength]; currentOutputPosition = 0; addBytes(SIGNATURE); addULong(messageType); }
private static int readUShort(final byte[] src, final int index) throws NtlmEngineException { if (src.length < index + 2) { throw new NtlmEngineException("NTLM authentication - buffer too small for WORD"); } return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8); }
/** Calculate and return the NTLMResponse */ public byte[] getNTLMResponse() throws NtlmEngineException { if (ntlmResponse == null) { ntlmResponse = lmResponse(getNTLMHash(), challenge); } return ntlmResponse; }
/** Calculate and return the LMResponse */ public byte[] getLMResponse() throws NtlmEngineException { if (lmResponse == null) { lmResponse = lmResponse(getLMHash(), challenge); } return lmResponse; }
/** Read a ulong from a position within the message buffer */ protected final int readULong(final int position) throws NtlmEngineException { return NtlmEngine.readULong(messageContents, position); }
@Override public AbstractHandler configureHandler() throws Exception { return new NTLMHandler(); }
private static int readULong(final byte[] src, final int index) throws NtlmEngineException { if (src.length < index + 4) { throw new NtlmEngineException("NTLM authentication - buffer too small for DWORD"); } return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8) | ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24); }
/** Calculate the LMv2 hash */ public byte[] getLMv2Hash() throws NtlmEngineException { if (lmv2Hash == null) { lmv2Hash = lmv2Hash(domain, user, getNTLMHash()); } return lmv2Hash; }
/** Read a byte from a position within the message buffer */ protected byte readByte(final int position) throws NtlmEngineException { if (messageContents.length < position + 1) { throw new NtlmEngineException("NTLM: Message too short"); } return messageContents[position]; }
/** Calculate the NTLMv2 hash */ public byte[] getNTLMv2Hash() throws NtlmEngineException { if (ntlmv2Hash == null) { ntlmv2Hash = ntlmv2Hash(domain, user, getNTLMHash()); } return ntlmv2Hash; }