精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
At the end of part 1, I asked you to choose which language to program in. I presented four choices for you:
在第1部分的结尾,我要求您选择要编程的语言。我为您提供了四种选择:
In order to get this method to work, you have to call some of the most confusing APIs in the Windows SDK! These low level APIs know nothing about the inheritance model of Windows 2000 (using these APIs will lead to a security bug on Windows 2000). There's no consistency as to whether the functions return bools, errnos, pointers, or voids. And one API expects you to manage five memory buffers, all from the LocalAlloc() heap! It's very easy to make a mistake developing with this method.为了使该方法起作用,您必须调用Windows SDK中一些最令人困惑的API!这些低级API对Windows 2000的继承模型一无所知(使用这些API将导致Windows 2000上的安全性错误)。函数是否返回bools,errnos,指针或voids不一致。一个API期望您从LocalAlloc()堆中管理五个内存缓冲区!使用这种方法开发错误很容易。
The only reason you'd want to use this technique is if your target market still uses Windows NT3.x or 4.x (and you enjoy being on the security mailing lists). New programs must not choose this technique at all. If you need to support just one Win9x or Win2000 client, you must not develop using this method. I feel sorry for you if you're forced to develop with this method of Access Control. Since your target environment is crippled, I will be assuming that your development environment is crippled (i.e. you don't have a reliable C++ compiler). This method will be programmed in C.
您想要使用此技术的唯一原因是,如果您的目标市场仍然使用Windows NT3.x或4.x(并且您喜欢被列入安全邮件列表中)。新程序绝对不能选择这种技术。如果只需要支持一个Win9x或Win2000客户端,则不能使用此方法进行开发。如果您被迫使用这种访问控制方法进行开发,我为您感到抱歉。由于您的目标环境很糟糕,因此我假设您的开发环境也很糟糕(即您没有可靠的C ++编译器)。此方法将用C编程。
During Windows NT 4 and 2000, Microsoft added a new set of APIs to make security programming easier. Perhaps the most significant result was the addition of the Security Descriptor Definition Language (SDDL).在Windows NT 4和2000中,Microsoft添加了一组新的API,以简化安全编程。也许最重要的结果是添加了安全描述符定义语言(SDDL)。
The Security Descriptor Definition Language (SDDL) presents security descriptors as a data-driven structure rather than as a programmatic structure, so both developers and administrators can now write security descriptors. At first sight SDDL seems to be just as non-descript as the low level structures, but if you look at enough SDDL strings, you will see it is far simpler to make SDDL strings than raw structures. The ConvertSecurityDescriptorToStringSecurityDescriptor() and ConvertStringSecurityDescriptorToSecurityDescriptor() functions make it easy to convert SDDL to security descriptors.安全描述符定义语言(SDDL)将安全描述符以数据驱动的结构而不是程序结构的形式呈现,因此开发人员和管理员现在都可以编写安全描述符。乍一看,SDDL似乎与底层结构一样没有描述性,但是如果您查看足够的SDDL字符串,就会发现制作SDDL字符串要比原始结构简单得多。该ConvertSecurityDescriptorToStringSecurityDescriptor()和ConvertStringSecurityDescriptorToSecurityDescriptor()功能可以很容易地SDDL转换为安全描述符。
The other significant addition to Windows 2000 was the automatic inheritance of DACLs (described in part 1). The support of automatic inheritance required the addition of new APIs to manipulate them, and you can find this new functionality in the GetSecurityInfo() functions (or the GetPrivateObjectSecurityEx() functions if you are using a custom class).Windows 2000的另一个重要添加是DACL的自动继承(在第1部分中进行了介绍)。对自动继承的支持要求添加新的API来对其进行操作,并且您可以在GetSecurityInfo()函数(或GetPrivateObjectSecurityEx()使用自定义类的函数)中找到此新功能。
If you work carefully enough, you can make this technique run on Windows NT! This article will not tell you how to do this (you'll just have to read the documentation carefully) but it is possible.如果您足够仔细地工作,则可以使该技术在Windows NT上运行!本文不会告诉您如何执行此操作(您只需要仔细阅读文档即可),但是有可能。
There is a requirement that you have to redistribute the ATL DLLs (or expect for a bloated application), and if you don't own Visual Studio .NET, this method will be unavailable. Finally, if you are one of those that loath ATL, you are unlikely to choose this method.有一个要求,您必须重新分发ATL DLL(或期望用于application肿的应用程序),并且,如果您不拥有Visual Studio .NET,则此方法将不可用。最后,如果您不喜欢ATL,则不太可能选择此方法。
You most likely based your decision either on your previous experience of Access Control, or your programming background. Now unfortunately, for this article I have already made the decision for you: "All the code in this article will use the ATL way". But don't worry! The demo project includes equivalent programs for all the four methods. And I will discuss all the solutions to the problem, one for each method (it's just the code that will be presented in ATL).您很可能会根据您以前的访问控制经验或编程背景来做出决定。现在不幸的是,对于本文,我已经为您做出了决定:“本文中的所有代码都将使用ATL方式”。但是不用担心!该演示项目包括所有四种方法的等效程序。我将讨论该问题的所有解决方案,每种方法一个(这只是将在ATL中提供的代码)。
The LocalSystem account is a special NT user that represents the username for the kernel and system services. In English Windows, it has the name "NT AUTHORITY\SYSTEM" (English Windows only), and generally has unrestricted access to your local workstation.
该LocalSystem帐户是一个特殊的NT用户,代表内核和系统服务的用户名。在英文Windows中,它的名称为“ NT AUTHORITY\SYSTEM”(仅英文Windows),并且通常可以不受限制地访问您的本地工作站。
int WellKnownSid2Trustee(void) { /* Wrap up the object in a CSid */ ATL::CSid SidUser(ATL::Sids::System()); std::wcout << SidUser.Sid(); TRUSTEE TrusteeSid = {0}; ::BuildTrusteeWithSid(&TrusteeSid, const_cast(SidUser.GetPSID())); return 0; }
Figure 9: Converting a well known SID into a TRUSTEE
void Sid2UserName(const SID *UserSid) { ATL::CSid UserCSid(UserSid /*, Domain */); /** This line would be unnecessary if we passed in a * CSid rather than an unwrapped SID **/ std::wcout << UserCSid.AccountName(); }
Figure 10: Getting the Username from a SID.
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州市文化路47号院1号楼4层(47-1楼位于文化路和红专路十字路口东北角,郑州大学工学院招待所南边,工学院科技报告厅西边。)