Using expect to try a series of passwords
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm completely new to using "expect" and clearly don't understand it at all well. My problem is that I used "encfs" to protect some files a while ago, and although I left myself a text file which included obfuscated hints about the password, I'm failing to remember/guess it. So, I'm pretty sure that it's one of a series of perhaps a hundred permutations, and I thought it would be easy to use expect to try them for me. So far, no luck there either!
I think expect has a scripting language, but I don't see where it's defined (and I was hoping not to learn an entire programming language just for this!)
Anyway, I created this script by copy-guess-and-fiddle:
#!/usr/bin/expect
set password [lindex $argv 0]
spawn echo Trying $password
spawn /usr/bin/encfs /home/simon/.safe /home/simon/safe
expect "Password: "
send "$passwordr";
interact
Which tests a single password and seems to work when I use it on a newly created encfs system. However, then I tried to run it over all the permutations, which I've created in a file called "tries". I did this using another script:
#!/bin/bash
while read line
do
echo trying $line
# ./breakone.sh "$line"
echo Status is $?
done < tries
(the first file is called "breakone.sh")
If I run the script in the form shown, it iterates over the lines of text in the file "tries". But if I uncomment the call to the expect script, it immediately drops out after entering the expect script the first time. Furthermore, it drops out immediately. Normally, expect will take a short pause (~ 1/2 second, maybe) and report that the password is bad. But when triggered from the primary script, it drops back to the calling script immediately (I know it comes back to the caller, as it prints the status, and the iteration immediately quits.
I'm guessing this is somehow because expect has "taken over" standard input to the point that the while loop no longer reads from the file, but I have no clue where to go next.
Any suggestions would be most welcome!
(Edit, I tried changing from reading the file to using a here-document, but that didn't change anything).
expect
add a comment |
I'm completely new to using "expect" and clearly don't understand it at all well. My problem is that I used "encfs" to protect some files a while ago, and although I left myself a text file which included obfuscated hints about the password, I'm failing to remember/guess it. So, I'm pretty sure that it's one of a series of perhaps a hundred permutations, and I thought it would be easy to use expect to try them for me. So far, no luck there either!
I think expect has a scripting language, but I don't see where it's defined (and I was hoping not to learn an entire programming language just for this!)
Anyway, I created this script by copy-guess-and-fiddle:
#!/usr/bin/expect
set password [lindex $argv 0]
spawn echo Trying $password
spawn /usr/bin/encfs /home/simon/.safe /home/simon/safe
expect "Password: "
send "$passwordr";
interact
Which tests a single password and seems to work when I use it on a newly created encfs system. However, then I tried to run it over all the permutations, which I've created in a file called "tries". I did this using another script:
#!/bin/bash
while read line
do
echo trying $line
# ./breakone.sh "$line"
echo Status is $?
done < tries
(the first file is called "breakone.sh")
If I run the script in the form shown, it iterates over the lines of text in the file "tries". But if I uncomment the call to the expect script, it immediately drops out after entering the expect script the first time. Furthermore, it drops out immediately. Normally, expect will take a short pause (~ 1/2 second, maybe) and report that the password is bad. But when triggered from the primary script, it drops back to the calling script immediately (I know it comes back to the caller, as it prints the status, and the iteration immediately quits.
I'm guessing this is somehow because expect has "taken over" standard input to the point that the while loop no longer reads from the file, but I have no clue where to go next.
Any suggestions would be most welcome!
(Edit, I tried changing from reading the file to using a here-document, but that didn't change anything).
expect
add a comment |
I'm completely new to using "expect" and clearly don't understand it at all well. My problem is that I used "encfs" to protect some files a while ago, and although I left myself a text file which included obfuscated hints about the password, I'm failing to remember/guess it. So, I'm pretty sure that it's one of a series of perhaps a hundred permutations, and I thought it would be easy to use expect to try them for me. So far, no luck there either!
I think expect has a scripting language, but I don't see where it's defined (and I was hoping not to learn an entire programming language just for this!)
Anyway, I created this script by copy-guess-and-fiddle:
#!/usr/bin/expect
set password [lindex $argv 0]
spawn echo Trying $password
spawn /usr/bin/encfs /home/simon/.safe /home/simon/safe
expect "Password: "
send "$passwordr";
interact
Which tests a single password and seems to work when I use it on a newly created encfs system. However, then I tried to run it over all the permutations, which I've created in a file called "tries". I did this using another script:
#!/bin/bash
while read line
do
echo trying $line
# ./breakone.sh "$line"
echo Status is $?
done < tries
(the first file is called "breakone.sh")
If I run the script in the form shown, it iterates over the lines of text in the file "tries". But if I uncomment the call to the expect script, it immediately drops out after entering the expect script the first time. Furthermore, it drops out immediately. Normally, expect will take a short pause (~ 1/2 second, maybe) and report that the password is bad. But when triggered from the primary script, it drops back to the calling script immediately (I know it comes back to the caller, as it prints the status, and the iteration immediately quits.
I'm guessing this is somehow because expect has "taken over" standard input to the point that the while loop no longer reads from the file, but I have no clue where to go next.
Any suggestions would be most welcome!
(Edit, I tried changing from reading the file to using a here-document, but that didn't change anything).
expect
I'm completely new to using "expect" and clearly don't understand it at all well. My problem is that I used "encfs" to protect some files a while ago, and although I left myself a text file which included obfuscated hints about the password, I'm failing to remember/guess it. So, I'm pretty sure that it's one of a series of perhaps a hundred permutations, and I thought it would be easy to use expect to try them for me. So far, no luck there either!
I think expect has a scripting language, but I don't see where it's defined (and I was hoping not to learn an entire programming language just for this!)
Anyway, I created this script by copy-guess-and-fiddle:
#!/usr/bin/expect
set password [lindex $argv 0]
spawn echo Trying $password
spawn /usr/bin/encfs /home/simon/.safe /home/simon/safe
expect "Password: "
send "$passwordr";
interact
Which tests a single password and seems to work when I use it on a newly created encfs system. However, then I tried to run it over all the permutations, which I've created in a file called "tries". I did this using another script:
#!/bin/bash
while read line
do
echo trying $line
# ./breakone.sh "$line"
echo Status is $?
done < tries
(the first file is called "breakone.sh")
If I run the script in the form shown, it iterates over the lines of text in the file "tries". But if I uncomment the call to the expect script, it immediately drops out after entering the expect script the first time. Furthermore, it drops out immediately. Normally, expect will take a short pause (~ 1/2 second, maybe) and report that the password is bad. But when triggered from the primary script, it drops back to the calling script immediately (I know it comes back to the caller, as it prints the status, and the iteration immediately quits.
I'm guessing this is somehow because expect has "taken over" standard input to the point that the while loop no longer reads from the file, but I have no clue where to go next.
Any suggestions would be most welcome!
(Edit, I tried changing from reading the file to using a here-document, but that didn't change anything).
expect
expect
asked Feb 10 at 15:42
Toby EggittToby Eggitt
1074
1074
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
A quick fix is to use a different file descriptor for the while read loop:
while read line <&3
do
echo trying $line
./breakone.sh "$line"
echo Status is $?
done 3< tries
That leaves the default stdin alone
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404163%2fusing-expect-to-try-a-series-of-passwords%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A quick fix is to use a different file descriptor for the while read loop:
while read line <&3
do
echo trying $line
./breakone.sh "$line"
echo Status is $?
done 3< tries
That leaves the default stdin alone
add a comment |
A quick fix is to use a different file descriptor for the while read loop:
while read line <&3
do
echo trying $line
./breakone.sh "$line"
echo Status is $?
done 3< tries
That leaves the default stdin alone
add a comment |
A quick fix is to use a different file descriptor for the while read loop:
while read line <&3
do
echo trying $line
./breakone.sh "$line"
echo Status is $?
done 3< tries
That leaves the default stdin alone
A quick fix is to use a different file descriptor for the while read loop:
while read line <&3
do
echo trying $line
./breakone.sh "$line"
echo Status is $?
done 3< tries
That leaves the default stdin alone
answered Feb 11 at 14:12
glenn jackmanglenn jackman
16.4k32646
16.4k32646
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404163%2fusing-expect-to-try-a-series-of-passwords%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown