48

I don't remember my password for one of my servers. I have a working connection saved and want to get the password from it.

From Remmina faq:

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.

So where do I get the key and where would the passwords be stored?

EDIT: Ok found that they are just in your users home folder under .remmina. both the private key are in base64 and i can't seem to get the password right when decrypting......

0

10 Answers 10

60

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)
7
  • 6
    For reasons that make me hate myself I needed a one-liner :/ : python -c "import base64,sys;from Crypto.Cipher import DES3;pc=open('/home/admalledd/.remmina/remmina.pref').read();pci=pc.index('secret=');secret=pc[pci:pc.index('\n',pci)].split('=',1)[1];cc=open(sys.argv[1]).read();cci=cc.index('password');password=cc[cci:cc.index('\n',cci)].split('=',1)[1];secret,password=base64.decodestring(secret),base64.decodestring(password); print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)" .remmina/1474332312568.remmina. Left here for the next time I might need it.
    – admalledd
    Dec 17, 2016 at 1:46
  • Nice one.. Works just fine
    – user169015
    Feb 23, 2017 at 6:57
  • 5
    The latest version of remmina has changed the location of these files. The pref file is now at: $HOME/.config/remmina/ and the connection file is listed at the bottom in remmina when you click on the connection (for example: ~/.local/share/remmina/4823893432523.remmina)
    – Ring
    Sep 8, 2017 at 16:28
  • 3
    Thank you past self, slightly updated one-liner that takes two args for the files. python -c "import base64,sys;from Crypto.Cipher import DES3;pc=open(sys.argv[1]).read();pci=pc.index('secret=');secret=pc[pci:pc.index('\n',pci)].split('=',1)[1];cc=open(sys.argv[2]).read();cci=cc.index('password');password=cc[cci:cc.index('\n',cci)].split('=',1)[1];secret,password=base64.decodestring(secret),base64.decodestring(password); print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)" /tmp/remmina/remmina.pref /tmp/remmina/00000000000.remmina
    – admalledd
    Mar 10, 2018 at 1:32
  • @admalledd You really should post that as an answer!
    – Michael
    Nov 21, 2018 at 0:50
45

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".

5
  • 1
    tried that already..... also i'm using lxde
    – linuxnewb
    May 5, 2013 at 10:21
  • 3
    This is true in some cases. Try this if the password listed in ~/.remmina/nnnnnnnnnnn.remmina is just ..
    – Kupiakos
    Apr 27, 2015 at 15:05
  • 1
    This worked for me on Ubuntu 18.04LTS
    – Chris
    Oct 30, 2020 at 15:25
  • 1
    FYI, the GUI to access the keyring can be launched by running seahorse from the terminal.
    – Jeff Ward
    Feb 2, 2021 at 18:08
  • It works for me - thanks Apr 12, 2021 at 9:01
20

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.

13

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]
1
  • sudo pip3 install --upgrade pycrypto python3 remmina_password_exposer.py Jan 31, 2020 at 23:55
6

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
1
  • 3
    This should be accepted the answer. Thank you very very much!
    – le hien
    Sep 8, 2021 at 2:02
2

I created a perl script to decode remmina passwords. It extract your key and decode all your saved passwords (locally).

https://github.com/lepe/scripts/blob/master/decode_remmina.pl (check for updated version)

#!/usr/bin/perl

use strict;
use warnings;
use Crypt::CBC; #Crypt::DES_EDE3
use MIME::Base64;
use File::Slurp;

my $remmina_dir = $ENV{"HOME"} . "/.remmina";
my $remmina_cfg = $remmina_dir . "/remmina.pref";

my $content = read_file($remmina_cfg);
if($content) {
    my ($secret) = $content =~ /^secret=(.*)/m;
    if($secret) {
        my $secret_bin = decode_base64($secret);
        my ($key, $iv) = ( $secret_bin =~ /.{0,24}/gs );
        my @files = <$remmina_dir/*.remmina>;

        my $des = Crypt::CBC->new( 
                -cipher=>'DES_EDE3', 
                -key=>$key, 
                -iv=>$iv,
                -header=>'none', 
                -literal_key=>1,
                -padding=>'null'
        ); 
        if(@files > 0) {
            foreach my $file (@files) {
                my $config = read_file($file);
                my ($password) = $config =~ /^password=(.*)/m;
                my ($name) = $config =~ /^name=(.*)/m;
                my ($host) = $config =~ /^server=(.*)/m;
                my ($user) = $config =~ /^username=(.*)/m;
                my $pass_bin = decode_base64($password);
                my $pass_plain = $des->decrypt( $pass_bin );
                if($pass_plain) {
                    print "$name    $host   $user   $pass_plain\n";
                }
            }
        } else {
            print "Unable to find *.remmina files \n";
        }
    } else {
        print "No secret key found...\n";
    }
} else {
    print "Unable to read content from remmina.pref\n";
}

You will need to install these packages (for example, using cpan <PACKAGE>): Crypt::CBC, Crypt::DES_EDE3, MIME::Base64, File::Slurp

Sample output:

(Name, host, user, password: tab separated)

Server1 192.168.1.25    administrator   jM822Azss2fake
Server2 192.168.1.88:2899   admin   JaxHaxFakez90
1

I needed to do the reverse and encrypt passwords for Remmina using a Python script. In case anyone needs it here's the code:

import base64    
from Crypto.Cipher import DES3

REMMINAPREF_SECRET_B64=b'G5XKhImmX+3MaRAWU920B31AtQLDcWEq+Geq4L+7sES='

def encryptRemminaPass(plain):
    plain = plain.encode('utf-8')
    secret = base64.b64decode(REMMINAPREF_SECRET_B64)
    key = secret[:24]
    iv = secret[24:]
    plain = plain + b"\0" * (8 - len(plain) % 8)
    cipher = DES3.new(key, DES3.MODE_CBC, iv)
    result = cipher.encrypt(plain)
    result = base64.b64encode(result)
    result = result.decode('utf-8')
    return result
1

You can use "seahorse" GUI for gnome-keyring to view & copy passwords from Remmina. Easy & Fast.

0

Here is the code to go from key to password

key is in: ~/.config/remmina/remmina.pref Password hash is in: ~/.local/share/remmina/*.remmina

To run, save as .py file replace 'key' and 'passw' fields and run python3 *.py

#!/usr/bin/env python3

import base64    
from Crypto.Cipher import DES3

REMMINAPREF_SECRET_B64=b'KEY FROM REMMINA PREFS'

print ("Place Secret up and pasword below")

passw = "ENCRYPTED PASSSWORD"
passw = base64.b64decode(passw)
secret = base64.b64decode(REMMINAPREF_SECRET_B64)
key = secret[:24]
iv = secret[24:]
cipher = DES3.new(key, DES3.MODE_CBC, iv)
result = cipher.decrypt(passw)
result = result.decode('utf-8')
print (result)
0

BASH VERSION

Get secret from remmina.pref, which is in ~/.config/remmina

s=`sed -n 's/^secret=//p' remmina.pref|base64 -d|hexdump -ve '/1 "%02x"'`

Decrypt:

echo CRYPTEDPW|openssl des3 -d -a -nopad -K ${s:0:48} -iv ${s:48}|tr -d "\0"

Encrypt (alternative to remmina --encrypt-password):

pw="PASSWORD"
pad=`printf "%*s" $[8-${#pw}%8] ""`
printf "$pw${pad// /\\0}"|openssl des3 -a -nopad -K ${s:0:48} -iv ${s:48}

Note, that the string padding during encrypting/decrypting is different between remmina and openssl. That's why -nopad option and the manual padding are needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.