Basically I am trying to make a program using Java to mount a Truecrypt container. I am basically using this code now to actually do that part:
Where container is obviously the .tc file and password is the password.Code:Process p = Runtime.getRuntime().exec("C:\\\\Program Files\\truecrypt\\truecrypt /s /v "+container+" /p "+password+" /q");
Right now it has the /s command which means its silent - If I put in the wrong password it wont prompt me to enter in a new one. Which is what I want since its basically going to true a few different passwords. I want it to handle all the errors. But If I have the /s it wont give me anything hince the "silence" part of it. But I want it to let me know if it worked or not. If I use /s it does nothing either way. If I dont use it it will work and then do nothing or prompt me with the truecrypt program.
My idea now is to set the drive to a known letter and check if the drive exists or something. But that might take too long when you get to 1 billion checks.
Well I tried a few things:
- Dir
- cd
- chdsk
I finally found one that gave me something close to what I needed and that was "find" lol
Basically I search for a string in "Z:\\" which is the directory I specify the container to mount to. If it returns "File not found" it does not work if it contains something else it worked.
It does work sorta... I did a test run and the password being "hello" it got the correct password but didnt get anything until about 10 passwords later.
...
hello
hell
heloh
heloe
helol
heloo
helo
hel
heohh
heohe
heohl
heoho
Password: heohoCode:try { this.p = Runtime.getRuntime().exec("C:\\\\Program Files\\truecrypt\\truecrypt /s /lz /v G:\\hello.tc /p "+password+" /q"); this.p = Runtime.getRuntime().exec("find \"hello\" Z:\\\\"); this.stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); if(!this.stdError.readLine().equals("File not found - Z:\\\\")) { System.out.println("Password: "+password); System.exit(1); } } catch (IOException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); }
Well I think I found a decent way to do it so I will go ahead and run it. I am moving tonight. So I will be gone for a few days until I get a computer setup.
Later!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks