libntlm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make nt and lm hashes of a password


From: Andrea Zagli
Subject: make nt and lm hashes of a password
Date: Wed, 27 May 2009 16:08:47 +0200
User-agent: Internet Messaging Program (IMP) H3 (4.3.2)

i just want to make nt and lm hashes of a password: how can i do?

i made this try below, but it doesn't work (the hashes aren't the same made by smbldap-passwd)

thanks in advance


#include <stdio.h>
#include <string.h>

#include <ntlm.h>

static uint16
intelEndian16 (uint16 n)
{
  uint16 u;
  unsigned char *buf = (unsigned char *) &u;
  buf[0] = n & 0xff;
  buf[1] = (n >> 8) & 0xff;
  return u;
}

static uint32
intelEndian32 (uint32 n)
{
  uint32 u;
  unsigned char *buf = (unsigned char *) &u;
  buf[0] = n & 0xff;
  buf[1] = (n >> 8) & 0xff;
  buf[2] = (n >> 16) & 0xff;
  buf[3] = (n >> 24) & 0xff;
  return u;
}

static void
fillUnicode (tSmbStrHeader * header, char *buffer, int buffer_start,
             int *index, const char *s)
{
  int len = strlen (s);
  header->len = header->maxlen = intelEndian16 (len * 2);
  header->offset = intelEndian32 (*index + buffer_start);
  *index += len * 2;

  for (; len; --len)
    {
      *buffer++ = *s++;
      *buffer++ = 0;
    }
}

static void
fillChallenge (tSmbNtlmAuthChallenge * challenge, const char *domain)
{
  int index = 0;

  memset (challenge, 0, sizeof (*challenge));
  memcpy (challenge->ident, "NTLMSSP\0\0\0", 8);
  challenge->msgType = intelEndian32 (2);
  fillUnicode (&challenge->uDomain, challenge->buffer,
               challenge->buffer - ((uint8 *) challenge), &index, domain);
  challenge->flags = intelEndian32 (0);
  memcpy (challenge->challengeData, "\x01\x02\x03\x04\xf5\xc3\xb2\x82", 8);
  challenge->bufIndex = intelEndian32 (index);
}

int
main (int argc, char **argv)
{
        uint8 lmRespData[24];
        uint8 ntRespData[24];
        tSmbNtlmAuthChallenge challenge;

        int i;

        fillChallenge (&challenge, "PDC-SRV");

        ntlm_smb_encrypt ("pippo", challenge.challengeData, lmRespData);
        ntlm_smb_nt_encrypt ("pippo", challenge.challengeData, ntRespData);

        for (i = 0; i < 24; i++)
                {
                        printf ("%X", lmRespData[i]);
                }
        printf ("\n");

        for (i = 0; i < 24; i++)
                {
                        printf ("%X", ntRespData[i]);
                }
        printf ("\n");

        return 0;
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]