Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-27-2008, 11:09 AM
darkoth darkoth is offline
Registered User
 
Join Date: Jun 2007
Posts: 29
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
Reply With Quote
  #2  
Old 06-27-2008, 01:32 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 585
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?
Reply With Quote
  #3  
Old 06-27-2008, 02:32 PM
darkoth darkoth is offline
Registered User
 
Join Date: Jun 2007
Posts: 29
Thanks

That works like a charm. Thank you very much.
Reply With Quote
  #4  
Old 06-27-2008, 02:35 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 585
Hi darkoth,

Great! I am glad the information I provided was helpful.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:49 PM.