PyWin32能否为用户提供对Win32 API的“太多”访问权限?

问题描述 投票:2回答:1

我正在为具有非常高安全性标准的公用事业组开发一个工具(出于显而易见的原因)。此工具在ESRI的ArcMap应用程序(使用ArcMap API - 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)将不会绕过分配给该用户配置文件的任何安全设置。

我能正确理解吗?我错过了什么吗?

python security pywin32 win32com
1个回答
1
投票

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

这是Python for Win32(pywin32)扩展的自述文件,它提供了对Python中许多Windows API的访问。

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

由于Pywin32没有官方文档页面,我将引用下一个最好的东西(我发现):[ActiveState.Docs]: PyWin32 Documentation

例子:

底线

PyWin32没有授予(默认情况下)其他权限(权限)。


但是我试图找到管理层担心安装PyWin32的原因。

一般来说,专家(在WINAPI领域)很可能知道:

  1. C(开发人数正在减少)
  2. 赢得内部(这里也不是很多)
  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%以上的盗贼(平庸的)
  • 对真正的主人没有任何影响
© www.soinside.com 2019 - 2024. All rights reserved.