2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* hostapd - Plaintext password to NtPasswordHash
|
|
|
|
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
2009-11-29 22:04:43 +01:00
|
|
|
#include "crypto/ms_funcs.h"
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
unsigned char password_hash[16];
|
|
|
|
size_t i;
|
|
|
|
char *password, buf[64], *pos;
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
password = argv[1];
|
|
|
|
else {
|
|
|
|
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
|
|
|
printf("Failed to read password\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
|
|
|
pos = buf;
|
|
|
|
while (*pos != '\0') {
|
|
|
|
if (*pos == '\r' || *pos == '\n') {
|
|
|
|
*pos = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
password = buf;
|
|
|
|
}
|
|
|
|
|
2009-08-16 18:07:57 +02:00
|
|
|
if (nt_password_hash((u8 *) password, strlen(password), password_hash))
|
|
|
|
return -1;
|
2008-02-28 02:34:43 +01:00
|
|
|
for (i = 0; i < sizeof(password_hash); i++)
|
|
|
|
printf("%02x", password_hash[i]);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|