LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-20-2009, 08:57 AM   #1
shakeshar
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
exec() echo "password" | cryptsetup


Hi,

Long story short: I used "cryptsetup luksCreate" to encrypt a harddrive. I forgot my password, so i wrote a bruteforce program in c++ to sort it out for me. I only have my codeline left to go.

If i run this as root:

echo "password" | cryptsetup luksOpen /dev/md1 md1

I will pipe the "password" to cryptsetup. How do i do that in c/c++? I have had a look at the exec() functions but i cant manage to get the work done. i tied this:


execlp("/usr/bin/echo","\"password\""," ", "|", " ", "cryptsetup"," ","luksOpen", " ","/dev/md1"," ","md1",0);


but that just echos the whole line to my screen. Any suggestions?

Best regards
Stefan
 
Old 03-20-2009, 09:30 AM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,300
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by shakeshar View Post
Any suggestions?
Try
Code:
    FILE *result = popen(echo "password" | cryptsetup luksOpen /dev/md1 md1);
if you need to parse the result, or
Code:
    int result = system(echo "password" | cryptsetup luksOpen /dev/md1 md1);
if you just want to know if it succeeded or not. Read the man pages for each before going forward.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Supplying "password" to "ssh" command paragkalra Linux - Networking 1 07-31-2008 05:19 AM
No UTMPX entry, You must EXEC "login" for the lowest "shell" ooihc Solaris / OpenSolaris 7 03-12-2007 02:09 PM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 02:14 PM
Can't exec "firefox 1.5", "prompts glibc detected" SPo2 Linux - General 1 06-04-2006 11:02 PM
"cannot exec `as': ..." AND "C compiler cannot create ..." pr3st0 Linux - Software 0 10-15-2004 12:42 PM


All times are GMT -5. The time now is 09:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration