Jump to content

Recommended Posts

Posted

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.

Posted

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")

Posted

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 

Posted
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... :roll:

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

 

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.

Posted
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 

Posted
...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.....

Posted

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.

Posted
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.

Posted

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

:lol:

Posted

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

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...