summaryrefslogtreecommitdiff
path: root/src/hashpwd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashpwd.cpp')
-rw-r--r--src/hashpwd.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/hashpwd.cpp b/src/hashpwd.cpp
index 414ffbd..6bc322c 100644
--- a/src/hashpwd.cpp
+++ b/src/hashpwd.cpp
@@ -10,6 +10,8 @@
#include <string.h>
#include <openssl/sha.h>
+#define MYVERSION "1.1"
+
using namespace std;
int v = 0;
@@ -148,28 +150,33 @@ void usage(void)
{
cout << "usage:" << endl <<
" mts-hashpwd [-v] [[-d did] [-m mac] | [-p password]] salt" << endl <<
+ " -V version" << endl <<
" -v verbose" << endl <<
" -d did Device ID (serial #)" << endl <<
" -m mac Ethernet mac address" << endl <<
" -p password" << endl <<
- "Either password must be supplied, or Device-ID and Ethernet Mac address" << endl <<
+ " -u uuid UUID (base 16)" << endl <<
+ "Either password must be supplied, or Device-ID and " << endl
+ << "either Ethernet Mac address or UUID" << endl <<
"salt is required." <<endl;
exit(1);
}
int main(int argc, char **argv) {
- int opt = 0, p = 0, d = 0, m = 0;
+ int opt = 0, p = 0, d = 0, m = 0, u=0;
unsigned long long fudge = 0;
short unsigned int prefix;
- string did, mac, pwd, salt;
+ string did, mac, pwd, salt, uuid;
- while ((opt = getopt(argc,argv,"d:m:p:v")) != EOF)
+ while ((opt = getopt(argc,argv,"Vd:m:p:u:v")) != EOF)
switch(opt)
{
+ case 'V': cout << MYVERSION << endl; exit(0);
case 'v': v = 1; cout << " verbose" <<endl; break;
case 'd': d = 1; did = optarg ; (v==1) && cout << "device-id is " << did << endl; break;
case 'm': m = 1; mac = optarg ; (v==1) && cout << "Ethernet mac is " << mac << endl; break;
case 'p': p = 1; pwd = optarg ; (v==1) && cout << "User defined password is \"" << pwd << "\"" << endl; break;
+ case 'u': u = 1; uuid = optarg ; (v==1) && cout << "UUID is \"" << uuid << "\"" << endl; break;
case '?': usage(); break;
default: cout<<endl; abort();
}
@@ -184,8 +191,8 @@ int main(int argc, char **argv) {
cout << "Must use either a supplied password or Device ID and Ethernet MAC address, but not all three." << endl;
usage();
}
- if ((d && !m) || (m && !d)) {
- cout << "Must have both a Device-ID and an Ethernet MAC address." << endl;
+ if ((d && (!m && !u)) || (m && !d) || (u && !d)) {
+ cout << "Must have both a Device-ID and either a UUID or Ethernet MAC address." << endl;
usage();
}
if (optind != argc-1) {
@@ -212,7 +219,10 @@ int main(int argc, char **argv) {
unsigned char hash[SHA256_DIGEST_LENGTH];
if(!p) {
- passwd0 = did + "|" + mac;
+ if (m)
+ passwd0 = did + "|" + mac;
+ else if (u)
+ passwd0 = did + "|" + uuid;
passwdnew = passwd0;
while (1) {