Question

i have a security problem on a script. I have to pass it a username and password, but i can't give it a password not crypted. This script is writed in bash.

#!/bin/bash
HOST=$1
USER=$2
PASSWORD=$3
#PASSWORD=`perl -e 'print pack "H*",$PASSWORD'`
wget -v $HOST --http-user=$USER --http-password=$PASSWORD --no-check-certificate
......

I have think to use something like this for generate cripted password:

perl -e 'print unpack "H*","yourpassword"'

and something like this for decript it

descrpt=`perl -e 'print pack "H*","encrypted password"'`

but it doesn't work. Someone could help me please?

Was it helpful?

Solution 2

Problem solved with:

echo $password | openssl enc -base64 -d

OTHER TIPS

Your command doesn't encrypt, it merely encodes the password as a hex string. Any programmer who sees the string will immediately know how to get the plaintext password back.

Instead, pass the password to wget in such a way that people can't just grab it from ps output. Here's one way of doing that:

wget -v "$HOST" --http-user="$USER" --no-check-certificate --config=/dev/stdin <<< "http_password = $PASSWORD"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top