security - Obfuscating password in batch script -
i have batch script password sitting in part of command requires credentials not want prompt credentials. not worried external threats, don't want co-worker going in there , seeing password. while trust them not abuse it, i'd rather not have there @ all.
i able pretty powershell storing secure string in text file. pretty basic, @ least there's no plain text passwords laying around. that's need.
how can obfuscate password in batch script?
you hide password in alternate data stream:
first, add secret password alternate data stream of script:
echo somewhatsecretpassword>script.bat:pwd
here's how retrieve password variable %p%
:
for /f "usebackq delims=" %i in (script.bat:pwd) set p=%i
from within batch file may use like:
for /f "usebackq delims=" %%i in (%~0:pwd) set p=%%i
this not secure!
please consider:
- this not secure!
- alternate data streams not copied everywhere (fat)
- passwords containing special characters may need escaped in order written correctly stream
- ... not secure
Comments
Post a Comment