VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Password in scripts (https://forums.vandyke.com/showthread.php?t=3024)

darkoth 06-27-2008 12:09 PM

Password in scripts
 
I'm working on a script that will go out to an FTP server, enter the users inputted username and password, send it, and then install.

My question is this. How would I "encrypt" their password when they typed their password in the window so that if someone is standing behind them, they won't see what is typed...

Example code below which grabs a pca package off one of our servers and installs it.

Code:

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

Sub Main

        ' Ask for userid
        User_ID = crt.Dialog.Prompt("Enter your username: ", "" )
        if User_ID = "" then exit sub

        ' Ask for password
        User_Pass = crt.Dialog.Prompt("Enter your password: ", "")
        if User_Pass = "" then exit sub

        crt.Screen.Send "cd /usr/tmp/;mkdir pca;cd pca" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "ftp server1" & chr(13)
        crt.Screen.WaitForString "): "
        crt.Screen.Send User_ID & chr(13)
        crt.Screen.WaitForString "Password:"
        crt.Screen.Send User_Pass & chr(13)
        crt.Screen.WaitForString "ftp> "
        crt.Screen.Send "bin" & chr(13)
        crt.Screen.WaitForString "ftp> "
        crt.Screen.Send "cd /data/Docs_Apps/SunPackages/pca" & chr(13)
        crt.Screen.WaitForString "ftp> "
        crt.Screen.Send "get pca.tar.gz" & chr(13)
        crt.Screen.WaitForString "ftp> "
        crt.Screen.Send "quit" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "gunzip pca.tar.gz;tar -xvf pca.tar.gz" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "ls" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "tar -xvf pca.tar" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "rm pca.tar" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pkgadd -d gcc-3.4.6-sol10-sparc-local" & chr(13)
        crt.Screen.WaitForString "all packages). (default: all) [?,??,q]: "
        crt.Screen.Send chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pkgadd -d openssl-0.9.8h-sol10-sparc-local" & chr(13)
        crt.Screen.WaitForString "all packages). (default: all) [?,??,q]: "
        crt.Screen.Send chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pkgadd -d libiconv-1.11-sol10-sparc-local" & chr(13)
        crt.Screen.WaitForString "all packages). (default: all) [?,??,q]: "
        crt.Screen.Send chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pkgadd -d libintl-3.4.0-sol10-sparc-local" & chr(13)
        crt.Screen.WaitForString "all packages). (default: all) [?,??,q]: "
        crt.Screen.Send chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pkgadd -d wget-1.11.3-sol10-sparc-local" & chr(13)
        crt.Screen.WaitForString "all packages). (default: all) [?,??,q]: "
        crt.Screen.Send chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "mv pca.conf /etc" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "chmod 755 pca;mv pca /usr/sbin" & chr(13)
        crt.Screen.WaitForString " ]# "
        crt.Screen.Send "pca" & chr(13)
End Sub


kbarnette 06-27-2008 02:32 PM

Hi darkoth,

The crt.Dialog.Prompt() method can accept an argument that specifies whether the dialog is a password prompt or not.

For example, in your code, using the following line to prompt the user for their password should be helpful in accomplishing what it is you are looking to do:

Code:

User_Pass = crt.Dialog.Prompt("Enter your password: ", "", "", True)
More information on the crt.Dialog.Prompt() method can be found in the 'ActiveX Scripting/Script Objects Reference/Dialog Object' chapter of the SecureCRT Help.

Note that the order of arguments passed to the crt.Dialog.Prompt is as follows, as indicated in the Help:
message [, title [, default [, isPassword ]]]
Given this, we needed to modify your prompt to pass a 'default' parameter so we could get at the 'isPassword' parameter.

Is this information helpful?

darkoth 06-27-2008 03:32 PM

Thanks
 
That works like a charm. Thank you very much.

kbarnette 06-27-2008 03:35 PM

Hi darkoth,

Great! I am glad the information I provided was helpful. :)


All times are GMT -6. The time now is 01:50 AM.