问题描述
我不记得我其中一台服务器的密码。我保存了有效的连接,并希望从中获取密码。
来自Remmina常见问题解答:
Q: How are my passwords stored? Are they secure?
A: They are encrypted using 3DES with a 256bit randomly generated key. You should keep your key secure.
那么,我在哪里获取密钥以及密码将存储在哪里?
编辑:确定发现它们只是位于.remmina下的用户主文件夹中。两个私钥都在base64中,解密时我似乎无法正确获取密码……
最佳思路
我能够使用@michaelcochez的Go解决方案通过Python对其进行解密:
import base64
from Crypto.Cipher import DES3
secret = base64.decodestring('<STRING FROM remmina.prefs>')
password = base64.decodestring('<STRING FROM XXXXXXX.remmina>')
print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)
次佳思路
它们存储在Gnome-Keyring中。
破折号->类型”keys”->密码和密钥。
在较新版本的海马(也称为“密码和密钥”)中,必须选择”View”->。 “Show any”查看按键。搜索”remmina”。
第三种思路
我在名为~/.remmina/remmina.prefs
的文件中找到了密钥,加密的密码在~/.remmina/nnnnnnnnnnn.remmina
中。
我写了一个code(在Go中),可用于解密:
//Decrypts obfuscated passwords by Remmina - The GTK+ Remote Desktop Client
//written by Michael Cochez
package main
import (
"crypto/cipher"
"crypto/des"
"encoding/base64"
"fmt"
"log"
)
//set the variables here
var base64secret = "yoursecret"
var base64password = "theconnectionpassword"
//The secret is used for encrypting the passwords. This can typically be found from ~/.remmina/remmina.pref on the line containing 'secret='.
//"The encrypted password used for the connection. This can typically be found from /.remmina/dddddddddddd.remmina " on the line containing 'password='.
//Copy everything after the '=' sign. Also include final '=' signs if they happen to be there.
//returns a function which can be used for decrypting passwords
func makeRemminaDecrypter(base64secret string) func(string) string {
//decode the secret
secret, err := base64.StdEncoding.DecodeString(base64secret)
if err != nil {
log.Fatal("Base 64 decoding failed:", err)
}
if len(secret) != 32 {
log.Fatal("the secret is not 32 bytes long")
}
//the key is the 24 first bits of the secret
key := secret[:24]
//3DES cipher
block, err := des.NewTripleDESCipher(key)
if err != nil {
log.Fatal("Failed creating the 3Des cipher block", err)
}
//the rest of the secret is the iv
iv := secret[24:]
decrypter := cipher.NewCBCDecrypter(block, iv)
return func(encodedEncryptedPassword string) string {
encryptedPassword, err := base64.StdEncoding.DecodeString(encodedEncryptedPassword)
if err != nil {
log.Fatal("Base 64 decoding failed:", err)
}
//in place decryption
decrypter.CryptBlocks(encryptedPassword, encryptedPassword)
return string(encryptedPassword)
}
}
func main() {
if base64secret == "yoursecret" || base64password == "theconnectionpassword" {
log.Fatal("both base64secret and base64password variables must be set")
}
decrypter := makeRemminaDecrypter(base64secret)
fmt.Printf("Passwd : %v\n", decrypter(base64password))
}
该代码可以在线运行,但是您信任golang.org。
第四种思路
我制作了一个脚本,可以自动解密您的密码文件。最新版本为https://github.com/peppelinux/remmina_password_exposer。
#!/usr/bin/python
from Crypto.Cipher import DES3
import base64
import os
import re
from os.path import expanduser
home = expanduser("~")
# costanti :)
REMMINA_FOLDER = os.getenv('REMMINA_FOLDER', home+'/'+'.remmina/')
REMMINA_PREF = 'remmina.pref'
REGEXP_ACCOUNTS = r'[0-9]{13}\.remmina(.swp)?'
REGEXP_PREF = r'remmina.pref'
diz = {}
fs = open(REMMINA_FOLDER+REMMINA_PREF)
fso = fs.readlines()
fs.close()
for i in fso:
if re.findall(r'secret=', i):
r_secret = i[len(r'secret='):][:-1]
print 'found secret', r_secret
for f in os.listdir(REMMINA_FOLDER):
if re.findall(REGEXP_ACCOUNTS, f):
o = open( REMMINA_FOLDER+f, 'r')
fo = o.readlines()
o.close()
for i in fo:
if re.findall(r'password=', i):
r_password = i[len(r'password='):][:-1]
if re.findall(r'^name=', i):
r_name = i.split('=')[1][:-1]
if re.findall(r'username=', i):
r_username = i.split('=')[1][:-1]
#~ print fo
#~ print 'found', f
password = base64.decodestring(r_password)
secret = base64.decodestring(r_secret)
diz[r_name] = DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)
# print the username and password of the last decryption
print r_name, r_username, diz[r_name]