spc-rocket Posted March 8, 2007 Posted March 8, 2007 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.
djm968 Posted March 8, 2007 Posted March 8, 2007 This link should help http://www.autoitscript.com/autoit3/docs/functions/InputBox.htm
mattx Posted March 8, 2007 Posted March 8, 2007 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 - [email protected] ; 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")
Geoff Posted March 8, 2007 Posted March 8, 2007 Just be aware that it's not totally secure. Any password dialog box can be snooped at GDI level.
mac_shinobi Posted March 8, 2007 Posted March 8, 2007 http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0204.mspx http://www.petri.co.il/forums/showthread.php?p=42406
djm968 Posted March 8, 2007 Posted March 8, 2007 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 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("") .WriteLn("[b]" & sTitle & "[b] ") .WriteLn("Password " & _ "Submit") .WriteLn("") 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
mattx Posted March 8, 2007 Posted March 8, 2007 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...
mattx Posted March 8, 2007 Posted March 8, 2007 All that to mask a password ? Whats the world comming to.......
fooby Posted March 8, 2007 Posted March 8, 2007 Perhaps this might be of use. http://internet.cybermesa.com/~bstewart/passdlg/ fooby
Geoff Posted March 8, 2007 Posted March 8, 2007 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.
djm968 Posted March 8, 2007 Posted March 8, 2007 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 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("") .WriteLn("[b]" & sTitle & "[b] ") .WriteLn("Password " & _ "Submit") .WriteLn("") 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
mattx Posted March 8, 2007 Posted March 8, 2007 ...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.....
Geoff Posted March 8, 2007 Posted March 8, 2007 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.
mattx Posted March 8, 2007 Posted March 8, 2007 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.
Guest Posted March 8, 2007 Posted March 8, 2007 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
Guest Posted March 9, 2007 Posted March 9, 2007 the vbs full screen script which could include a policy that students had to read and click accept or if they dont it logs them off
mattx Posted March 9, 2007 Posted March 9, 2007 which could include a policy that students too to read and click accept or if they dont it logs them off I've got something like that lurking around my HDs somewhere...., can't remember if its VB or something else I did it in now.
spc-rocket Posted March 9, 2007 Author Posted March 9, 2007 Thanks for all your help, certainly lots of options available. Ash.
mattx Posted March 9, 2007 Posted March 9, 2007 Isn't the MOTD thing in Group Policy sufficient? Not for us.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now