|
Answer» hello, I want to hide the password when the user is being prompted to ENTER the password in a batch file. could any body help me in doing the same. Best Regards, MohanWell, recently I found getkey.com (thanks to Dias) This sets the key pressed to an errorlevel.
This will create a password of abc, without displaying any echos.
Code: [Select]@echo off if not exist C:\WINDOWS\getkey.com ( echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>C:\WINDOWS\getkey.com echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>C:\WINDOWS\getkey.com echo l/[emailprotected]>>C:\WINDOWS\getkey.com ) REM password is set to abc :run C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==97 goto :success1 echo Incorrect. pause >nul exit
:success1 C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==98 goto :success2 echo Incorrect. pause >nul exit
:success2 C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==99 goto :enter echo Incorrect. pause >nul exit
:enter echo Correct Password pause >nul
Here are a list of the 'key' codes: which are used in If %Key%==97 goto :success1
Code: [Select] %Key%==97 = a %Key%==98 = b %Key%==99 = c %Key%==100 = d %Key%==101 = e %Key%==102 = f %Key%==103 = g %Key%==104 = h %Key%==105 = i %Key%==106 = j %Key%==107 = k %Key%==108 = l %Key%==109 = m %Key%==110 = n %Key%==111 = o %Key%==112 = p %Key%==113 = q %Key%==114 = r %Key%==115 = s %Key%==116 = t %Key%==117 = u %Key%==118 = v %Key%==119 = w %Key%==120 = x %Key%==121 = y %Key%==122 = z %Key%==65 = A %Key%==66 = B %Key%==67 = C %Key%==68 = D %Key%==69 = E %Key%==70 = F %Key%==71 = G %Key%==72 = H %Key%==73 = I %Key%==74 = J %Key%==75 = K %Key%==76 = L %Key%==77 = M %Key%==78 = N %Key%==79 = O %Key%==80 = P %Key%==81 = Q %Key%==82 = R %Key%==83 = S %Key%==84 = T %Key%==85 = U %Key%==86 = V %Key%==87 = W %Key%==88 = X %Key%==89 = Y %Key%==90 = Z %Key%==32 = SpaceBar
If you want more than three digits keep adding these (but replace X with the appropriate numbers) Code: [Select] :successX C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==XX goto :successX echo Incorrect. pause >nul exit is there any other way to do the same thing. Quote from: Jacob on October 30, 2008, 04:02:16 AM Well, recently I found getkey.com (thanks to Dias) This sets the key pressed to an errorlevel.
This will create a password of abc, without displaying any echos.
Code: [Select]@echo off if not exist C:\WINDOWS\getkey.com ( echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>C:\WINDOWS\getkey.com echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>C:\WINDOWS\getkey.com echo l/[emailprotected]>>C:\WINDOWS\getkey.com ) REM password is set to abc :run C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==97 goto :success1 echo Incorrect. pause >nul exit
:success1 C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==98 goto :success2 echo Incorrect. pause >nul exit
:success2 C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==99 goto :enter echo Incorrect. pause >nul exit
:enter echo Correct Password pause >nul
Here are a list of the 'key' codes: which are used in If %Key%==97 goto :success1
Code: [Select] %Key%==97 = a %Key%==98 = b %Key%==99 = c %Key%==100 = d %Key%==101 = e %Key%==102 = f %Key%==103 = g %Key%==104 = h %Key%==105 = i %Key%==106 = j %Key%==107 = k %Key%==108 = l %Key%==109 = m %Key%==110 = n %Key%==111 = o %Key%==112 = p %Key%==113 = q %Key%==114 = r %Key%==115 = s %Key%==116 = t %Key%==117 = u %Key%==118 = v %Key%==119 = w %Key%==120 = x %Key%==121 = y %Key%==122 = z %Key%==65 = A %Key%==66 = B %Key%==67 = C %Key%==68 = D %Key%==69 = E %Key%==70 = F %Key%==71 = G %Key%==72 = H %Key%==73 = I %Key%==74 = J %Key%==75 = K %Key%==76 = L %Key%==77 = M %Key%==78 = N %Key%==79 = O %Key%==80 = P %Key%==81 = Q %Key%==82 = R %Key%==83 = S %Key%==84 = T %Key%==85 = U %Key%==86 = V %Key%==87 = W %Key%==88 = X %Key%==89 = Y %Key%==90 = Z %Key%==32 = SpaceBar
If you want more than three digits keep adding these (but replace X with the appropriate numbers) Code: [Select] :successX C:\WINDOWS\getkey.com set key=%errorlevel% If %Key%==XX goto :successX echo Incorrect. pause >nul exit
Yes, but i find this the best and safest way. hello, thanks for your reply. could you please let me if other way to do the same. Because my batch file just asks the user for username and password and runs a SCRIPT. So my intention is to avoid to keep more code in that batch file. thanks in advacne.
Quote from: Jacob on October 30, 2008, 04:36:58 AMYes, but i find this the best and safest way.
I'm afraid you will need somebody Else's help on this if you would like a different solution. Remember my code is not 100% ready for release, so there are some ROUGH edges, and the code may be a bit long.I found an old debug script in the snippet closet but it had no context as how to use it. After seeing Jacob's technique, this should help you out:
Code: [Select]@echo off echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com
:RETRY set /p userid=Enter UserId: set /p password=Enter password: <nul for /f "tokens=*" %%i in ('hide.com') do set password=%%i if /i %password%==password goto next cls echo Try again. You are not logged in! goto retry
:next echo. echo You are logged in! del hide.com
The problem with passwords is that at some point a compare must be made with the actual password. In a batch file the password is there to see for ANYONE interested. Might be better to hide the password in a file. An alternative solution would be VBScript which can be encoded. Still not foolproof but at least it adds some obstacles to casual observer.
The easiest way would be to compile your script into an .exe. Decompile proof. Google conset.zip. When used with switches (/ph I believe?) conset will star out user input. For dos 9x, input will do the same - google "dos input.zip"
|