+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
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 ...
  1. #1

    Join Date
    Oct 2005
    Location
    East Midlands
    Posts
    740
    Thank Post
    17
    Thanked 106 Times in 66 Posts
    Rep Power
    37

    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.

  2. #2

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    783
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24

    Re: Masking the password on inputbox vbscript


  3. #3

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

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

  4. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,807
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    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.

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,846
    Thank Post
    3,359
    Thanked 1,061 Times in 981 Posts
    Rep Power
    366

  6. #6

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    783
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24

    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

  7. #7

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

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

  8. #8

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    Re: Masking the password on inputbox vbscript

    All that to mask a password ? Whats the world comming to.......

  9. #9
    fooby's Avatar
    Join Date
    Dec 2005
    Posts
    351
    Thank Post
    0
    Thanked 5 Times in 4 Posts
    Rep Power
    19

    Re: Masking the password on inputbox vbscript

    Perhaps this might be of use.

    http://internet.cybermesa.com/~bstewart/passdlg/

    fooby

  10. #10

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,807
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Masking the password on inputbox vbscript

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

  11. #11

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    783
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24

    Re: Masking the password on inputbox vbscript

    Quote 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

  12. #12

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

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

  13. #13

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,807
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    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.

  14. #14

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    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.

  15. #15
    Guest

    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:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. VBScript / SQL Server
    By Gatt in forum Scripts
    Replies: 7
    Last Post: 23rd September 2011, 03:21 PM
  2. Vbscript reset a single domain user's password
    By ryan_powell in forum Scripts
    Replies: 9
    Last Post: 4th June 2009, 02:43 PM
  3. VBScript Error
    By sqdge in forum Scripts
    Replies: 20
    Last Post: 13th September 2007, 03:34 PM
  4. another VBScript question!
    By StewartKnight in forum Coding
    Replies: 4
    Last Post: 3rd May 2007, 05:41 PM
  5. VBScript
    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
  •