String user = "your_user_name"; String pass ="your_pass_word"; String sharedFolder="shared"; String path="smb://ip_address/"+sharedFolder+"/test.txt"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass); SmbFile smbFile = new SmbFile(path,auth); SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile); smbfos.write("testing....and writing to a file".getBytes()); System.out.println("completed ...nice !");
defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); ssn.setAttribute( "ntlmdomain", ntlm.getDomain() ); ssn.setAttribute( "ntlmuser", ntlm.getUsername() ); } else { HttpSession ssn = request.getSession(false);
defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); dc = UniAddress.getByName( domainController, true ); log.println( "NtlmHttpFilter: " + ntlm.getName() + ": 0x" + jcifs.util.Hexdump.toHexString( sae.getNtStatus(), 8 ) + ": " + sae );
byte[] ntResponse; try { ntResponse = Responses.getNTLM2SessionResponse(credentials.getPassword(), challenge, clientNonce); } catch (Exception e) credentials.getDomain(), credentials.getUsername(), Type3Message.getDefaultWorkstation()); NTLMKeyFactory ntlmKeyFactory = new NTLMKeyFactory(); byte[] sessionResponseUserSessionKey; try { sessionResponseUserSessionKey = ntlmKeyFactory.getNTLM2SessionResponseUserSessionKey(credentials.getPassword(), servernonce); byte[] lmResponse = NtlmPasswordAuthentication.getPreNTLMResponse( credentials.getPassword(), challenge); byte[] ntResponse = NtlmPasswordAuthentication.getNTLMResponse( credentials.getPassword(), challenge); type3 = new Type3Message(flags, lmResponse, ntResponse, credentials.getDomain(), credentials.getUsername(), Type3Message.getDefaultWorkstation()); if ((flags & NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH) != 0) {
String domain = ( index != -1 ) ? user.substring(0, index) : this.defaultDomain; user = ( index != -1 ) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(getTransportContext(), domain, user, password); ssn.setAttribute("ntlmdomain", ntlm.getUserDomain()); ssn.setAttribute("ntlmuser", ntlm.getUsername());
public byte[] initSecContext(byte[] token, int offset, int len) throws SmbException { switch (state) { case 1: Type1Message msg1 = new Type1Message(ntlmsspFlags, auth.getDomain(), workstation); token = msg1.toByteArray(); auth.getPassword(), auth.getDomain(), auth.getUsername(), workstation, ntlmsspFlags);
@Override public NtlmPasswordAuthentication clone () { NtlmPasswordAuthentication cloned = new NtlmPasswordAuthentication(); cloneInternal(cloned, this); return cloned; }
/** * Computes the 24 byte ANSI password hash given the 8 byte server challenge. */ public byte[] getAnsiHash( byte[] challenge ) { if( hashesExternal ) { return ansiHash; } switch (LM_COMPATIBILITY) { case 0: case 1: return getPreNTLMResponse( password, challenge ); case 2: return getNTLMResponse( password, challenge ); case 3: case 4: case 5: if( clientChallenge == null ) { clientChallenge = new byte[8]; RANDOM.nextBytes( clientChallenge ); } return getLMv2Response(domain, username, password, challenge, clientChallenge); default: return getPreNTLMResponse( password, challenge ); } } /**
String domain = npa.getUserDomain(); String user = !npa.isAnonymous() ? npa.getUsername() : null; String password = npa.getPassword(); String userInfo = this.url.getUserInfo(); if ( userInfo != null ) {
capabilities &= ~SmbConstants.CAP_EXTENDED_SECURITY; } else if (session.transport.server.encryptedPasswords) { lmHash = auth.getAnsiHash( session.transport.server.encryptionKey ); ntHash = auth.getUnicodeHash( session.transport.server.encryptionKey ); } else if( useUnicode ) { String password = auth.getPassword(); lmHash = new byte[0]; ntHash = new byte[(password.length() + 1) * 2]; } else { String password = auth.getPassword(); lmHash = new byte[(password.length() + 1) * 2]; ntHash = new byte[0];
log.debug("NtlmHttpFilter: " + ntlm.getName() + ": 0x" + Hexdump.toHexString(sae.getNtStatus(), 8) + ": ", sae); log.error("", e); return new AuthenticatorToken(ntlm.getUsername());
/** * Return the domain and username in the format: * <tt>domain\\username</tt>. This is equivalent to <tt>getName()</tt>. */ public String toString() { return getName(); }
/** * Computes the 24 byte Unicode password hash given the 8 byte server challenge. */ public byte[] getUnicodeHash( byte[] challenge ) { if( hashesExternal ) { return unicodeHash; } switch (LM_COMPATIBILITY) { case 0: case 1: case 2: return getNTLMResponse( password, challenge ); case 3: case 4: case 5: /* if( clientChallenge == null ) { clientChallenge = new byte[8]; RANDOM.nextBytes( clientChallenge ); } return getNTLMv2Response(domain, username, password, null, challenge, clientChallenge); */ return new byte[0]; default: return getNTLMResponse( password, challenge ); } }
public Type1Message createType1 () throws IOException { final int flags = getDefaultFlags (); return new Type1Message ( flags, this.credentials.getDomain (), Type1Message.getDefaultWorkstation () ); }
System.arraycopy(type3Message.getLMResponse(), 0, servernonce, 8, 8);//first 8 bytes only , the rest are all 0x00 and not required. try { sessionResponseUserSessionKey = ntlmKeyFactory.getNTLM2SessionResponseUserSessionKey(credentials.getPassword(), servernonce); } catch (Exception e) { throw new RuntimeException("Exception occured while forming Session Security from Type3 AUTH",e);
/** * Constructs the LanManager response to the given Type-2 message using * the supplied password. * * @param type2 The Type-2 message. * @param password The password. * @return A <code>byte[]</code> containing the LanManager response. */ public static byte[] getLMResponse(Type2Message type2, String password) { if (type2 == null || password == null) return null; return NtlmPasswordAuthentication.getPreNTLMResponse(password, type2.getChallenge()); }
defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); ssn.setAttribute( "ntlmdomain", ntlm.getDomain() ); ssn.setAttribute( "ntlmuser", ntlm.getUsername() ); } else { HttpSession ssn = request.getSession(false);
defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); dc = UniAddress.getByName( domainController, true ); log.println( "NtlmHttpFilter: " + ntlm.getName() + ": 0x" + jcifs.util.Hexdump.toHexString( sae.getNtStatus(), 8 ) + ": " + sae );
target = this.credentials.getDomain ().toUpperCase (); if ( target.equals ( "" ) ) try final byte[] lmv2Response = Responses.getLMv2Response ( target, this.credentials.getUsername (), this.credentials.getPassword (), type2.getChallenge (), clientNonce ); final byte[][] retval = Responses.getNTLMv2Response ( target, this.credentials.getUsername (), this.credentials.getPassword (), type2.getTargetInformation (), type2.getChallenge (), clientNonce ); final byte[] ntlmv2Response = retval[0]; blob = retval[1]; type3 = new Type3Message ( flags, lmv2Response, ntlmv2Response, target, this.credentials.getUsername (), Type3Message.getDefaultWorkstation () ); try ntResponse = Responses.getNTLM2SessionResponse ( this.credentials.getPassword (), challenge, clientNonce ); type3 = new Type3Message ( flags, lmResponse, ntResponse, target, this.credentials.getUsername (), Type3Message.getDefaultWorkstation () ); final byte[] lmResponse = NtlmPasswordAuthentication.getPreNTLMResponse ( this.credentials.getPassword (), challenge ); final byte[] ntResponse = NtlmPasswordAuthentication.getNTLMResponse ( this.credentials.getPassword (), challenge ); type3 = new Type3Message ( flags, lmResponse, ntResponse, target, this.credentials.getUsername (), Type3Message.getDefaultWorkstation () ); if ( ( flags & NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH ) != 0 ) userSessionKey = ntlmKeyFactory.getNTLMv2UserSessionKey ( target, this.credentials.getUsername (), this.credentials.getPassword (), type2.getChallenge (), blob ); try userSessionKey = ntlmKeyFactory.getNTLM2SessionResponseUserSessionKey ( this.credentials.getPassword (), servernonce );
String domain = ( index != -1 ) ? user.substring(0, index) : this.defaultDomain; user = ( index != -1 ) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(getTransportContext(), domain, user, password); ssn.setAttribute("ntlmdomain", ntlm.getUserDomain()); ssn.setAttribute("ntlmuser", ntlm.getUsername());