PyWin32能给用户“太多”访问win32api的权限吗?

2024-05-16 05:22:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为一个具有很高安全标准的公用事业集团开发一个工具(原因很明显)。这个工具运行在ESRI的ArcMap应用程序中(使用arcmapapi-ArcPy)。ArcFM是安装在ArcMap之上的软件,用于基于实用程序的分析(ArcFM具有与ArcMap不同的许可证)。我正在开发的工具需要ArcPy(Python)使用PyWin32签出ArcFM许可证(参见下面的代码片段)

#ArcFM licensing
import win32com.client
app = win32com.client.Dispatch("Miner.Framework.Dispatch.MMAppInitializeDispatch")
runtime = win32com.client.Dispatch("Miner.Framework.Dispatch.MMRuntimeEnvironmentDispatch")
app.Initialize(0x5)
#end ArcFm licensing

为了在我正在开发的工具中使用一些ArcFM功能,ArcFM许可证必须首先在脚本中签出。在

这个片段签出ArcFM的许可证,这样我就可以在GUI之外访问ArcFM函数。公用事业集团的IT主管一直在犹豫要不要在他们的机器上安装PyWIN,因为他/她担心这会给用户太多访问自己电脑的权限。在

据我所知,Win32不会给用户额外的访问权限(它只允许用户通过API访问功能)。例如,如果用户没有访问注册表项的权限,Win32(或PyWin32)将不会绕过分配给该用户配置文件的任何安全设置。在

我理解得对吗?我错过了什么吗?在


Tags: 工具用户clientapp权限win32com集团公用事业
1条回答
网友
1楼 · 发布于 2024-05-16 05:22:49

[GitHub]: mhammond/pywin32 - Python for Windows (pywin32) Extensions强调是我的)状态:

This is the readme for the Python for Win32 (pywin32) extensions, which provides access to many of the Windows APIs from Python.

因此,PyWin32是一个覆盖在WINAPIs的Python包装器(它只允许以友好的方式从Python调用它们)。不管它是否安装在Python上,WINAPI仍然存在,可以从以下位置访问:

因为Pywin32没有官方文档页面,所以我将引用我发现的下一个最好的东西:[ActiveState.Docs]: PyWin32 Documentation。在

示例:


底线

在默认情况下,PyWin32没有额外的特权(权限)。在


然而,我试图找出管理层对安装PyWin32的担忧的原因。在

一般而言,专家(在WINAPI领域)最有可能知道:

  1. C(开发人员数量正在减少)
  2. Win内部(这里也不是很多)
  3. 一般计算机(低级)知识
  4. 从上面的3个例子中,这些用户将知道调用WINAPI的含义(如果不知道,他们很容易知道为了得到答案,应该搜索/调查什么)

从这些用户的PoV来看,没有什么区别。但由于PyWin32模块可以查询其内容:

>>> import win32security
>>>
>>> print([name for name in dir(win32security) if callable(getattr(win32security, name))])
['ACL', 'AcceptSecurityContext', 'AcquireCredentialsHandle', 'AdjustTokenGroups', 'AdjustTokenPrivileges', 'AllocateLocallyUniqueId', 'CheckTokenMembership', 'ConvertSecurityDescriptorToStringSecurityDescriptor', 'ConvertSidToStringSid', 'ConvertStringSecurityDescriptorToSecurityDescriptor', 'ConvertStringSidToSid', 'CreateRestrictedToken', 'CreateWellKnownSid', 'CredHandleType', 'CryptEnumProviders', 'CtxtHandleType', 'DsBind', 'DsCrackNames', 'DsGetDcName', 'DsGetSpn', 'DsListDomainsInSite', 'DsListInfoForServer', 'DsListRoles', 'DsListServersForDomainInSite', 'DsListServersInSite', 'DsListSites', 'DsUnBind', 'DsWriteAccountSpn', 'DuplicateToken', 'DuplicateTokenEx', 'EnumerateSecurityPackages', 'GetBinarySid', 'GetFileSecurity', 'GetKernelObjectSecurity', 'GetNamedSecurityInfo', 'GetPolicyHandle', 'GetSecurityInfo', 'GetTokenInformation', 'GetUserObjectSecurity', 'ImpersonateAnonymousToken', 'ImpersonateLoggedOnUser', 'ImpersonateNamedPipeClient', 'ImpersonateSelf', 'InitializeSecurityContext', 'IsTokenRestricted', 'LogonUser', 'LogonUserEx', 'LookupAccountName', 'LookupAccountSid', 'LookupPrivilegeDisplayName', 'LookupPrivilegeName', 'LookupPrivilegeValue', 'LsaAddAccountRights', 'LsaCallAuthenticationPackage', 'LsaClose', 'LsaConnectUntrusted', 'LsaDeregisterLogonProcess', 'LsaEnumerateAccountRights', 'LsaEnumerateAccountsWithUserRight', 'LsaEnumerateLogonSessions', 'LsaGetLogonSessionData', 'LsaLookupAuthenticationPackage', 'LsaOpenPolicy', 'LsaQueryInformationPolicy', 'LsaRegisterLogonProcess', 'LsaRegisterPolicyChangeNotification', 'LsaRemoveAccountRights', 'LsaRetrievePrivateData', 'LsaSetInformationPolicy', 'LsaStorePrivateData', 'LsaUnregisterPolicyChangeNotification', 'MapGenericMask', 'OpenProcessToken', 'OpenThreadToken', 'PyCredHandleType', 'PyCtxtHandleType', 'PySecBufferDescType', 'PySecBufferType', 'QuerySecurityPackageInfo', 'RevertToSelf', 'SECURITY_ATTRIBUTES', 'SECURITY_DESCRIPTOR', 'SID', 'SecBufferDescType', 'SecBufferType', 'SetFileSecurity', 'SetKernelObjectSecurity', 'SetNamedSecurityInfo', 'SetSecurityInfo', 'SetThreadToken', 'SetTokenInformation', 'SetUserObjectSecurity', 'TranslateName', 'error']

这可能会得到另一种用户的想法。在

因此(有争议的是:错误的)关注的是,一个强大的力量(包括知识的力量)被分享给那些可能不具备处理这种权力所需的重大责任的用户。在某些情况下,这可能会导致(戏剧化一点)灾难(不管是因为错误还是恶意,都不太相关)。在

与现实生活中的情景相比较:在你的门上有一个假锁(或者在海滩上鞋子里的钱包):

  • 会阻止90%的盗贼(平庸者)
  • 对真正的大师没有效果

相关问题 更多 >