r_st::

Šifrovaná bitcoin peněženka

Vydal r_st před 8 měsíci v kategorii tučňáci a jiná havěť

Jak si na svém *NIXovém systému zabezpečit svůj soubor wallet.dat, ve kterém jsou uloženy všechny vaše bitcoiny?

Naši peněženku si zašifrujeme a budeme ji rozšifrovávat, jenom, když budeme spuštět bitcoin klienta. Jediné, co potřebujeme, je openssl, kdialog (případně cokoliv, co se nás umí zeptat na heslo) a pár minut času.

Nejprve si vytvoříme klíč, kterým budeme naši peněženku šifrovat: $ dd if=/dev/urandom of=keyfile bs=512 count=4

Tím zašifrujeme soubor wallet.dat:

$ openssl enc -aes-256-cbc -salt -in wallet.dat -out wallet.dat.enc -pass file:keyfile

Takto by ale soubor mohl dešifrovat každý, kdo má přístup k souboru s klíčem, proto si i klíč zašifrujeme naším tajným heslem.

$ openssl enc -aes-256-cbc -salt -in keyfile -out keyfile.enc -pass pass:tajneheslo

Nyní můžeme wallet.dat a keyfile smazat (nebo raději někam bezpečně zazálohovat :-)). Klíči nastavíme práva jen pro čtení vlastníkem, peněžence povolíme i zápis. $ chmod 400 keyfile.enc $ chmod 600 wallet.dat.enc

Nakonec si uložíme následující skript někam do $PATH, pomocí kterého budeme klienta spouštět.

<code>
!/bin/bash
## Wrapper that decrypts your bitcoin wallet with a keyfile on bitcoin client startup and encrypts it on shutdown
##
## (c) Robert Štětka <robert.stetka (at) gmail.com> 2011
## Licensed under the MIT License
## http://www.opensource.org/licenses/mit-license.php
##
## Usage:
## 1. Create random keyfile
## 2. Encrypt wallet.dat with keyfile and then encrypt the keyfile with secret password (see line 49)
## 3. Now you can delete wallet.dat and keyfile and restrict permissions to the encrypted ones
## 4. Put this script to your $PATH, grant execution rights and run it instead your bitcoin client
##

dialog="kdialog"
keyfile="${HOME}/.bitcoin/keyfile"
enckeyfile="${keyfile}.enc"
wallet="${HOME}/.bitcoin/wallet.dat"
encwallet="${wallet}.enc"

if [ ! -r ${enckeyfile} ]; then
${dialog} --error "Keyfile not found!"
exit 1
fi

if [ ! -r ${encwallet} ]; then
${dialog} --error "Wallet not found!"
exit 1
fi

keyPass=$(${dialog} --password "Insert your bitcoin wallet passphrase")

openssl enc -d -aes-256-cbc -in ${enckeyfile} -out ${keyfile} -pass pass:$keyPass
res=$?
unset keyPass
chmod 400 ${keyfile}

if [ ${res} -eq 0 ]; then
openssl enc -d -aes-256-cbc -in ${encwallet} -out ${wallet} -pass file:${keyfile}

if [ $? -eq 1 ]; then
${dialog} --error "Decrypting failed!"
exit 1
fi

chmod 600 ${wallet}

bitcoin $1
openssl enc -aes-256-cbc -salt -in ${wallet} -out ${encwallet} -pass file:${keyfile}

rm ${wallet}
else
${dialog} --error "Wrong password!"
exit 1
fi

rm ${keyfile}

exit 0
</code>

Barevná verze na Pastebin.com

Upozornění: Za případné poškození nebo ztrátu vaší peněženky neručím :-)

Pokud mi chcete poslat pár bitcoinů, tady je adresa: 18yoPKJoKP14qThbXbYs­sh6Jx6RjqwbvSW


Zatím nebyly napsány žádné komentáře

 
  • Povolené tagy jsou a, code, em, p, pre a strong
  • Mužete taky použít Texy syntaxi
  • Na ostatní komentáře odkazujte pomocí [], např. [1]