hide the batch input through this file

Asked

Viewed 536 times

1

I am trying to encrypt a folder hiding it, but when entering this code, it forwards me to batch to ask for the password, when I am entering 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

2 answers

0

There is a issue at Soen with several possibilities. What seems to me simpler and interesting is the one you use 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 don’t use Windows to test this solution and maybe I need some adaptation, but I hope I helped in the solution path.

0

Here a method 100% Bat to hide 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.