[jcifs] Hash generation
Michael B Allen
mba2000 at ioplex.com
Tue Oct 25 16:48:26 GMT 2005
Here, maybe this will help:
http://davenport.sourceforge.net/ntlm.html
Mike
On Tue, 25 Oct 2005 15:07:05 +0000
paulo at hdfigueira.min-saude.pt wrote:
>
> I try to do a class that autenticates a user using NTLM (something like the NtlmHttpFilter), but I couldnt make it to work.
> After some testing I try to pass a known chalenge to the IE insted of geting it from the domain controller, and I found that the response was different from the one I would get from the NtlmPasswordAuthentication.getPreNTLMResponse() and NtlmPasswordAuthentication.getNTLMResponse() functions.
>
> I used the fowling code:
>
> public class Teste {
>
> /*
> args[0] = domainController
> args[1] = domain
> args[2] = username
> args[3] = password
> */
> public static void main(String[] args) throws Exception {
> UniAddress dc = UniAddress.getByName( args[0], true );
> //byte[] challenge = SmbSession.getChallenge( dc );
> byte[] c2 = {(byte)140, (byte)255, (byte)158, (byte)148, (byte)164, (byte)96, (byte)54, (byte)20};
> byte[] challenge = c2;
> for(int i=0; i<challenge.length; i++) {
> System.out.println(" challenge["+i+"] = "+(challenge[i] & 0xFF));
> }
>
> byte[] lm = NtlmPasswordAuthentication.getPreNTLMResponse(args[3],challenge);
> byte[] nt = NtlmPasswordAuthentication.getNTLMResponse(args[3],challenge);
>
> NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(args[1], args[2], challenge, lm, nt);
> for(int i=0; i<lm.length; i++) {
> System.out.println(" lm["+i+"] = "+(lm[i] & 0xFF));
> }
> for(int i=0; i<nt.length; i++) {
> System.out.println(" nt["+i+"] = "+(nt[i] & 0xFF));
> }
>
> SmbSession.logon( dc, ntlm );
> }
> }
>
> When using this code I get:
> ch: 140 255 158 148 164 96 54 20
> lm: 8 159 168 108 15 58 94 216 65 8 134 215 235 120 92 158 200 152 159 31 188 56 145 221
> nt: 242 230 2 106 6 75 148 28 51 66 93 36 56 223 135 13 190 94 34 199 136 214 224 95
>
> When passing the same chalenge (and user, pass, etc) to the IE, I get:
> ch: 140 255 158 148 164 96 54 20
> lm: 45 38 22 10 95 8 27 63 50 63 72 63 20 63 113 58 63 63 63 31 63 56 63 63
> nt: 90 63 107 63 63 63 63 63 10 63 63 110 104 37 35 60 81 17 63 115 102 63 63 63
>
> Is this normal ?
> Should'nt I get the same response ?
>
> Paulo Gonçalves
>
> Hospital Distrital da Figueira da Foz, SA.
>
More information about the jcifs
mailing list