Register
It is currently Fri Aug 22, 2014 9:42 am

TrueCrypt GUI in bash... Found this on the Ubuntu Forums


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sat Jan 06, 2007 4:29 am   

Joined: Mon Sep 18, 2006 1:16 pm
Posts: 27
I was looking around for some zenity examples and found a GUI for truecrypt. i havent tested it yet but there was a screenshot and it looked a lot like the windows gui.


Code:
#!/bin/bash

# TrueCrypt GUI. Written by 454redhawk on Sep 19 2006 in Afghanistan.
######The first option must be selected in addition to your mount options if mounting a FAT volume.#####
# If mounting a USB Device type volume (partition or drive) and you do not know the dev name you can find out by selecting the fdisk option.
#If its an # ext3 truecrypt volume it will say its invalid but this is of no concern as the volume cannot be recognized because its encrypted.


function MNT_UMNT ()
{

ACTION=`zenity --height=340 --width=410 \
         --title="TRUECRYPT GUI" \
         --text="Pick your Function" \
         --list \
         --checklist \
         --column="Pick This" \
         --column="Action" \
         False "Also check this option if MOUNTING a FAT Volume" \
         False "Mount File Type Volume" \
         False "Mount Partition or Disk" \
         False "UnMOUNT ALL" \
         False "View already mounted volumes" \
         False "Create a Truecrypt Volume" \
         False "Format a volume to ext3" \
         False "Run Fdisk -l to see devices"`
         if [ $? = 1 ]; then
            exit
         fi
         if [ "$ACTION" = "UnMOUNT ALL" ]; then
         truecrypt -d
         zenity --info --text="All Volumes Unmounted"
         elif [ "$ACTION" = "Also check this option if MOUNTING a FAT Volume|Mount File Type Volume" ]; then
         SELECT_VOLUME
         elif [ "$ACTION" = "Mount File Type Volume" ]; then
         SELECT_VOLUME
         elif [ "$ACTION" = "Also check this option if MOUNTING a FAT Volume|Mount Partition or Disk" ]; then
         SELECT_DEVICE
         elif [ "$ACTION" = "Mount Partition or Disk" ]; then
         SELECT_DEVICE
         elif [ "$ACTION" = "View already mounted volumes" ]; then
         truecrypt -l | zenity --width=500 --height=100 --text-info --title "Here are the mounted volumes"
         MNT_UMNT
         elif [ "$ACTION" = "Run Fdisk -l to see devices" ]; then
         fdisk -l | zenity --width=600 --height=600 --text-info --title "Here are your devices"
         MNT_UMNT
         elif [ "$ACTION" = "Create a Truecrypt Volume" ]; then
         zenity --info --text="A Terminal is about to open,  when you finish close the window.
         
         Click ok to open the terminal
         "
         xterm -hold -e truecrypt -c
         zenity --info --text="Volume Created Unless you aborted early.

You may now mount and use your volume if you made it FAT. Otherwise you need to format it for ext3"
         MNT_UMNT
         elif [ "$ACTION" = "Format a volume to ext3" ]; then
         FMT
         fi
}


function SELECT_DEVICE ()
{
DEVICE=`zenity --entry --title="Device Select" --text="Select Your disk or partition, Example sda or sda1"`
if [ $? = 1 ]; then
exit
fi
SELECT_MNTPT
}

function SELECT_VOLUME ()
{
TC_VOLUME=`zenity --title="Select a TrueCrypt Volume" --file-selection --filename=/home/`
         if [ $? = 1 ]; then
         exit
         fi
      
         SELECT_MNTPT
}


function SELECT_MNTPT ()
{
MNTPNT=`zenity --title="Select a Mount Point for the TrueCrypt Volume" --file-selection --directory --filename=/media/`

         if [ $? = 1 ]; then
         exit
         fi

MNT
}

function MNT ()
{
if [ "$ACTION" = "Also check this option if MOUNTING a FAT Volume|Mount Partition or Disk" ]; then
      zenity --entry --title="Truecrypt Password" --text="Enter Your Password:" --hide-text | truecrypt -u /dev/$DEVICE $MNTPNT
elif [ "$ACTION" = "Also check this option if MOUNTING a FAT Volume|Mount File Type Volume" ]; then
      zenity --entry --title="Truecrypt Password" --text="Enter Your Password:" --hide-text | truecrypt -u $TC_VOLUME $MNTPNT
elif [ "$ACTION" = "Mount Partition or Disk" ]; then
      zenity --entry --title="Truecrypt Password" --text="Enter Your Password:" --hide-text | truecrypt /dev/$DEVICE $MNTPNT
elif [ "$ACTION" = "Mount File Type Volume" ]; then
      zenity --entry --title="Truecrypt Password" --text="Enter Your Password:" --hide-text | truecrypt $TC_VOLUME $MNTPNT
fi
if [ $? = 1 ]; then
      zenity --error --text="ERROR  Maybe an incorrect password or you tried to mount an unformated ext3 volume"
else
      truecrypt -l | zenity --width=500 --height=100 --text-info --title "Here are the mounted volumes"
fi
exit
}

function FMT ()
{
zenity --question --text="MAKE SURE all volumes are UNmounted.

If a volume IS MOUNTED it will be destroyed.

Any data on the volume to be formatted volume WILL be destroyed.

If you are unsure cancel NOW and check, or else you WILL lose data"
if [ $? = 1 ]; then
zenity --error --text="You were unsure and hit cancel. Use the GUI to view mounted volumes"
MNT_UMNT
fi
if [ $? = 0 ]; then

TYPE=`zenity --height=300 --width=370 \
         --title="What are we formatting?" \
         --text="What are we formatting?" \
         --list \
         --radiolist \
         --column="Pick This" \
         --column="Action" \
         False "DEVICE type volume" \
         False "File type Volume"`
fi
         if [ "$TYPE" = "DEVICE type volume" ]; then
FMT_DEVICE_SYSTEM=`zenity --entry --title="Device Select" --text="Select Your disk or partition to be formatted. Example sda or sda1"`
if [ $? = 1 ]; then
exit
fi
zenity --entry --title="Truecrypt Password" --text="Enter The Password for the selected volume:" --hide-text | truecrypt /dev/$FMT_DEVICE_SYSTEM
if [ $? = 1 ]; then
exit
fi
zenity --info --text="You may be prompted for your SUDO password to format the volume (Close the window when its finished)"
xterm -hold -e sudo mkfs.ext3 /dev/mapper/truecrypt0
zenity --info --text="$FMT_DEVICE_SYSTEM format complete

You may have to log into a SU file manager (Press F2 and type gksudo nautilus) after you mount it and change permissions on the mounted location to your user or group before you can write to it"
truecrypt -d
MNT_UMNT

elif [ "$TYPE" = "File type Volume" ]; then
FMT_FILE_SYSTEM=`zenity --title="Select a TrueCrypt Volume to be formatted" --file-selection`
if [ $? = 1 ]; then
exit
fi
zenity --entry --title="Truecrypt Password" --text="Enter The Password for the selected volume:" --hide-text | truecrypt $FMT_FILE_SYSTEM
if [ $? = 1 ]; then
exit
fi
zenity --info --text="You may be prompted for your SUDO password to format the volume (Close the window when its finished)"
xterm -hold -e sudo mkfs.ext3 /dev/mapper/truecrypt0
zenity --info --text="$FMT_FILE_SYSTEM format complete


You may have to log into a SU file manager (Press F2 and type gksudo nautilus) after you mount it and change permissions on the mounted location to your user or group before you can write to it"
truecrypt -d
MNT_UMNT
fi

}
MNT_UMNT


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP