Coding Thread, Masking the password on inputbox vbscript in Coding and Web Development; Hi All,
Just wondering if anyone know how to mask the password on an inputbox when the user is typing ...
-
8th March 2007, 03:12 PM #1 Masking the password on inputbox vbscript
Hi All,
Just wondering if anyone know how to mask the password on an inputbox when the user is typing in the password.
I have a situation where i'm tryin to use vb script (using the wscript) which prompts for the username and password but the password obviously needs to masked with *'s or other character.
Looked around on the net but not got much info except using IE to mask and incoporating this into the script.
Any ideas?
Ash.
-
-
IDG Tech News
-
8th March 2007, 03:17 PM #2 Re: Masking the password on inputbox vbscript
-
-
8th March 2007, 03:25 PM #3 Re: Masking the password on inputbox vbscript
Not sure if this is of any use to you - [ Its written in AutoIT ] It may give you an idea...
Just need to change the $sPass to what you want....
; AutoIt Version: 3
; Language: English
; Platform: WinXP
; Author: Matt Marsh -
mmarsh@st-johns.org.uk
; Script Function: Script that Launches Fun With Texts Teacher Console
$sPass = 'password'
Do
$sInput = InputBox( "Password Prog By Matt Marsh", "Insert password to Launch Fun With Texts Teacher Console" & @LF & "The password is CaSe SeNSiTIve.", "", ".")
If @error Then Exit
If $sPass == $sInput Then ExitLoop
MsgBox(4096 + 16, 'Error!', 'Password didn''t match.' & @LF & 'Try again.')
Until 0
Run("P:\FWT3\FWTT.EXE")
-
-
8th March 2007, 03:27 PM #4 Re: Masking the password on inputbox vbscript
Just be aware that it's not totally secure. Any password dialog box can be snooped at GDI level.
-
-
8th March 2007, 03:35 PM #5 Re: Masking the password on inputbox vbscript
-
-
8th March 2007, 03:36 PM #6 Re: Masking the password on inputbox vbscript
Just to clarify.... what you are trying to do to my knowledge cannot be done using pure vbscript this code uses an IE object to mask the password
Code:
Dim bPasswordBoxWait ' A required global variable
wsh.echo "You entered:", PasswordBox("Enter your password")
Function PasswordBox(sTitle)
set oIE = CreateObject("InternetExplorer.Application")
With oIE
.FullScreen = True
.ToolBar = False : .RegisterAsDropTarget = False
.StatusBar = False : .Navigate("about:blank")
While .Busy : WScript.Sleep 100 : Wend
With .document
With .ParentWindow
.resizeto 400,100
.moveto .screen.width/2-200, .screen.height/2-50
End With
.WriteLn("<html><body bgColor=Silver><center>")
.WriteLn("[b]" & sTitle & "[b]
")
.WriteLn("Password <input type=password id=pass> " & _
"<button id=but0>Submit</button>")
.WriteLn("</center></body></html>")
With .ParentWindow.document.body
.scroll="no"
.style.borderStyle = "outset"
.style.borderWidth = "3px"
End With
.all.but0.onclick = getref("PasswordBox_Submit")
.all.pass.focus
oIE.Visible = True
bPasswordBoxOkay = False : bPasswordBoxWait = True
On Error Resume Next
While bPasswordBoxWait
WScript.Sleep 100
if oIE.Visible Then bPasswordBoxWait = bPasswordBoxWait
if Err Then bPasswordBoxWait = False
Wend
PasswordBox = .all.pass.value
End With ' document
.Visible = False
End With ' IE
End Function
Sub PasswordBox_Submit()
bPasswordBoxWait = False
End Sub
-
-
8th March 2007, 03:36 PM #7 Re: Masking the password on inputbox vbscript
it's not totally secure. Any password dialog box can be snooped at GDI level.
Indeed, its only meant as an internal quick and dirty script.....I don't have time to code an encrypted password script...
-
-
8th March 2007, 03:38 PM #8 Re: Masking the password on inputbox vbscript
All that to mask a password ? Whats the world comming to.......
-
-
8th March 2007, 03:46 PM #9 Re: Masking the password on inputbox vbscript
-
-
8th March 2007, 03:51 PM #10 Re: Masking the password on inputbox vbscript

Originally Posted by
mattx Indeed, its only meant as an internal quick and dirty script.....I don't have time to code an encrypted password script...

Well no, if you can capture keyboard input directly when your dialog window has focus you can take that input and deal with it without it being exposed to GDI widgets. If you synchronise this with a normal text box display that gets filled with asterisks at the appropriate rate the user will be none the wiser.
This is how GTK/QT/Motif do it anyway.
-
-
8th March 2007, 04:05 PM #11 Re: Masking the password on inputbox vbscript

Originally Posted by
mattx All that to mask a password ? Whats the world comming to.......
I agree..... and code gets even longer if you want to re-size the IE windows
Code:
Function PasswordBox(sTitle)
set oIE = CreateObject("InternetExplorer.Application")
With oIE
.FullScreen = True
.ToolBar = False : .RegisterAsDropTarget = False
.StatusBar = False : .Navigate("about:blank")
.Width = 400
.Height = 200
.Left = 300
.Top = 200
.Visible = 1
While .Busy : WScript.Sleep 100 : Wend
With .document
With .ParentWindow
.resizeto 100,50
.moveto .screen.width/2-200, .screen.height/2-50
End With
.WriteLn("<html><body bgColor=Silver><center>")
.WriteLn("[b]" & sTitle & "[b]
")
.WriteLn("Password <input type=password id=pass> " & _
"<button id=but0>Submit</button>")
.WriteLn("</center></body></html>")
With .ParentWindow.document.body
.scroll="no"
.style.borderStyle = "outset"
.style.borderWidth = "3px"
End With
.all.but0.onclick = getref("PasswordBox_Submit")
.all.pass.focus
oIE.Visible = True
bPasswordBoxOkay = False : bPasswordBoxWait = True
On Error Resume Next
While bPasswordBoxWait
WScript.Sleep 100
if oIE.Visible Then bPasswordBoxWait = bPasswordBoxWait
if Err Then bPasswordBoxWait = False
Wend
PasswordBox = .all.pass.value
End With ' document
.Visible = False
End With ' IE
End Function
Sub PasswordBox_Submit()
bPasswordBoxWait = False
End Sub
-
-
8th March 2007, 04:12 PM #12 Re: Masking the password on inputbox vbscript
...without it being exposed to GDI widgets.
Just double checked, and not many of our children know what a GDI Widget is, so my script should be quite safe for the time being.....
-
-
8th March 2007, 04:22 PM #13 Re: Masking the password on inputbox vbscript
Security through obscurity is no security at all. 
1. Grab SIW here (a cool tool for other things too).
2. Tools -> Eureka!
3. Open a dialog up using a password box. IE, Sophos Autoupdates, anything interesting like that.
4. Drag the magnifying glass across to the password entry box and... 
I figure if I can do it, so can someone else.
-
-
8th March 2007, 07:43 PM #14 Re: Masking the password on inputbox vbscript
I figure if I can do it, so can someone else.
Our students are more interested in miniclip.com and some of the other games we allow on our network.
I'll take a look though.
-
-
8th March 2007, 11:36 PM #15 Re: Masking the password on inputbox vbscript
sorry to hijack this thread but that script was brilliant
was wondering if 1 of you clever guys could come up with a AUP screen that students would need to click accept or get logged off
-
SHARE: 
Similar Threads
-
Replies: 7
Last Post: 23rd September 2011, 03:21 PM
-
By ryan_powell in forum Scripts
Replies: 9
Last Post: 4th June 2009, 02:43 PM
-
By sqdge in forum Scripts
Replies: 20
Last Post: 13th September 2007, 03:34 PM
-
By StewartKnight in forum Coding
Replies: 4
Last Post: 3rd May 2007, 05:41 PM
-
By StewartKnight in forum Coding
Replies: 5
Last Post: 1st May 2007, 11:04 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules