Topic "Protect credentials in VBScript"

Author Message
Templar
[View user's profile]

Joined: 2017-07-26
Posts: 3
Hello,

I would like to protect credentials using encryption in a similar way to what is explained here:

https://winscp.net/eng/docs/guide_protecting_credentials_for_automation#fn2

... but for VBS.

Guidance would be very welcome.

Thanks.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
That article shows several techniques. Do you have any particular one in mind?

You point to a footnote, which does not seem relevant to your question.
Templar
[View user's profile]

Joined: 2017-07-26
Posts: 3
Sorry, I should have pointed to the full page:
https://winscp.net/eng/docs/guide_protecting_credentials_for_automation

The page shows how to store encrypted passwords in xml and the use them as secure password e.g. in Powershell with
$sessionOptions.SecurePassword = ConvertTo-SecureString $config.Configuration.Password

I am bound to use VBS and would like to do something similar to avoid storing plain clear text password in a config file.

Hope this makes my point clearer.

Many thanks for your help.
Templar
[View user's profile]

Joined: 2017-07-26
Posts: 3
I cannot run powershell scripts on my machine, but maybe I could circumvent the problem by using powershell command line.
Here is what I tried:
Code:

<job>
<reference object="WinSCP.Session" />
<script language="VBScript">
Dim  key, cmd, Shell, executor, seckey

key = "ABCABCABC....."
cmd = "powershell.exe ConvertTo-SecureString "& key
Set shell = CreateObject("WScript.Shell")
Set executor = shell.Exec(cmd)
executor.StdIn.Close
seckey = executor.StdOut.ReadAll
sessionOptions.SecurePassword = seckey
...
 

but I get an error stating something like "SecurePassword incorrect argument" (sorry I had to translate the message into English). So, I even wonder if "SecurePassword" is supported at all in VBS.

A full VBS solution would be prefered but if I can find a workaround with a working version of the code above, I would be happy too!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
This cannot work. SecureString is an object, while you get a string from PowerShell output.

You might be able to use the ProtectedData.Unprotect approach.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License