Wasif_Hasan_

PasswordSubmitter.bat

Sep 10th, 2020 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.04 KB | None | 0 0
  1. <!-- :
  2.  
  3.  :: PasswordSubmitter.bat | Wasif Hasan | Sep 2020
  4.  :: This is a Batch-HTA-VBScript hybrid that will show a GUI window to enter password
  5.  :: Save it as a .bat file and run it in your other batch files
  6.  :: and returns the password as a result (to STDOUT)
  7.  :: If you enter no password in the dialog it will show an error message box and persist
  8.  :: Arguments: "BatchFilePath" "prompt (To Show over the password box)"
  9.  :: Default prompt is "Enter password"
  10.  
  11.  @echo off & setlocal EnableDelayedExpansion
  12.  if [%*]==[] (
  13.  for /f "tokens=* delims=" %%a in ('echo "Enter Password" ^| mshta.exe "%~f0"') do set "pass=%%a"
  14.  ) else (
  15.  for /f "tokens=* delims=" %%a in ('echo %* ^| mshta.exe "%~f0"') do set "pass=%%a"
  16.  )
  17.  echo !pass! & exit /b 0
  18.  
  19. -->
  20.  
  21. <!DOCTYPE html>
  22. <html>
  23. <head>
  24. <title>Password box</title>
  25. <hta:application
  26.  applicationName="Password box"
  27.  border="thin"
  28.  maximizeButton="no"
  29.  minimizeButton="no"
  30.  showinTaskbar="no"
  31.  scroll="no"
  32.  singleInstance="yes"
  33.  contextMenu="no"
  34.  selection="no"
  35. />
  36. <script type="text/vbscript">
  37.   Sub Window_OnLoad()
  38.     Dim fso2, strPrompt, dblQuote
  39.     window.resizeTo 320,180
  40.     Set fso2 = CreateObject("Scripting.FileSystemObject").GetStandardStream(0)
  41.     strPrompt = fso2.ReadLine
  42.     dblQuote = Chr(34)
  43.     strPrompt = Replace(strPrompt, dblQuote, "")
  44.     Document.All.prompt.innerHTML = strPrompt
  45.     document.All.Password.Focus
  46.   End Sub
  47.   Sub Validate()
  48.     Dim fso, GetPassword
  49.     GetPassword = Document.All.Password.Value
  50.     If GetPassword = "" Then
  51.       MsgBox "Please enter a password!",48,"Password box"
  52.     Else
  53.       Set fso = CreateObject("Scripting.FileSystemObject").GetStandardStream(1)
  54.       window.Close(fso.write(GetPassword))
  55.     End If
  56.   End Sub
  57. </script>
  58. </head>
  59. <body style="background-color:lightblue;font-family:Tahoma;">
  60. <div align="center">
  61. <p id="prompt">Enter Password</p>
  62. <p><input type="password" size="20" id="Password" /></p>
  63. <p><input type="button" value="Submit" onClick="Validate()" /></p>
  64. </div>
  65. </body>
  66. </html>
Add Comment
Please, Sign In to add comment