mirror of
https://github.com/MzHmO/WhoIsWho
synced 2026-06-06 16:14:37 +00:00
SSPI
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
void WhoIsWho();
|
||||
|
||||
int main()
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
WhoIsWho();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SECURITY_WIN32
|
||||
#include <sspi.h>
|
||||
#pragma comment (lib, "Secur32.lib")
|
||||
void WhoIsWho() {
|
||||
CredHandle hCredentials;
|
||||
TimeStamp tsExpires;
|
||||
NTSTATUS status = AcquireCredentialsHandle(
|
||||
NULL,
|
||||
(LPWSTR)L"Kerberos",
|
||||
SECPKG_CRED_BOTH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&hCredentials,
|
||||
&tsExpires
|
||||
);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
{
|
||||
status = AcquireCredentialsHandle(
|
||||
NULL,
|
||||
(LPWSTR)L"NTLM",
|
||||
SECPKG_CRED_BOTH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&hCredentials,
|
||||
&tsExpires
|
||||
);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SecPkgCredentials_NamesW names;
|
||||
status = QueryCredentialsAttributesW(
|
||||
&hCredentials,
|
||||
SECPKG_CRED_ATTR_NAMES,
|
||||
&names
|
||||
);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::wcout << names.sUserName << std::endl;
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user