1

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

2 Answers 2

3

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.)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your response rici, however it looks I cant use -passin with the rc4 (?) and provide the password through command line
@user3124171: A little more manpage reading would have revealed the answer, but I edited mine anyway: you need to use -pass.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.