2

I have a script copying files using Windows ftp. (Batch file)

The password in there is in clear text. Is it possible to obfuscate or encrypt this password?

As it is a server in a plant I cannot simply install new programs such as WinSCP. I have to try ftp first or tell my superiors it is not possible this way.

(I understand that using ftp is no secure way of copying files, for this sftp has to be used)

1 Answers1

3

What you're trying to do is what I've heard referred to as "security by obscurity"....

You can pass the password in from a process that executes the batch file and lock down that process so no accounts can read from it that have access to that machine and perhaps use EFS for the folder it is in as well if you can or maybe bit locker encrypt the hard drive the script resides.

So in the batch you'd have SET ftpPass=%~1 and then with Task Scheduler or whatever you have locked down that executes it, pass the password in as the first argument as C:\Folder\FTPScript.bat "MyPassword" so in the script they'd only see %ftpPass%.

Batch Script Example

@ECHO ON

SET ftpPass=%~1
SET ftphost=<hostname>
SET ftpusr=<username>
SET ftptmpfile=%temp%\temp_MyFTPJob.ftp
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"


:ftp
ECHO open %ftphost%> %ftptmpfile%
ECHO %ftpusr%>> %ftptmpfile%
ECHO %ftpPass%>> %ftptmpfile%
ECHO prompt                          >> %ftptmpfile%
ECHO binary                          >> %ftptmpfile%
ECHO mput "C\folder\path\*.txt"      >> %ftptmpfile%
ECHO dir                             >> %ftptmpfile%
ECHO bye                             >> %ftptmpfile%
ftp -s:%ftptmpfile%
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"
EXIT

Further Resources

Windows 10: Scheduled tasks with workstation lock/unlock not being triggered