How to extract saved password from Remmina?

Solution 1:

I was able to use the Go solution by @michaelcochez to decrypt it with 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)

Solution 2:

They are stored in Gnome-Keyring.

Dash->type "keys"->Passwords&Keys.

In newer versions of seahorse (a.k.a. "Passwords and Keys") one has to select "View" -> "Show any" to see the keys. Search for "remmina".

Solution 3:

I found the key in a file called ~/.remmina/remmina.prefs and the encrypted passwords are in ~/.remmina/nnnnnnnnnnn.remmina.

I wrote a code (in Go) which can be used for decryption:

//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))

}

The code can be run online, but then you are trusting golang.org.

Solution 4:

I made a script that automatically decrypt your password files. The most recent version is at 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]

Solution 5:

Remmina (1.3.3) store passwords thanks to libsecret, the libsecret-tools package can help you retrieve the stored password.

I was looking for the password of a Windows RDP connection with user password saved; I finnaly found the password with the command

secret-tool search key password