2015-07-13 21:57:01 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from Crypto.Hash import MD5
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
from base64 import b64decode
|
|
|
|
from requests import get
|
|
|
|
from socket import gethostname
|
2015-07-14 20:01:41 +00:00
|
|
|
from tempfile import mkstemp
|
|
|
|
import os
|
2015-07-13 21:57:01 +00:00
|
|
|
|
|
|
|
key = MD5.new(gethostname()).digest()
|
|
|
|
cipher = AES.new(key, AES.MODE_ECB)
|
|
|
|
base64enc = get("http://{{ serverfqdn }}:3000/vaultpass")
|
2015-07-13 23:06:00 +00:00
|
|
|
encrypted = b64decode(base64enc.content)
|
2015-07-13 21:57:01 +00:00
|
|
|
longpass = cipher.decrypt(encrypted)
|
|
|
|
|
2015-07-14 20:01:41 +00:00
|
|
|
fd, filename = mkstemp()
|
|
|
|
with open(filename, 'w+') as f:
|
|
|
|
f.write(longpass.strip('x'))
|
|
|
|
os.close(fd)
|
|
|
|
|
|
|
|
print(filename)
|