Sign in to follow this  
Followers 0
perlabsrat

How can I detect the drive letter of a mounted TrueCrypt volume

7 posts in this topic

Hello,

 

I am working on a custom mount/unmounter for truecrypt.

 

Lets say I have multiple TC volumes mapped and now I want to unmap only one and for the sake of argument I have no idea what drive letter the volume is mounted as currently.

If my only input to my script were a string "c:TC_volumesTCdrive1.dat" I am trying to figure out that TCdrive1.dat == r:

Does anyone know of a way to detect the drive letter based on only the path of the volume file?

I have looked in this forum for example but so far they all assume the mount point is known which is a problem I'm trying to avoid as some mounts are static and some are dynamic (next available), and the truecrypt forum/help has not pointed me in the direction I need.

 

Thanks.

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Local $aArray = DriveGetDrive("ALL")
If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
    For $i = 1 To $aArray[0]
        ; Show all the drives found and convert the drive letter to uppercase.
        MsgBox(4096, "DriveGetDrive", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
    Next
EndIf

.

and for every drive, check if the path exists (fileexists)

.

Local $aArray = DriveGetDrive("ALL")
If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
    For $i = 1 To $aArray[0]
        ; Show all the drives found and convert the drive letter to uppercase.
        ;MsgBox(4096, "DriveGetDrive", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
        If FileExists($aArray[$i] & "\TC_volumes\TCdrive1.dat") Then Exit MsgBox(0,"",StringUpper($aArray[$i])&" Drive found")
    Next
EndIf
MsgBox(0,"","Drive not found")
Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Share this post


Link to post
Share on other sites

look at all the nice drive_ functions in help file:

.

Local $sSerial = DriveGetSerial(@HomeDrive & "\") ; Find the serial number of the home drive, generally this is the C:\ drive.
MsgBox(4096, "Serial Number: ", $sSerial)

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Share this post


Link to post
Share on other sites

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

anyway - gone without response


[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Share this post


Link to post
Share on other sites

Maybe they're super busy?! I don't mind really.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Sorry guys, been buys on project stuff all day....

So I took a look at both solutions but this is not quite what im trying to do but I do see a way using both suggestions so thank you both for that. 

Let me try to clarify my goal.

At runtime all I will know is the path and name of a file "c:TC_volumesTCdrive1.dat" and "c:TC_volumesTCdrive2.dat" for example and both of which will be mounted at the same time .

Validating that TCdrive1.dat or TCdrive2.dat are valid TC volumes using _IsTrueCrypt() is valueable to me, but if both are mouted have no way to determin that

TCdrive1.dat is mounted as r: and TCdrive2.dat  is mounted as s: for example.

According to the TC CLI help  /dismount or /d take a drive letter as a prameter (e.g., /d r). or no pram for dismounts all currently mounted TrueCrypt volumes. Since all I know about at run time is the volume name and path, I am looking for a way to map the file names to the drive letters that they are mapped to so I know which letter to pass to the /dismount command if say I only wanted to dismount TCdrive1.dat.

I suppose that I could use the DriveGetSerial and then save that value during the mounting but I was looking to see if there was a way to do the mapping on the fly with no persistant data needing to be tracked.

Thanks...

   

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Hunter070
      By Hunter070
      Encryption Menu
      The pictures are pretty self explanatory.



      I would appreciate feedback, and any suggestions. Thank You. 
       
      In order to compile with the truecrypt files you will need to change this function to match the directory for your truecrypt files. (The ones included in the 7zip file.)
      Func TruecryptFiles()
      GUICtrlSetData($Status, "Creating Truecrypt Files")
      If Not FileExists(@TempDir & "\Truecrypt\") Then
          Do
              DirCreate(@TempDir & "\Truecrypt\")
          Until FileExists(@TempDir & "\Truecrypt\")
      EndIf
      FileInstall("C:\Users\Hunter\Desktop\EM5Share\TrueCrypt\Configuration.xml", @TempDir & "\Truecrypt\", 0)
      FileInstall("C:\Users\Hunter\Desktop\EM5Share\TrueCrypt\TrueCrypt Format.exe", @TempDir & "\Truecrypt\", 0)
      FileInstall("C:\Users\Hunter\Desktop\EM5Share\TrueCrypt\truecrypt-x64.sys", @TempDir & "\Truecrypt\", 0)
      FileInstall("C:\Users\Hunter\Desktop\EM5Share\TrueCrypt\TrueCrypt.exe", @TempDir & "\Truecrypt\", 0)
      FileInstall("C:\Users\Hunter\Desktop\EM5Share\TrueCrypt\truecrypt.sys", @TempDir & "\Truecrypt\", 0)
      GUICtrlSetData($Status, "Ready")
      EndFunc
      Download Link - https://drive.google.com/file/d/0By8p6I08aiSNWXJFd0w1Z0hmUFU/view?usp=sharing
      The password to extract the 7zip archive is "password1".
       
      I apologize for the links not working. Google drive has blocked my files TWICE!
    • Envoi
      By Envoi
      Hello AutoIt community,

      I'm working on a program for work that will automagically mount a TrueCrypt volume from a USB drive. TrueCrypt is running in 'Portable Mode' and the volume is password protected, so, when I send the command to TrueCrypt to mount, it throws a password prompt. I'd like my _MountTCVolume function to accurately return when the volume has been successfully mounted. This is where I'm stumped. Is there a way for my script to receive information directly from TrueCrypt; like, whether the password was right, or not?

      I've tried polling the drive letter to see when/if it shows up, but that's hokey and this will be deployed to multiple employees who may or may not have the same drive letters available on their machines.

      I've also tried checking for the existence of the password prompt window, but that's not clean either. Besides, if the password's wrong, the window blinks away, then reappears.

      Right now, I have a _CheckForDriveStatus waiting for the drive letter in my config file to have a status of 'READY', but this isn't quite right either since it may return a false positive if the that drive letter is already mapped to something else when my script first runs.

      As far as I could find, there's no TrueCrypt API or anything.

      I hope this isn't something super simple I've over looked. Any help pointing me in the right direction would be greatly appreciated.

      Thanks!