本文整理汇总了Python中win32security.LookupPrivilegeValue方法的典型用法代码示例。如果您正苦于以下问题:Python win32security.LookupPrivilegeValue方法的具体用法?Python win32security.LookupPrivilegeValue怎么用?Python win32security.LookupPrivilegeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32security
的用法示例。
在下文中一共展示了win32security.LookupPrivilegeValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_extra_privs
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import LookupPrivilegeValue [as 别名]
def get_extra_privs():
# Try to give ourselves some extra privs (only works if we're admin):
# SeBackupPrivilege - so we can read anything
# SeDebugPrivilege - so we can find out about other processes (otherwise OpenProcess will fail for some)
# SeSecurityPrivilege - ??? what does this do?
# Problem: Vista+ support "Protected" processes, e.g. audiodg.exe. We can't see info about these.
# Interesting post on why Protected Process aren't really secure anyway: http://www.alex-ionescu.com/?p=34
th = win32security.OpenProcessToken(win32api.GetCurrentProcess(), win32con.TOKEN_ADJUST_PRIVILEGES | win32con.TOKEN_QUERY)
privs = win32security.GetTokenInformation(th, TokenPrivileges)
newprivs = []
for privtuple in privs:
if privtuple[0] == win32security.LookupPrivilegeValue(remote_server, "SeBackupPrivilege") or privtuple[0] == win32security.LookupPrivilegeValue(remote_server, "SeDebugPrivilege") or privtuple[0] == win32security.LookupPrivilegeValue(remote_server, "SeSecurityPrivilege"):
print "Added privilege " + str(privtuple[0])
# privtuple[1] = 2 # tuples are immutable. WHY?!
newprivs.append((privtuple[0], 2)) # SE_PRIVILEGE_ENABLED
else:
newprivs.append((privtuple[0], privtuple[1]))
# Adjust privs
privs = tuple(newprivs)
str(win32security.AdjustTokenPrivileges(th, False , privs))
示例2: enable_privilege
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import LookupPrivilegeValue [as 别名]
def enable_privilege(privilege_name):
success = False
privilege_id = win32security.LookupPrivilegeValue(
None,
privilege_name
)
new_privilege = [(privilege_id, win32con.SE_PRIVILEGE_ENABLED)]
h_token = win32security.OpenProcessToken(
win32process.GetCurrentProcess(),
win32security.TOKEN_ALL_ACCESS
)
if h_token:
success = win32security.AdjustTokenPrivileges(
h_token, 0, new_privilege
)
close_handle(h_token)
return success
示例3: acquire_privilege
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import LookupPrivilegeValue [as 别名]
def acquire_privilege(privilege):
process = win32process.GetCurrentProcess()
token = win32security.OpenProcessToken(
process,
win32security.TOKEN_ADJUST_PRIVILEGES |
win32security.TOKEN_QUERY)
priv_luid = win32security.LookupPrivilegeValue(None, privilege)
privilege_enable = [(priv_luid, win32security.SE_PRIVILEGE_ENABLED)]
privilege_disable = [(priv_luid, win32security.SE_PRIVILEGE_REMOVED)]
win32security.AdjustTokenPrivileges(token, False, privilege_enable)
try:
yield
finally:
win32security.AdjustTokenPrivileges(token, False, privilege_disable)
示例4: seDebug
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import LookupPrivilegeValue [as 别名]
def seDebug():
try:
"""SEDebug"""
flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), flags)
id = win32security.LookupPrivilegeValue(None, "seDebugPrivilege")
newPrivileges = [(id, win32security.SE_PRIVILEGE_ENABLED)]
win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges)
except Exception as e:
print 'je me vautre'
pass