1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-14 15:23:39 +00:00

Updated usernameToUserKey() to support non-local accounts

This commit is contained in:
Bryan Roe
2019-11-05 13:58:14 -08:00
parent 9a84f82a50
commit cc59f186ca
2 changed files with 37 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@@ -223,6 +223,8 @@ function windows_registry()
}
};
this.usernameToUserKey = function usernameToUserKey(user)
{
try
{
var sid = user;
if (typeof (user) == 'string')
@@ -238,7 +240,30 @@ function windows_registry()
return (u.subkeys[i]);
}
}
throw (user + ': Not Found');
}
catch(e)
{
}
// Not Found yet, so let's try to brute-force it
var entries = this.QueryKey(this.HKEY.Users);
for(i in entries.subkeys)
{
if(entries.subkeys[i].split('-').length>5 && !entries.subkeys[i].endsWith('_Classes'))
{
try
{
if (this.QueryKey(this.HKEY.Users, entries.subkeys[i] + '\\Volatile Environment', 'USERNAME') == user)
{
return (entries.subkeys[i]);
}
}
catch(ee)
{
}
}
}
throw ('Unable to determine HKEY_USERS key for: ' + user);
};
}