updated extras/gtomb to latest by parazyd

This commit is contained in:
Jaromil 2016-12-29 17:29:15 +01:00
parent 7b72f07f96
commit 88f5a926f0
3 changed files with 310 additions and 489 deletions

View File

@ -1,11 +1,12 @@
gtomb - A GUI wrapper for Tomb, the crypto undertaker gtomb - A GUI wrapper for Tomb, the crypto undertaker
Copyright (C) 2015 Parazyd <parazyd AT dyne DOT org> Copyright (C) 2015-2016 Parazyd <parazyd@dyne.org>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

View File

@ -11,7 +11,7 @@ list and the script will run it for you. Easy-peasy.
### Random notes ### Random notes
* If you type in your sudo password once correctly, in the next 5 (or whatever your sudoers timeout is) minutes, you can type in the wrong password as well. * If you type in your sudo password once correctly, in the next 5 (or whatever your sudoers timeout is) minutes, you can type in the wrong password as well.
* The function for catching cancellation sometimes fails because of bad ps syntax. No idea why yet. * The function for catching cancellation sometimes fails because of bad ps syntax. (Possibly fixed, needs more testing)
## Dependencies ## Dependencies
* [tomb](https://github.com/dyne/Tomb) (also get tomb's dependencies) * [tomb](https://github.com/dyne/Tomb) (also get tomb's dependencies)
@ -19,8 +19,8 @@ list and the script will run it for you. Easy-peasy.
## TODO ## TODO
* Complete error checking * Complete error checking
* Figure out why ps fails sometimes
* and more stuff * and more stuff
## What you need to do ## What you need to do
* Be patient or help with coding :) * Be patient or help with coding :)
* Request features

View File

