Ejemplo n.º 1
0
void DumpSecurityDescriptor(CSecurityDesc& sd, SECURITY_INFORMATION si, Mapping* pAccessMappings)
{
	CIndent scope;

	CSid sidOwner;
	CSid sidGroup;
	CDacl dacl;
	CSacl sacl;
	bool bPresent = false;
	bool bDefaulted = false;

	if (LOBYTE(LOWORD(::GetVersion())) >= 5)
	{
		// only works on Windows 2000 or greater
		CString strSD;
		if (sd.ToString(&strSD, si))
			Log(_T("%s"), (LPCTSTR)strSD);
	}

	if ((si & OWNER_SECURITY_INFORMATION) && sd.GetOwner(&sidOwner, &bDefaulted))
	{
		Log(_T("Owner: %s"),
			bDefaulted ? _T("[Defaulted]") : _T(""));
		DumpSid(sidOwner);
	}

	if ((si & GROUP_SECURITY_INFORMATION) && sd.GetGroup(&sidGroup, &bDefaulted))
	{
		Log(_T("Group: %s"),
			bDefaulted ? _T("[Defaulted]") : _T(""));
		DumpSid(sidGroup);
	}

	if ((si & DACL_SECURITY_INFORMATION) && sd.GetDacl(&dacl, &bPresent, &bDefaulted))
	{
		Log(_T("Dacl: %s %s"),
			bPresent ? _T("") : _T("[Not Present]"),
			bDefaulted ? _T("[Defaulted]") : _T(""));
		DumpAcl(dacl, pAccessMappings);
	}

	if ((si & SACL_SECURITY_INFORMATION) && sd.GetSacl(&sacl, &bPresent, &bDefaulted))
	{
		Log(_T("Sacl: %s %s"),
			bPresent ? _T("") : _T("[Not Present]"),
			bDefaulted ? _T("[Defaulted]") : _T(""));
		DumpAcl(sacl, pAccessMappings);
	}
}
Ejemplo n.º 2
0
//*****************************************************************************
//* Function Name: DumpTokenDefaultDacl
//*   Description: 
//*****************************************************************************
void DumpTokenDefaultDacl (
	HANDLE	p_hToken,
	LPVOID	p_pTokenInformation,
	DWORD	p_dwTokenInformationLength)
{
	PTOKEN_DEFAULT_DACL l_pTokenDefaultDacl = reinterpret_cast<PTOKEN_DEFAULT_DACL>(p_pTokenInformation);
	DumpAcl (l_pTokenDefaultDacl->DefaultDacl, _T("TOKEN_DEFAULT_DACL"));
	DumpAcl2 (l_pTokenDefaultDacl->DefaultDacl, _T("TOKEN_DEFAULT_DACL"));
}
Ejemplo n.º 3
0
void DumpAccessToken(CAccessToken& at)
{
	CIndent scope;

	CSid sidUser;
	if (!at.GetUser(&sidUser))
		Log(_T("Failure retrieving User from Token"));
	else
	{
		Log(_T("User:"******"Failure retrieving Groups from Token"));
	else
	{
		Log(_T("Groups:"));
		DumpGroups(groups);
	}

	CTokenPrivileges priv;
	if (!at.GetPrivileges(&priv))
		Log(_T("Failure retrieving Privileges from Token"));
	else
	{
		Log(_T("Privileges:"));
		DumpPrivileges(priv);
	}

	CSid sidOwner;
	if (!at.GetOwner(&sidOwner))
		Log(_T("Failure retrieving Owner from Token"));
	else
	{
		Log(_T("Default Owner:"));
		DumpSid(sidOwner);
	}

	CSid sidPrimaryGroup;
	if (!at.GetOwner(&sidPrimaryGroup))
		Log(_T("Failure retrieving Primary Group from Token"));
	else
	{
		Log(_T("Primary Group:"));
		DumpSid(sidPrimaryGroup);
	}

	CDacl dacl;
	if (!at.GetDefaultDacl(&dacl))
		Log(_T("Failure retrieving Default Dacl from Token"));
	else
	{
		Log(_T("Default Dacl:"));
		DumpAcl(dacl, mapGenericAccess);
	}

	TOKEN_SOURCE source;
	if (!at.GetSource(&source))
		Log(_T("Failure retrieving Source from Token"));
	else
	{
		Log(_T("Source:"));
		Log(_T("Source Name: %.8s"), CString(source.SourceName));
		Log(_T("Source Identifier: 0x%.8x%.8x"), source.SourceIdentifier.HighPart, source.SourceIdentifier.LowPart);
	}

	TOKEN_TYPE type;
	if (!at.GetType(&type))
		Log(_T("Failure retrieving Type from Token"));
	else
		Log(_T("Type: %s"), (LPCTSTR)GetTokenType(type));
	
	if (type == TokenImpersonation)
	{
		SECURITY_IMPERSONATION_LEVEL sil;
		if (!at.GetImpersonationLevel(&sil))
			Log(_T("Failure retrieving Impersonation Level from Token"));
		else
			Log(_T("Impersonation Level: %s"), (LPCTSTR)GetImpersonationLevel(sil));
	}

	TOKEN_STATISTICS stats;
	if (!at.GetStatistics(&stats))
		Log(_T("Failure retrieving Statistics from Token"));
	else
	{
		Log(_T("Statistics:"));
		DumpStatistics(stats);
	}
}