Reputation: 401
I want to execute open-ssl to encrypt many times a file with a wordlist. Everytime I am using:
openssl enc -e -rc4 -in plain -out cipher
enter rc4 encryption password:
and what I want to do is
echo "differentpasswordeverytime" | openssl enc -e -rc4 -in plain -out cipher
I have done the while loop but I cant find a way to parse this into openssl. This should be through STDIN of openssl ?
I found 2 other posts regarding stdin and parsing input but these didnt work.
Cheers
Upvotes: 1
Views: 681
Reputation: 1097
If you want to pipe a variable into a command, you should use echo
but be careful as implementations can vary, and multi-line variables can sometimes be collapsed into a single line.
For me in bash
echo "$variable" | command
worked, and kept multi-line strings.
If you want internal /n
and other escaped characters to be evaluated into newlines you should pass the -e
flag like so:
echo -e "$variable" | command
Upvotes: 0
Reputation: 241711
Quoting from man openssl
(near the end):
PASS PHRASE ARGUMENTS
Several commands accept password arguments, typically using
-passin
and-passout
for input and output passwords respectively. These allow the password to be obtained from a variety of sources. Both of these options take a single argument whose format is described below. If no password argument is given and a password is required then the user is prompted to enter one: this will typically be read from the current terminal with echoing turned off.
That's followed by a list of possible ways of acquiring the password. I would think that the one you want is stdin
, although it might well work out better to use the option for an environment variable. (You'll need to export
the variable for that to work.)
I suggest you read the description carefully, taking account of the security implications. You should also read the manpage for the subcommand you are using (enc
), or at least read through the summary provided if you specify an option it does not understand.
(In enc
, the actual option specified is neither -passin
nor -passout
but rather -pass
.)
Upvotes: 3