winpr-hash: cleanup cmd line and add man page

* add a initial man page
* clean up the command line a little bit (basically error messages)
This commit is contained in:
Bernhard Miklautz 2017-01-11 15:28:18 +01:00
parent 3a4e1adee7
commit 2f93c0f452
4 changed files with 70 additions and 18 deletions

View File

@ -1,2 +1,3 @@
makecert-cli/winpr-makecert
hash-cli/winpr-hash
hash-cli/winpr-hash.1

View File

@ -50,3 +50,4 @@ if (WITH_DEBUG_SYMBOLS AND MSVC)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools")
configure_file(winpr-hash.1.in ${CMAKE_CURRENT_BINARY_DIR}/winpr-hash.1)

View File

@ -44,6 +44,13 @@
*
*/
void usage_and_exit()
{
printf("winpr-hash: NTLM hashing tool\n");
printf("Usage: winpr-hash -u <username> -p <password> [-d <domain>] [-f <_default_,sam>] [-v <_1_,2>]\n");
exit(1);
}
int main(int argc, char* argv[])
{
int index = 1;
@ -65,8 +72,8 @@ int main(int argc, char* argv[])
if (index == argc)
{
printf("missing domain\n");
exit(1);
printf("missing domain\n\n");
usage_and_exit();
}
Domain = argv[index];
@ -77,8 +84,8 @@ int main(int argc, char* argv[])
if (index == argc)
{
printf("missing username\n");
exit(1);
printf("missing username\n\n");
usage_and_exit();
}
User = argv[index];
@ -89,8 +96,8 @@ int main(int argc, char* argv[])
if (index == argc)
{
printf("missing password\n");
exit(1);
printf("missing password\n\n");
usage_and_exit();
}
Password = argv[index];
@ -101,14 +108,17 @@ int main(int argc, char* argv[])
if (index == argc)
{
printf("missing version\n");
exit(1);
printf("missing version parameter\n\n");
usage_and_exit();
}
version = atoi(argv[index]);
if ((version != 1) && (version != 2))
version = 1;
{
printf("unkown version %d \n\n", version);
usage_and_exit();
}
}
else if (strcmp("-f", argv[index]) == 0)
{
@ -116,8 +126,8 @@ int main(int argc, char* argv[])
if (index == argc)
{
printf("missing format\n");
exit(1);
printf("missing format\n\n");
usage_and_exit();
}
if (strcmp("default", argv[index]) == 0)
@ -127,9 +137,7 @@ int main(int argc, char* argv[])
}
else if (strcmp("-h", argv[index]) == 0)
{
printf("winpr-hash: NTLM hashing tool\n");
printf("Usage: winpr-hash -u <username> -p <password> [-d <domain>] -f <default,sam> -v <1,2>\n");
exit(1);
usage_and_exit();
}
index++;
@ -137,8 +145,8 @@ int main(int argc, char* argv[])
if ((!User) || (!Password))
{
printf("missing username or password\n");
exit(1);
printf("missing username or password\n\n");
usage_and_exit();
}
UserLength = strlen(User);
@ -149,8 +157,8 @@ int main(int argc, char* argv[])
{
if (!Domain)
{
printf("missing domain\n");
exit(1);
printf("missing domain (version 2 requires a domain to specified)\n\n");
usage_and_exit();
}
NTOWFv2A(Password, PasswordLength, User, UserLength, Domain, DomainLength, NtHash);

View File

@ -0,0 +1,42 @@
.TH winpr-hash 1 2017-01-11 "@FREERDP_VERSION_FULL@" "FreeRDP"
.SH NAME
winpr-hash \- NTLM hashing tool
.SH SYNOPSIS
.B winpr-hash
\fB-u\fP username
\fB-p\fP password
[\fB-d\fP domain]
[\fB-f\fP { \fIdefault\fP | sam }]
[\fB-v\fP { \fI1\fP | 2 }]
.SH DESCRIPTION
.B winpr-hash
is a small utility that can be used to create a NTLM hash form a username and password pair. The created hash can be outputed as plain hash or in SAM format.
.SH OPTIONS
.IP "-u username"
The username to use.
.IP "-p password"
Password to use.
.IP "-d domain"
A optional parameter to specify the domain of the user.
.IP "-f format"
Specify the output format. The \fIdefault\fP outputs only the plain NTLM
hash. The second output format available is \fIsam\fP which outputs the
created hash in a format that it can be used in SAM file:
user:domain::hash:::
.IP "-v version"
Version allows it to specify the NTLM version to use. The default is to use version 1. In case
version 2 is used a domain needs to be specified.
.SH EXAMPLES
winpr-hash -u \fIuser\fP -p \fIpassword\fP -d \fIdomain\fP -f \fIsam\fP -v \fI2\fP
Create a version \fI2\fP NTLM hash for \fIuser\fP with \fIdomain\fP and \fIpassword\fP and output it in \fIsam\fP format.
.SH EXIT STATUS
.TP
.B 0
Successful program execution.
.TP
.B 1
Missing or invalid arguments.
.SH AUTHOR
FreeRDP <team@freerdp.com>