hide the input in the batch through this file

0

I'm trying to encrypt a folder by hiding it, but when I enter this code, it will forward me to the batch to ask for the password, when I insert it it shows the password and does not hide it.

cls
@ECHO OFF

if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDLOCKER

:CONFIRM
echo Tem certeza de que deseja bloquear a pasta (Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM


:LOCK
ren Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End

:UNLOCK
echo Digite a senha para desbloquear pasta
set/p "password=>"
if NOT %password%==password_aqui goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder Unlocked successfully
goto End


:FAIL
echo Senha Invalida
goto end

:MDLOCKER
 md Private
 echo Private foi criada com sucesso
 goto End
 :End
    
asked by anonymous 20.10.2015 / 03:47

2 answers

0

There is a SOen question with several possibilities. The one that seems most simple and interesting is using powershell . Example:

@echo off
set "psCommand=powershell -Command "$pword = read-host 'Digite a senha para desbloquear pasta' -AsSecureString ; ^
    $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
        [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in ('%psCommand%') do set password=%%p
echo %password%

Unfortunately, I do not use Windows to test this solution and may need some adaptation, but I hope I have helped on the way to the solution.

    
21.10.2015 / 03:03
0

Here is a 100% Bat method to hide the password:

::By SachaDee® (©) 2015

@echo off&cls

::O codigo
set "$Mdp=toto1234"

::O tamanho do codigo
set "$Long=-1"
for /F "delims=" %%c in ('cmd /D /U /C echo %$Mdp% ^| find /V ""') do (set /a $Long+=1)

::Les autres variables
set "$l="
set "$l1="
set "$C=0"

:test
if %$c%==%$Long% goto:Pastrouve
set "$T="
cls&echo Entrer votre MDP : %$l1%
For /F "delims=" %%# In ('Xcopy /W "%~f0" "%~f0" 2^>Nul') Do If Not Defined $T Set "$T=%%#"

set "$testenter=%$T:~-1%"
if not defined $Testenter goto:Pastrouve

if %$T:~-1%== (
 if not %$C%==0 (
  Set "$l=%$l:~0,-1%"
  set "$l1=%$l1:~0,-1%"
  set /a $C-=1)
 ) else (
  Set "$l=%$l%%$T:~-1%"
  set "$l1=%$l1%*"
  set /a $C+=1)

if "%$l%"=="%$Mdp%" goto:trouve
goto:test

:trouve
echo Codigo OK
Pause >NUL & exit/b

:Pastrouve
echo Codigo Errado
Pause>NUL & exit/b

And the same using Powershell

::By SachaDee® (©) 2015
@echo off&cls
set $MDP=toto1234
for /f "delims=" %%a in ('powershell -c "$rep=read-host Entrer_votre_MDP -AsSecureString;$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($rep));write $password"') do set $rep=%%a
if %$MDP%==%$rep% (echo Codigo OK) else (echo Codigo Errado)
exit/b
    
17.02.2016 / 01:05