0

i wrote a small python app to automatically login a user to specific service using the keyring module (for storing the password in the windows credential vault) and wxpython for a login gui. The login tool for this service doesnt support the storage of login credentials but has a cmd login method i am using in my script.

The script is now finished and works perfectly but i would like to deploy this as exe to several other systems.

Keyring doesnt seem to play nice with pyinstaller but i got my program to start atleast after adding a huge list of hidden imports:

'json', 
'json.decoder', 
'json.encoder', 
'json.scanner',
'keyring.backends.file',
'keyring.backends.Gnome',
'keyring.backends.Google',
'keyring.backends.keyczar',
'keyring.backends.kwallet',
'keyring.backends.multi',
'keyring.backends.OS_X',
'keyring.backends.pyfs',
'keyring.backends.SecretService',
'keyring.backends.Windows',
'keyring.backends._win_crypto',
'keyring.util.escape',
'keyring.util.XDG',
'keyring.credentials'

With those the app starts without any errors of missing modules but it still crashes when it tries to access the credential vault:

c:\PY\novell_login>dist\thread_test\thread_test.exe
Logging in User: test
Traceback (most recent call last):
  File "c:\PY\build\thread_test\out00-PYZ.pyz\wx._core", line 16766, in <lambda>
  File "<string>", line 119, in LongTaskDone
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.core", line 44, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.file", line 87, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.Windows", line 81, in encrypt
NameError: global name '_win_crypto' is not defined

I dont know what else to do to fix this... Can anyone help me to properly include keyring or knows an alternative i could use. I would really like to keep using the windows crendential vault for storing the password.

Thanks!

Python: 2.7.9 pyinstaller: 2.1 keyring: 5.6 pywin: Build 219

4

1 回答 1

1

即使在此处和 pyinstaller github 上发布后一周都没有成功,我制定了自己的解决方案。我放弃了 keyring 模块并使用 win32crypt 模块来使用 windows 函数 CryptProtectData,经过一些研究,它使用与 keyring 相同的保护。

我将密码散列到存储在用户 appdata 文件夹中的字符串中,并在需要时对其进行解密。这很好用,并且应该与密钥环方法一样安全,因为它只能从同一用户处解密,重置密码以获取访问权限也不起作用。对我来说足够安全。

当然,这适用于 pyinstaller。

于 2015-11-20T15:44:50.033 回答