使用Python解密Windows无线密码

2024-09-29 19:04:18 发布

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

我试图用Python解密profilexml文件中存储的Windows无线密码。我遇到了一个blog post,它给出了如何使用Python的win32crypt模块调用Windows CryptUnprotectData的示例。我的问题是我得到了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?在

作为参考,我检索到的加密密码是WindowsVista配置文件xml文件中的keyMaterial密钥。在

我使用的代码:

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]

提前谢谢。在


Tags: thetorunincmdyouanfor
1条回答
网友
1楼 · 发布于 2024-09-29 19:04:18

如果你需要的话,为什么不让你的系统管理员给你本地系统特权呢?在

顺便说一句,不要费心从十六进制到二进制的复杂转换。就这么做吧:

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

相关问题 更多 >

    热门问题