@ -1,43 +1,32 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# #
# gtomb - a GUI wrapper for Tomb # Copyright (c) 2015-2016 parazyd
# gtomb is written and maintained by parazyd <parazyd@dyne.org>
# #
# Maintained and written by parazyd <parazyd AT dyne DOT org> # This file is part of gtomb
# https://github.com/parazyd/gtomb
# https://github.com/dyne/Tomb
# #
# gtomb is experimental software. It still does not work completely as # This source code is free software: you can redistribute it and/or modify
# intended and should be used with caution.
#
# {{{ License
# gtomb - A GUI wrapper for Tomb, the crypto undertaker
# Copyright (C) 2015 Parazyd <parazyd AT dyne DOT org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/ # along with this source code. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#set -x ver="0.8"
#set -v TOMBPATH="/usr/local/bin/tomb" # Set this to your tomb executable's path
ver="0.6.2" KDFPATH="/usr/local/bin/" # Set this to the path of your KDF binaries (if you're using them)
TOMBPATH="/usr/bin/tomb" # Set this to your tomb executable's path
KDFPATH="/usr/bin/" # Set this to the path of your KDF binaries (if you're using them)
# The ones below should not need changing # The ones below should not need changing
HEXENC="$KDFPATH/tomb-kdb-hexencode" HEXENC="$KDFPATH/tomb-kdb-hexencode"
GENSALT="$KDFPATH/tomb-kdb-pbkdf2-gensalt" GENSALT="$KDFPATH/tomb-kdb-pbkdf2-gensalt"
GETITER="$KDFPATH/tomb-kdb-pbkdf2-getiter" GETITER="$KDFPATH/tomb-kdb-pbkdf2-getiter"
PBKDF="$KDFPATH/tomb-kdb-pbkdf2" PBKDF="$KDFPATH/tomb-kdb-pbkdf2"
_DD=/bin/dd
# {{{ monmort icon # {{{ monmort icon
MONMORT="/tmp/monmort.png" MONMORT="/tmp/monmort.png"
@ -52,15 +41,19 @@ b2RpZnkAMjAxMS0wMS0xMlQwOTozNDoyNCswMTowMNKiZVMAAAAASUVORK5CYII="
echo -e "$ICONB64" | base64 --decode > $MONMORT echo -e "$ICONB64" | base64 --decode > $MONMORT
# }}} # }}}
function _ { _clean } # I like cleaning :) # {{{ sudo functions
function _sudo {
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
}
# {{{ sudo function
function _sudowrong { function _sudowrong {
if [[ $? == 1 ]]; then [[ $? = 0 ]] || {
sudoassword=$(ask_password "Wrong password. Insert sudo password for user $USER") sudoassword=$(ask_password "Wrong password. Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v echo -e "$sudoassword\n" | sudo -S -v
_sudowrong _sudowrong
fi }
} }
# }}} # }}}
@ -71,7 +64,6 @@ function _zenques {
--question \ --question \
--text="$1" --text="$1"
} }
function _fsel { function _fsel {
zenity \ zenity \
--window-icon="$MONMORT" \ --window-icon="$MONMORT" \
@ -93,6 +85,21 @@ function _zenwarn {
--title="$1" \ --title="$1" \
--text="$2" --text="$2"
} }
function _info {
which notify-send > /dev/null
if [[ $? == "0" ]]; then
_zenotif $*
else
_zeninfo $*
fi
}
function _zenotif {
zenity \
--window-icon="$MONMORT" \
--notification \
--title="$1" \
--text="$2"
}
function _zeninfo { function _zeninfo {
zenity \ zenity \
--window-icon="$MONMORT" \ --window-icon="$MONMORT" \
@ -141,7 +148,6 @@ function _zenentry {
# Wraps around the pinentry command, from the GnuPG project, as it # Wraps around the pinentry command, from the GnuPG project, as it
# provides better security and conveniently use the right toolkit. # provides better security and conveniently use the right toolkit.
ask_password() { ask_password() {
local description="$1" local description="$1"
local title="${2:-Enter tomb password.}" local title="${2:-Enter tomb password.}"
local output local output
@ -299,22 +305,19 @@ function _failure die() {
# {{{ _clean - Clean function, removes sensitive stuff from memory # {{{ _clean - Clean function, removes sensitive stuff from memory
function _clean { function _clean {
echo "Cleaning..." # For debugging.
unset $? unset $?
local rr="$RANDOM" local rr="$RANDOM"
while [[ ${#rr} -lt 500 ]]; do while [[ ${#rr} -lt 500 ]]; do
rr+="$RANDOM" rr+="$RANDOM"
done done
command="$rr"; unset command cmnd="$rr"; unset cmnd
tombname="$rr"; unset tombname tombname="$rr"; unset tombname
tombsize="$rr"; unset tombsize tombsize="$rr"; unset tombsize
keyfile="$rr"; unset keyfile keyfile="$rr"; unset keyfile
sudoassword="$rr"; unset sudoassword sudoassword="$rr"; unset sudoassword
tombtmp=/tmp/tombtmp tombtmp="/tmp/tombtmp"
if [ -f $tombtmp ] if [ -f $tombtmp ]; then
then
dd if=/dev/urandom of=$tombtmp bs=800 count=1 dd if=/dev/urandom of=$tombtmp bs=800 count=1
rm -f $tombtmp rm -f $tombtmp
fi fi
@ -327,7 +330,7 @@ function _clean {
# {{{ _main - Main window # {{{ _main - Main window
function _main { function _main {
_clean _clean
command=`zenity \ cmnd=`zenity \
--window-icon="$MONMORT" \ --window-icon="$MONMORT" \
--title="gtomb" \ --title="gtomb" \
--width=640 \ --width=640 \
@ -353,222 +356,157 @@ function _main {
"engrave" "Generates a QR code of a key to be saved on paper" \ "engrave" "Generates a QR code of a key to be saved on paper" \
"bury" "Hide a key inside a JPEG image" \ "bury" "Hide a key inside a JPEG image" \
"exhume" "Extract a key from a JPEG image"` "exhume" "Extract a key from a JPEG image"`
eval "_$cmnd"
eval "_$command"
} }
# }}} # }}}
# {{{ dig - Dig a new tomb # {{{ dig - Dig a new tomb
function _dig { function _dig {
tombname=`_fsave "Choose where to dig your tomb" "secret.tomb"` tombname=`_fsave "Choose where to dig your tomb" "secret.tomb"`
res=$? res=$?
if [[ -f $tombname ]]; then if [[ -f "$tombname" ]]; then
_zenerr "Error" "This tomb already exists. I am not digging here." _zenerr "Error" "This tomb already exists. I am not digging here."
exec _main exec _main
elif [[ $tombname == "" ]]; then elif [[ -z "$tombname" ]]; then
_zenwarn "Warning" "Try again." _info "gtomb" "Cancelled"
exec _main exec _main
fi fi
case $res in [[ $res = 0 ]] || exec _main
0)
tombsize=`_zenentry "Tomb digging" "Enter the size of your tomb in MiB (min. 10 MiB)" "10"`
tombsize=`_zenentry "Tomb digging" "Enter the size of your tomb in MiB (min. 10 MiB)" "10"`
res=$? res=$?
re='^[0-9]+$' re='^[0-9]+$'
if ! [[ $tombsize =~ $re ]]; then if ! [[ $tombsize =~ $re ]]; then
_zenerr "Error" "Please choose a valid number." _zenerr "Error" "Please choose a valid number."
exec _main exec _main
elif [[ $tombsize == "" ]]; then elif [[ -z $tombsize ]]; then
_zenwarn "Warning" "Try again." _info "gtomb" "Cancelled"
exec _main exec _main
fi fi
case $res in [[ $res = 0 ]] || { _zenwarn "Warning" "Tomb digging canceled." ; exec _main }
0)
$TOMBPATH dig -s $tombsize $tombname | \ "$TOMBPATH" dig -s "$tombsize" "$tombname" | \
_zenprog "Digging new tomb" "Please wait while your tomb is being dug..." & _zenprog "Digging new tomb" "Please wait while your tomb is being dug..." &
PID_ZEN=$(ps -C zenity h -o pid,command | grep "Digging new tomb" | awk '{print $1}') PID_ZEN=$(ps -C zenity h -o pid,command | awk '/Digging new tomb/ {print $1}')
while [ -n "$PID_ZEN" ]; do
while [ "$PID_ZEN" != "" ]; do
PID_ZEN=$(ps h -o pid -p ${PID_ZEN}) PID_ZEN=$(ps h -o pid -p ${PID_ZEN})
PID_DD=$(ps -C dd h -o pid,command | grep "$tombname" | awk '{print $1}') PID_DD=$(ps -C $_DD h -o pid,command | awk -v tombtmp="$tombname" '$0~tombtmp{print $1}')
sleep 1 sleep 1
done done
if [[ "$PID_DD" != "" && "$PID_ZEN" == "" ]]; then [[ -n "$PID_DD" && -z "$PID_ZEN" ]] && {
kill -9 $PID_DD kill -9 $PID_DD
_zenwarn "Warning" "Tomb digging canceled." _zenwarn "Warning" "Tomb digging cancelled."
rm -f $tombname rm -f "$tombname"
exec _main exec _main
fi }
_clean _info "Success" "Your tomb has been dug in $tombname"
_zeninfo "Success" "Your tomb has been dug."
exec _main exec _main
;;
1)
_zenwarn "Warning" "Tomb digging canceled."
exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ forge - Forge a new key # {{{ forge - Forge a new key
function _forge { function _forge {
keyfile=`_fsave "Choose where to forge your key" "secret.tomb.key"` keyfile=`_fsave "Choose where to forge your key" "secret.tomb.key"`
res=$? res=$?
if [[ -f $keyfile ]]; then if [[ -f $keyfile ]]; then
_zenerr "Error" "This key already exists. I am not overwriting." _zenerr "Error" "This key already exists. I am not overwriting."
exec _main exec _main
elif [[ $keyfile == "" ]]; then elif [[ -z $keyfile ]]; then
_zenwarn "Warning" "Try again." _info "gtomb" "Canceled"
exec _main exec _main
fi fi
if [[ -f $HEXENC ]] && [[ -f $GENSALT ]] && [[ -f $GETITER ]] && [[ -f $PBKDF ]]; then
kdf="" kdf=""
kdfiter="" kdfiter=""
if [[ -x $HEXENC ]] && [[ -x $GENSALT ]] && [[ -x $GETITER ]] && [[ -x $PBKDF ]]; then
_zenques "Do you want to use KDF? (Generates passwords armored against dictionary attacks)" _zenques "Do you want to use KDF? (Generates passwords armored against dictionary attacks)"
if [[ $? == "0" ]]; then [[ $? == "0" ]] && {
kdf="--kdf" kdf="--kdf"
kdfiter=`_zenentry "Iterations" "Enter the delay (itertime) in seconds for each time this key is used:" "2"` kdfiter=`_zenentry "Iterations" "Enter the delay (itertime) in seconds for each time \n\
this key is used:" "2"`
re='^[0-9]+$'
if ! [[ $kdfiter =~ $re ]]; then
_zenerr "Error" "Please choose a valid number."
exec _main
elif [[ -z $kdfiter ]]; then
_info "gtomb" "Canceled"
exec _main
fi fi
}
else
_zenotif "gtomb" "KDF binaries not found."
fi fi
case $res in [[ $? = 0 ]] || exec _main
0)
$TOMBPATH forge $keyfile $kdf $kdfiter | \ "$TOMBPATH" forge "$keyfile" "$kdf" "$kdfiter" | \
_zenprog "Forging key" "Please wait while your key is being forged...\n\ _zenprog "Forging key" "Please wait while your key is being forged...\n\
You can move your mouse around and use your computer to speed up the process." & You can move your mouse around and use your computer to speed up the process." &
PID_ZEN=$(ps -C zenity h -o pid,command | grep "Forging key" | awk '{print $1}') PID_ZEN=$(ps -C zenity h -o pid,command | awk '/Forging key/ {print $1}')
while [ -n "$PID_ZEN" ]; do
while [ "$PID_ZEN" != "" ]; do
PID_ZEN=$(ps h -o pid -p ${PID_ZEN}) PID_ZEN=$(ps h -o pid -p ${PID_ZEN})
PID_DD=$(ps -C dd h -o pid,command | grep " if=" | awk '{print $1}') PID_DD=$(ps -C $_DD h -o pid,command | awk '/ if/ {print $1}')
sleep 1 sleep 1
done done
[[ -n "$PID_DD" && -z "$PID_ZEN" ]] && {
if [[ "$PID_DD" != "" && "$PID_ZEN" == "" ]]; then
kill -9 $PID_DD kill -9 $PID_DD
_zenwarn "Warning" "Forging canceled." _zenwarn "Warning" "Forging cancelled."
rm -f $keyfile rm -f $keyfile
exec _main exec _main
fi }
_clean _info "Success" "Your key is now forged in $keyfile"
_zeninfo "Success" "Your key is now forged."
exec _main exec _main
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ lock - Lock a non-locked tomb # {{{ lock - Lock a non-locked tomb
function _lock { function _lock {
tombname=`_fsel "Select a tomb to lock"` tombname=`_fsel "Select a tomb to lock"`
[[ -n $tombname ]] || { _zenotif "gtomb" "Cancelled" ; exec _main }
[[ $? = 0 ]] || exec _main
res=$?
if [[ $tombname == "" ]]; then
_zenwarn "Warning" "Try again."
exec _main
fi
case $res in
0)
keyfile=`_fsel "Choose the key for your tomb"` keyfile=`_fsel "Choose the key for your tomb"`
[[ -n $keyfile ]] || { _zenotif "gtomb" "Cancelled" ; exec _main }
[[ $? = 0 ]] || exec _main
res=$? _sudo
"$TOMBPATH" lock "$tombname" -k "$keyfile" | \
if [[ $keyfile == "" ]]; then
_zenwarn "Warning" "Try again."
exec _main
fi
case $res in
0)
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH lock $tombname -k $keyfile | \
_zenprognc "Locking your tomb" "Please wait while your tomb is being locked..." _zenprognc "Locking your tomb" "Please wait while your tomb is being locked..."
_info "Success" "Your tomb is now locked."
_clean # Clean sensitive stuff from memory
_zeninfo "Success" "Your tomb is now locked."
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ open - Open an existing tomb # {{{ open - Open an existing tomb
function _open { function _open {
tombname=`_fsel "Choose a tomb to open"` tombname=`_fsel "Choose a tomb to open"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
keyfile=`_fsel "Choose the key for your tomb"` keyfile=`_fsel "Choose the key for your tomb"`
[[ $? = 0 ]] || exec _main
res=$? _sudo
case $res in "$TOMBPATH" open "$tombname" -k "$keyfile"
0) _info "Success" "Your tomb is now open."
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH open $tombname -k $keyfile
_clean # Clean sensitive stuff from memory
_zeninfo "Success" "Your tomb is now open."
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ list - list all open tombs, along with their mountpoint # {{{ list - list all open tombs, along with their mountpoint
function _list { function _list {
tombtmp="/tmp/tombtmp" tombtmp="/tmp/tombtmp"
$TOMBPATH list --get-mountpoint > $tombtmp "$TOMBPATH" list --get-mountpoint > $tombtmp
tombname=`cat $tombtmp | \ tombname=`cat $tombtmp | \
sed 's/.*\/\([^\/]*\)$/\1\n &/' | \ sed 's/.*\/\([^\/]*\)$/\1\n &/' | \
zenity \ zenity \
@ -580,9 +518,10 @@ function _list {
--column=Tomb \ --column=Tomb \
--column=Path ` --column=Path `
res=$? tombname=`echo "$tombname" | cut -c1-16`
case $res in
0) [[ $? = 0 ]] || exec _main
listchoice=`zenity \ listchoice=`zenity \
--title="Choose action" \ --title="Choose action" \
--window-icon="$MONMORT" \ --window-icon="$MONMORT" \
@ -598,70 +537,56 @@ function _list {
"binds" "Edit current bind-hooks." \ "binds" "Edit current bind-hooks." \
"posts" "Edit current post-hooks."` "posts" "Edit current post-hooks."`
if [[ $? == 1 ]]; then [[ $? = 0 ]] || exec _main
exec _main
fi
case $listchoice in case $listchoice in
close) close)
sudoassword=$(ask_password "Insert sudo password for user $USER") _sudo
echo -e "$sudoassword\n" | sudo -S -v "$TOMBPATH" close "$tombname"
_sudowrong
$TOMBPATH close $tombname
_zeninfo "Success" "Tomb closed successfully!" _zeninfo "Success" "Tomb closed successfully!"
exec _main exec _main
;; ;;
slam) slam)
sudoassword=$(ask_password "Insert sudo password for user $USER") _sudo
echo -e "$sudoassword\n" | sudo -S -v "$TOMBPATH" slam "$tombname"
_sudowrong _info "Success" "$tombname slammed successfully!"
$TOMBPATH slam $tombname
_zeninfo "Success" "Tomb slammed successfully!"
exec _main exec _main
;; ;;
disindex) disindex)
tombloc=`$TOMBPATH list $tombname --get-mountpoint` tombloc=`"$TOMBPATH" list "$tombname" --get-mountpoint`
touch "$tombloc/.noindex" touch "$tombloc/.noindex"
_zeninfo "Success" "Indexing disabled for this tomb." _info "Success" "Indexing disabled for this tomb."
exec _main exec _main
;; ;;
enindex) enindex)
tombloc=`$TOMBPATH list $tombname --get-mountpoint` tombloc=`"$TOMBPATH" list "$tombname" --get-mountpoint`
rm "$tombloc/.noindex" rm -f "$tombloc/.noindex"
_zeninfo "Success" "Indexing of this tomb is enabled." _info "Success" "Indexing of this tomb is now enabled."
exec _main exec _main
;; ;;
binds) binds)
tombloc=`$TOMBPATH list $tombname --get-mountpoint` tombloc=`"$TOMBPATH" list "$tombname" --get-mountpoint`
bindhooks=`zenity \ bindhooks=`zenity \
--text-info \ --text-info \
--filename="$tombloc/bind-hooks" \ --filename="$tombloc/bind-hooks" \
--editable` --editable`
if [[ $? == "0" ]]; then [[ $? = 0 ]] && {
echo "$bindhooks" > "$tombloc/bind-hooks" echo "$bindhooks" > "$tombloc/bind-hooks"
fi _info "gtomb" "bind-hooks saved"
}
exec _main exec _main
;; ;;
posts) posts)
tombloc=`$TOMBPATH list $tombname --get-mountpoint` tombloc=`"$TOMBPATH" list "$tombname" --get-mountpoint`
posthooks=`zenity \ posthooks=`zenity \
--text-info \ --text-info \
--filename="$tombloc/post-hooks" \ --filename="$tombloc/post-hooks" \
--editable` --editable`
if [[ $? == "0" ]]; then [[ $? = 0 ]] && {
echo "$posthooks" > "$tombloc/post-hooks" echo "$posthooks" > "$tombloc/post-hooks"
chmod +x $tombloc/post-hooks chmod +x "$tombloc/post-hooks"
fi _info "gtomb" "post-hooks saved"
exec _main }
;;
# See what else to add
esac
;;
1)
exec _main exec _main
;; ;;
esac esac
@ -671,7 +596,7 @@ function _list {
# {{{ close - Close open tomb(s) # {{{ close - Close open tomb(s)
function _close { function _close {
tombtmp="/tmp/tombtmp" tombtmp="/tmp/tombtmp"
$TOMBPATH list --get-mountpoint > $tombtmp "$TOMBPATH" list --get-mountpoint > $tombtmp
echo "/all" >> $tombtmp echo "/all" >> $tombtmp
tombname=`cat $tombtmp | \ tombname=`cat $tombtmp | \
sed 's/.*\/\([^\/]*\)$/\1\n &/' | \ sed 's/.*\/\([^\/]*\)$/\1\n &/' | \
@ -683,30 +608,20 @@ function _close {
--column=Tomb \ --column=Tomb \
--column=Path ` --column=Path `
res=$? [[ $? = 0 ]] || exec _main
case $res in
0)
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH close $tombname _sudo
tombname=`echo "$tombname" | cut -c1-16`
_clean # Clean sensitive stuff from memory "$TOMBPATH" close "$tombname"
_zeninfo "Success" "Tomb(s) closed successfully!" _info "Success" "Closed successfully!"
exec _main exec _main
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ slam - Slam open tombs # {{{ slam - Slam open tombs
function _slam { function _slam {
tombtmp="/tmp/tombtmp" tombtmp="/tmp/tombtmp"
$TOMBPATH list --get-mountpoint > $tombtmp "$TOMBPATH" list --get-mountpoint > $tombtmp
echo "/all" >> $tombtmp echo "/all" >> $tombtmp
tombname=`cat $tombtmp | \ tombname=`cat $tombtmp | \
sed 's/.*\/\([^\/]*\)$/\1\n &/' | \ sed 's/.*\/\([^\/]*\)$/\1\n &/' | \
@ -718,237 +633,136 @@ function _slam {
--column=Tomb \ --column=Tomb \
--column=Path ` --column=Path `
res=$? [[ $? = 0 ]] || exec _main
case $res in
0)
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH slam $tombname _sudo
tombname=`echo "$tombname" | cut -c1-16`
_clean # Clean sensitive stuff from memory "$TOMBPATH" slam "$tombname"
_zeninfo "Success" "Tomb(s) slammed successfully!" _info "Success" "Slammed successfully!"
exec _main exec _main
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ resize - Resize an existing *closed* tomb # {{{ resize - Resize an existing *closed* tomb
function _resize { function _resize {
tombname=`_fsel "Choose a tomb to resize"` tombname=`_fsel "Choose a tomb to resize"`
res=$? res=$?
case $res in _zenques "Is your tomb closed?"
0)
[[ $? = 0 ]] || { _zenwarn "gtomb" "Please close the tomb before resizing." ; exec _main }
[[ $res = 0 ]] || exec _main
tombsize=`_zenentry "New tomb size" "Enter the new size of your tomb in MiB. Must be higher than the current size." "100"` tombsize=`_zenentry "New tomb size" "Enter the new size of your tomb in MiB. Must be higher than the current size." "100"`
[[ -n $tombsize ]] || _zenotif "gtomb" "Cancelled"
re='^[0-9]+$'
if ! [[ $tombsize =~ $re ]]; then
_zenerr "Error" "Please choose a valid number."
exec _main
elif [[ -z $tombsize ]]; then
_info "gtomb" "Cancelled"
exec _main
fi
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
keyfile=`_fsel "Choose according keyfile"` keyfile=`_fsel "Choose according keyfile"`
[[ $? = 0 ]] || exec _main
res=$? _sudo
case $res in "$TOMBPATH" resize "$tombname" -s "$tombsize" -k "$keyfile" | \
0)
sudoassword=$(ask_password "Insert sudo password for user $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH resize $tombname -s $tombsize -k $keyfile | \
_zenprognc "Resizing tomb." "Please wait while your tomb is being resized..." _zenprognc "Resizing tomb." "Please wait while your tomb is being resized..."
_info "Success" "Tomb resized successfully!"
_clean # Clean sensitive stuff from memory
_zeninfo "Success" "Tomb resized successfully!"
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ passwd - Change existing key's passphrase # {{{ passwd - Change existing key's passphrase
function _passwd { function _passwd {
keyfile=`_fsel "Choose a keyfile"` keyfile=`_fsel "Choose a keyfile"`
[[ $? = 0 ]] || exec _main
res=$? "$TOMBPATH" passwd -k "$keyfile" | \
case $res in
0)
$TOMBPATH passwd -k $keyfile | \
_zenprognc "Changing passphrase" "Please wait while your key's passphrase is being changed..." _zenprognc "Changing passphrase" "Please wait while your key's passphrase is being changed..."
_clean # Clean sensitive stuff from memory _info "Success" "$keyfile passphrase changed successfully!"
_zeninfo "Success" "Passphrase changed successfully!"
exec _main exec _main
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ setkey - Change a tomb's keyfile # {{{ setkey - Change a tomb's keyfile
function _setkey { function _setkey {
tombname=`_fsel "Choose a tomb to change its keyfile"` tombname=`_fsel "Choose a tomb to change its keyfile"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
keyfile=`_fsel "Chosse your tomb's old keyfile"` keyfile=`_fsel "Chosse your tomb's old keyfile"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
newkey=`_fsel "Choose your tomb's new keyfile"` newkey=`_fsel "Choose your tomb's new keyfile"`
[[ $? = 0 ]] || exec _main
res=$? _sudo
case $res in "$TOMBPATH" setkey -k "$newkey" "$keyfile" "$tombname" | \
0)
sudoassword=$(ask_password "Insert sudo password for $USER")
echo -e "$sudoassword\n" | sudo -S -v
_sudowrong
$TOMBPATH setkey -k $newkey $keyfile $tombname | \
_zenprognc "Changing key" "Please wait while your tomb's key is being changed..." _zenprognc "Changing key" "Please wait while your tomb's key is being changed..."
_clean _info "Success" "$tombname keyfile successfully changed! Now using $newkey"
_zeninfo "Success" "Tomb's keyfile successfully changed!"
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ engrave - generate QR code of a key # {{{ engrave - generate QR code of a key
function _engrave { function _engrave {
which qrencode || _zenwarn "Warning" "qrencode is not installed. Install it and try again" && exec _main which qrencode || _zenwarn "Warning" "qrencode is not installed. Install it and try again"
keyfile=`_fsel "Choose a keyfile to engrave"` keyfile=`_fsel "Choose a keyfile to engrave"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
jpegfile=`_fsave "Choose where to save your keyfile (PNG format)"` jpegfile=`_fsave "Choose where to save your keyfile (PNG format)"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
awk '/^-----/ {next}; /^Version/ {next}; {print $0}' $keyfile \ awk '/^-----/ {next}; /^Version/ {next}; {print $0}' $keyfile \
| qrencode --size 4 --level H --casesensitive -o $jpegfile | qrencode --size 4 --level H --casesensitive -o $jpegfile
_zeninfo "Success" "QR code generated in $jpegfile" _info "Success" "QR code generated in $jpegfile"
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ bury - hide a keyfile in a JPEG image # {{{ bury - hide a keyfile in a JPEG image
function _bury { function _bury {
which steghide || _zenwarn "Warning" "steghide is not installed. Install it and try again" && exec _main which steghide || _zenwarn "Warning" "steghide is not installed. Install it and try again"
keyfile=`_fsel "Choose keyfile"` keyfile=`_fsel "Choose keyfile"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
jpegfile=`_fsel "Choose JPEG file"` jpegfile=`_fsel "Choose JPEG file"`
[[ $? = 0 ]] || exec _main
res=$? "$TOMBPATH" bury -k "$keyfile" "$jpegfile"
case $res in _info "Success" "Your key is now hidden in $jpegfile"
0)
$TOMBPATH bury -k $keyfile $jpegfile
_zeninfo "Success" "Your key is now hidden in $jpegfile"
_clean # Clean sensitive stuff from memory
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ exhume - extract keyfile from JPEG # {{{ exhume - extract keyfile from JPEG
function _exhume { function _exhume {
which steghide || _zenwarn "Warning" "steghide is not installed. Install it and try again" && exec _main which steghide || _zenwarn "Warning" "steghide is not installed. Install it and try again"
jpegfile=`_fsel "Choose JPEG file"` jpegfile=`_fsel "Choose JPEG file"`
[[ $? = 0 ]] || exec _main
res=$?
case $res in
0)
keyfile=`_fsave "Choose where to extract your key"` keyfile=`_fsave "Choose where to extract your key"`
[[ $? = 0 ]] || exec _main
res=$? "$TOMBPATH" exhume -k "$keyfile" "$jpegfile"
case $res in _info "Success" "Your keyfile is extracted to $keyfile"
0)
$TOMBPATH exhume -k $keyfile $jpegfile
_zeninfo "Success" "Your keyfile is extracted to $keyfile"
_clean # Clean sensitive stuff from memory
exec _main exec _main
;;
1)
exec _main
;;
esac
;;
1)
exec _main
;;
esac
} }
# }}} # }}}
# {{{ index - index the contents of open tombs # {{{ index - index the contents of open tombs
function _index { function _index {
which mlocate || _zenwarn "Warning" "mlocate is not installed. Install it and try again" && exec _main which locate || _zenwarn "Warning" "mlocate is not installed. Install it and try again"
"$TOMBPATH" index | _zenprognc "Indexing" "Please wait while the open tombs are being indexed..."
$TOMBPATH index | _zenprognc "Indexing" "Please wait while the open tombs are being indexed..." _info "Success" "Tombs indexed!"
_zeninfo "Success" "Tombs indexed!"
exec _main exec _main
} }
# }}} # }}}
@ -956,30 +770,36 @@ function _index {
# {{{ search - searches the contents of indexed tombs # {{{ search - searches the contents of indexed tombs
function _search { function _search {
strings="" strings=""
_searchstring
exec _main
}
function _searchstring { function _searchstring {
srchstring=`_zenentry "Search" "Enter an argument to search. Cancel to finish."` srchstring=`_zenentry "Search" "Enter an argument to search. Cancel to finish."`
res=$? res=$?
strings="$strings $srchstring" strings="$strings $srchstring"
if [[ $res == "1" ]]; then if [[ $res = 1 ]]; then
tombtmp="/tmp/tombtmp" tombtmp="/tmp/tombtmp"
$TOMBPATH search $strings > $tombtmp _info "Success" "Search complete!"
#cat $tombtmp | \ "$TOMBPATH" search "$strings" > $tombtmp
zenity \ zenity \
--text-info \ --text-info \
--width=800 --height=640 \
--title="Search results" \ --title="Search results" \
--filename=$tombtmp --filename=$tombtmp
else else
_searchstring _searchstring
fi fi
} }
_searchstring
}
# }}} # }}}
if [ ! -f $TOMBPATH ]; then function _ { _clean } # I like cleaning :)
_zenwarn "Warning" "Tomb binary is nonexistent in the current path. Install it or edit the script to point to the correct path."
else [[ -x $TOMBPATH ]] || {
_zenwarn "Warning" "Tomb binary is not executable or doesn't exist in the current path. Install it or edit the script to point to the correct path."
exit 1 }
_main _main
fi