python - 使用 Python 解密 Windows 无线密码

标签 python encryption wireless

我正在尝试使用 Python 解密存储在配置文件 xml 文件中的 Windows 无线密码。我遇到了 blog post举例说明如何调用 Windows CryptUnprotectData使用 Python 的 win32crypt 模块。我的问题是我收到 Key not valid for use in specified state 错误,需要使用 LocalSystem 运行它。

You will get that error even if you run cmd.exe as an administrator. Here's where you need to know a bit about Windows that, as a Windows n00b, I didn't know: the LocalSystem account is different from the administrator privilege. In order to run cmd.exe with the LocalSystem account, you need to install a Microsoft package called PsTools. Inside PsTools a program called PsExec, which is a little bit like sudo on Un*x. Just download the zip linked at the bottom of the Microsoft TechNet page above and unzip it somewhere where you can find it.

To use PsExec, open cmd.exe as an administrator (open the start menu in the bottom-left of your screen, type cmd.exe into the search box, and press Ctrl+Shift+Enter to run it as an admin). Hit "continue" on the User Account Control dialog box that opens. In the command shell that opens, navigate to the directory where you unzipped PsTools. Now run "psexec.exe /s /i cmd.exe". After you agree to PsTools's EULA, PsTools should open a new cmd.exe shell window running as LocalSystem.

有没有如博文所述不使用 psexec.exe 解决此错误的方法?也许使用 CryptoPy 或 PyCrypto?

作为引用,我检索到的加密密码是 Windows Vista 配置文件 xml 文件中的 keyMaterial key 。

我使用的代码:

import win32crypt
mykey='01000000D08C9DDF.....' # 308 characters long
binout = []
for i in range(len(mykey)):
    if i % 2 == 0:
        binout.append(chr(int(mykey[i:i+2],16)))
pwdHash=''.join(binout)

output =  win32crypt.CryptUnprotectData(pwdHash,None,None,None,0)

print "hex:", "".join(["%02X" % ord(char) for char in output[1]])

print "ascii:", output[1]

提前致谢。

最佳答案

如果您需要的话,为什么不让您的系统管理员给您 LocalSystem 权限呢?

顺便说一句,不要为从十六进制到二进制的复杂转换而烦恼。只是做:

In [5]: '01000000D08C9DDF'.decode('hex')
Out[5]: '\x01\x00\x00\x00\xd0\x8c\x9d\xdf'

关于python - 使用 Python 解密 Windows 无线密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11445058/

相关文章:

python - 找不到在 Django 中呈现页面的代码

python - 在数据分析工具 QLikView 中运行 Python 脚本

ios - 放在钥匙串(keychain)中的数据应该手动加密吗?

linux - 将 WiFi Dongle 与 Beaglebone Black-Issue 集成

ios - 如何在 iOS 设备上获取关联接入点的 IP 地址

python - Open() 需要整数吗?

python - 如何将 pandas 中的数据框组合在一起?

c++ - 需要帮助来理解轮类计算并减少我的代码中的一些脂肪

c# - 在 .NET 中加密字符串并在 PHP 中解密?

mobile - 当连接到 3/4G 网络上某人提供的无线热点时,您的设备是否获得 IP 地址?