hash passwords

Toomas Soome tsoome at ut.ee
Tue Jul 10 22:49:51 GMT 2001


I do:
    TimeInit();
    charset_initialise();
    lp_load(servicesf,1,0,0);
    codepage_initialise(lp_client_code_page());

in my little perl module. works fine for lm and NT hash.

On Wed, 11 Jul 2001, Roland Bauerschmidt wrote:

> I wrote a small patch against Samba 2.2 to get a tool (let's call it
> hashsmbpasswd) to encrypt a given password as Samba does. I am using the
> nt_lm_owf_gen function for that. This works fine for everything except
> of the NT hash which is everytime the same and logically doesn't work.
> Maybe somebody sees the flaw in this.
>
> 	Roland
>
> #include <stdio.h>
> #include <string.h>
> #include "includes.h"
>
> #define CMDLINE
>
> /*
>  * hashsmbpasswd -- hashes a passwd and prints the entries as in
>  * /etc/samba/smbpasswd
>  */
>
> int main(int argc, char *argv[])
> {
>         char passwd[130];
>         uchar nt_p16[16];
>         uchar p16[16];
>         int i;
>
> #ifdef CMDLINE
>         if(argc != 2) {
>                 fprintf(stderr, "Usage: %s password\n", argv[0]);
>                 exit(1);
>         }
>
>         strncpy(passwd, argv[1], 130);
>         /* we don't want the password in process list */
>         memset(argv[1], 0, strlen(argv[1]));
> #else
>         fgets(passwd, 130, stdin);
>         passwd[strlen(passwd)-1] = '\0';
> #endif
>
>         nt_lm_owf_gen(passwd, nt_p16, p16);
>
>         for(i = 0; i < 16; i++)
>                 printf("%02X", nt_p16[i]);
>         printf("\n");
>         for(i = 0; i < 16; i++)
>                 printf("%02X", p16[i]);
>         printf("\n");
>         printf("[U          ]\n");
>         printf("LCT-%08X\n", time(NULL));
> }
>
> --
> Roland Bauerschmidt
>

toomas
-- 
Experience, n:
	Something you don't get until just after you need it.
		-- Olivier





More information about the samba-technical mailing list