Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
dumpsd.c
Package: win2ksrc.rar [view]
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 4k
Category:
Windows Develop
Development Platform:
Visual C++
- #ifdef DEBUG
- void HexDumpBytes(
- TCHAR *pv,
- unsigned cb)
- {
- TCHAR achHex[]=TEXT("0123456789ABCDEF");
- TCHAR achOut[80];
- unsigned iOut;
- iOut = 0;
- while (cb)
- {
- if (iOut >= 78)
- {
- PINFO(achOut);
- iOut = 0;
- }
- achOut[iOut++] = achHex[(*pv >> 4) & 0x000f];
- achOut[iOut++] = achHex[*pv++ & 0x000f];
- achOut[iOut] = TEXT('');
- cb--;
- }
- if (iOut)
- {
- PINFO(achOut);
- }
- }
- void PrintSid(
- PSID sid)
- {
- DWORD cSubAuth;
- DWORD i;
- PINFO(TEXT("rnSID: "));
- if (sid)
- {
- HexDumpBytes((LPBYTE)GetSidIdentifierAuthority(sid), sizeof(SID_IDENTIFIER_AUTHORITY));
- SetLastError(0);
- cSubAuth = *GetSidSubAuthorityCount(sid);
- if (GetLastError())
- {
- PINFO(TEXT("Invalid SIDrn"));
- }
- else
- {
- for (i = 0;i < cSubAuth; i++)
- {
- PINFO(TEXT("-"));
- HexDumpBytes((LPBYTE)GetSidSubAuthority(sid, i), sizeof(DWORD));
- }
- PINFO(TEXT("rn"));
- }
- }
- else
- {
- PINFO(TEXT("NULL SIDrn"));
- }
- }
- //
- // Purpose: Print out the entries in an access-control list.
- //
- void PrintAcl(
- PACL pacl)
- {
- ACL_SIZE_INFORMATION aclsi;
- ACCESS_ALLOWED_ACE *pace;
- unsigned i;
- if (pacl)
- {
- if (GetAclInformation(pacl, &aclsi, sizeof(aclsi), AclSizeInformation))
- {
- for (i = 0;i < aclsi.AceCount;i++)
- {
- GetAce(pacl, i, &pace);
- PINFO(TEXT("Type(%x) Flags(%x) Access(%lx)rnSID:"),(int)pace->Header.AceType,
- (int)pace->Header.AceFlags, pace->Mask);
- PrintSid((PSID)&(pace->SidStart));
- }
- }
- }
- else
- {
- PINFO(TEXT("NULL PACLrn"));
- }
- }
- void PrintSD(
- PSECURITY_DESCRIPTOR pSD)
- {
- DWORD dwRev;
- WORD wSDC;
- BOOL fDefault, fAcl;
- PACL pacl;
- PSID sid;
- if (NULL == pSD)
- {
- PINFO(TEXT("NULL sdrn"));
- return;
- }
- if (!IsValidSecurityDescriptor(pSD))
- {
- PINFO(TEXT("Bad SD %p"), pSD);
- return;
- }
- // Drop control info and revision
- if (GetSecurityDescriptorControl(pSD, &wSDC, &dwRev))
- {
- PINFO(TEXT("SD - Length: [%ld] Control: [%x] [%lx]rnGroup:"),
- GetSecurityDescriptorLength(pSD), wSDC, dwRev);
- }
- else
- {
- PINFO(TEXT("Couldn't get controlrnGroup"));
- }
- // Show group and owner
- if (GetSecurityDescriptorGroup(pSD, &sid, &fDefault) &&
- sid &&
- IsValidSid(sid))
- {
- PrintSid(sid);
- PINFO(TEXT(" %s default.rnOwner:"), fDefault ? TEXT(" ") : TEXT("Not"));
- }
- else
- {
- PINFO(TEXT("Couldn't get grouprn"));
- }
- if (GetSecurityDescriptorOwner(pSD, &sid, &fDefault) &&
- sid &&
- IsValidSid(sid))
- {
- PrintSid(sid);
- PINFO(TEXT(" %s default.rn"), fDefault ? TEXT(" ") : TEXT("Not"));
- }
- else
- {
- PINFO(TEXT("Couldn't get ownerrn"));
- }
- // Print DACL and SACL
- if (GetSecurityDescriptorDacl(pSD, &fAcl, &pacl, &fDefault))
- {
- PINFO(TEXT("DACL: %s %srn"), fAcl ? TEXT("Yes") : TEXT("No"),
- fDefault ? TEXT("Default") : TEXT(" "));
- if (fAcl)
- {
- if (pacl && IsValidAcl(pacl))
- {
- PrintAcl(pacl);
- }
- else
- {
- PINFO(TEXT("Invalid Acl %prn"), pacl);
- }
- }
- }
- else
- {
- PINFO(TEXT("Couldn't get DACLrn"));
- }
- if (GetSecurityDescriptorSacl(pSD, &fAcl, &pacl, &fDefault))
- {
- PINFO(TEXT("SACL: %s %srn"), fAcl ? TEXT("Yes") : TEXT("No"),
- fDefault ? TEXT("Default") : TEXT(" "));
- if (fAcl)
- {
- if (pacl && IsValidAcl(pacl))
- {
- PrintAcl(pacl);
- }
- else
- {
- PINFO(TEXT("Invalid ACL %prn"), pacl);
- }
- }
- }
- else
- {
- PINFO(TEXT("Couldn't get SACLrn"));
- }
- }
- #else
- #define PrintSid(x)
- #define PrintSD(x)
- #endif