문제

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?

도움이 되었습니까?

해결책 2

Problem solved with:

echo $password | openssl enc -base64 -d

다른 팁

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"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top