Tuesday, December 22, 2009

FreeOTFE command line

FreeOTFE is a very nice freeware encryption program. It is very similar to the well known TrueCrypt application, but I prefer FreeOTFE since it has a PocketPC version and it's thus more portable.


Like I mentioned in a previous post, I use FreeOTFE in combination with Dropbox. I encrypt a complete portable DropBox folder to make sure all data and account information is kept save whenever I would lose my USB stick. This is possible since FreeOTFE can very easily be used as a portable application and thus perfect for any USB stick.


Since I use my USB stick with portable DropBox and portable Roboform2Go almost every day, I made some small batch scripts to easily start up the FreeOTFE drive and the portable applications within the encrypted volume. So far I have created these scripts:


FreeOTFEAutoLoad.bat: Batch script to mount a volume with a portable FreeOTFE, the volume to mount has to be specified as first parameter when running the script, so for example: FreeOTFEAutoLoad.bat "example.vol"



@echo off
TITLE Auto load FreeOTFE
FreeOTFE\FreeOTFE.exe /portable start /silent
FreeOTFE\FreeOTFE.exe /mount /volume %1%
exit

FreeOTFEStop.bat: Batch script to unmount all volumes that are started using a portable FreeOTFE.



@echo off
TITLE Stop FreeOTFE
:DISMOUNT
FreeOTFE\FreeOTFE.exe /dismount all /silent
IF %ERRORLEVEL% NEQ 0 GOTO DISMOUNTFAILED
GOTO STOPPORTABLE
:STOPPORTABLE
FreeOTFE\FreeOTFE.exe /dismount all /silent /force
FreeOTFE\FreeOTFE.exe /portable stop /silent
GOTO EXIT
:DISMOUNTFAILED
echo Dismount of FreeOTFE failed: %ERRORLEVEL%.
echo Make sure all locks on FreeOTFE disks are removed, then continue this process.
SET INPUT=
set /p INPUT=Press enter to try again, f to force dismount, e to exit.
if /i "%INPUT%" == "f" goto FORCEDISMOUNT
if /i "%INPUT%" == "e" goto EXIT
FreeOTFE\FreeOTFE.exe /dismount all /silent
IF %ERRORLEVEL% NEQ 0 GOTO DISMOUNTFAILED
GOTO STOPPORTABLE
:FORCEDISMOUNT
FreeOTFE\FreeOTFE.exe /dismount all /silent /force
IF %ERRORLEVEL% NEQ 0 GOTO DISMOUNTFAILED
GOTO STOPPORTABLE
:EXIT
exit

FreeOTFE - volume.bat: Batch script to automount a specific volume and launch some script from within the encrypted volume once it is mounted.



@echo on
start "AutoLoad" /wait FreeOTFEAutoLoad.bat "example.vol"

set _Target=NotFound
set _TargetName=REPLACE_THIS_TEXT_WITH_THE_EXACT_NAME_OF_YOUR_MOUNTED_FREEOTFE_VOLUME

for /f usebackq %%a in (`Drives.exe -f %_TargetName%`) do set _Target=%%a

if "%_Target%" == "NotFound" (
echo Unable to find target drive named "%_TargetName%"
goto :EOF
)
pushd %_Target%
%_Target%\SCRIPT_OR_APPLICATION_TO_BE_STARTED_FROM_THE_MOUNTED_VOLUME.bat

When launching FreeOTFE it can take some time to load all cyphers and hashes included, so I created my own archive only including the cypher and hashes I use (the most secure onces). Now FreeOTFE will launch much faster. The application "Drives.exe" is created by Scott Seligman and is used to determine the drive letter based on the name of a volume. The minimal portable FreeOTFE with all scripts above can be downloaded using this link.

No comments:

Post a Comment