Hidden password in batch

1

In this POST, I will provide you with a segment of a program that you can use to make a password lock on you batch program. DON’T LEAVE YET. You may be thinking: “I’ve seen heaps of these, I’ll just leave now”. Don’t.

My version is different, and, in my opinion, better than those of others. The main, and only difference, is that when you enter your password, instead of letters showing up, asterisks (*) do instead.

There are a few drawbacks with this though. The code is longer than most, the password must be under a certain amount of letters and the password is case insensitive.

It can only contain letters (a-z) and numbers (0-9).

Oh, and also, sorry for spamming instructables recently, I’m having so many ideas. Just bear with my creative flow, until it runs out, that is.

Here it is:

Step 1: Code

2

:start
@echo off
setlocal enableextensions enabledelayedexpansion
color f0
title hidden password tester

if not exist pass.bat goto create

call pass.bat

set let1=na
set let2=na
set let3=na
set let4=na
set let5=na
set let6=na
set let7=na
set let8=na
set let9=na
set let10=na
set input=0
set tries=3

set code2=%pass%q234567890

set char1=!code2:~0,1!
set char2=!code2:~1,1!
set char3=!code2:~2,1!
set char4=!code2:~3,1!
set char5=!code2:~4,1!
set char6=!code2:~5,1!
set char7=!code2:~6,1!
set char8=!code2:~7,1!
set char9=!code2:~8,1!
set char10=!code2:~9,1!
set char11=!code2:~10,1!

if %char2% equ q set num=1

if %char3% equ q set num=2

if %char4% equ q set num=3

if %char5% equ q set num=4

if %char6% equ q set num=5

if %char7% equ q set num=6

if %char8% equ q set num=7

if %char9% equ q set num=8

if %char10% equ q set num=9

if %char11% equ q set num=10

set count=%num%

set round=-1

set /a num=%num%+1
goto login

:erase
set round=-1
set let1=na
set let2=na
set let3=na
set let4=na
set let5=na
set let6=na
set let7=na
set let8=na
set let9=na
set let10=na
set input=0
set /a num=%count%+1

:login
set /a num=%num%-1
set /a round=%round%+1
if %round% equ 1 set input=*
if %round% equ 2 set input=**
if %round% equ 3 set input=***
if %round% equ 4 set input=****
if %round% equ 5 set input=*****
if %round% equ 6 set input=******
if %round% equ 7 set input=*******
if %round% equ 8 set input=********
if %round% equ 9 set input=*********
if %round% equ %count% goto compile
cls
echo %tries% tries remaining
echo.
echo Please Enter your password.
if %input% neq 0 echo %input%
choice /c abcdefghijklmnopqrstuvwxyz1234567890 /n
cls
if %errorlevel% equ 1 set let%num%=a
if %errorlevel% equ 2 set let%num%=b
if %errorlevel% equ 3 set let%num%=c
if %errorlevel% equ 4 set let%num%=d
if %errorlevel% equ 5 set let%num%=e
if %errorlevel% equ 6 set let%num%=f
if %errorlevel% equ 7 set let%num%=g
if %errorlevel% equ 8 set let%num%=h
if %errorlevel% equ 9 set let%num%=i
if %errorlevel% equ 10 set let%num%=j
if %errorlevel% equ 11 set let%num%=k
if %errorlevel% equ 12 set let%num%=l
if %errorlevel% equ 13 set let%num%=m
if %errorlevel% equ 14 set let%num%=n
if %errorlevel% equ 15 set let%num%=o
if %errorlevel% equ 16 set let%num%=p
if %errorlevel% equ 17 set let%num%=q
if %errorlevel% equ 18 set let%num%=r
if %errorlevel% equ 19 set let%num%=s
if %errorlevel% equ 20 set let%num%=t
if %errorlevel% equ 21 set let%num%=u
if %errorlevel% equ 22 set let%num%=v
if %errorlevel% equ 23 set let%num%=w
if %errorlevel% equ 24 set let%num%=x
if %errorlevel% equ 25 set let%num%=y
if %errorlevel% equ 26 set let%num%=z
if %errorlevel% equ 27 set let%num%=1
if %errorlevel% equ 28 set let%num%=2
if %errorlevel% equ 29 set let%num%=3
if %errorlevel% equ 30 set let%num%=4
if %errorlevel% equ 31 set let%num%=5
if %errorlevel% equ 32 set let%num%=6
if %errorlevel% equ 33 set let%num%=7
if %errorlevel% equ 36 set let%num%=8
if %errorlevel% equ 35 set let%num%=9
if %errorlevel% equ 36 set let%num%=0
goto login

:compile
if %let1% equ na goto 9
if %let2% equ na goto 1
if %let3% equ na goto 2
if %let4% equ na goto 3
if %let5% equ na goto 4
if %let6% equ na goto 5
if %let7% equ na goto 6
if %let8% equ na goto 7
if %let9% equ na goto 8
goto 10

:10
set password=%let10%%let9%%let8%%let7%%let6%%let5%%let4%%let3%%let2%%let1%
goto check

:9
set password=%let9%%let8%%let7%%let6%%let5%%let4%%let3%%let2%%let1%
goto check

:8
set password=%let8%%let7%%let6%%let5%%let4%%let3%%let2%%let1%
goto check

:7
set password=%let7%%let6%%let5%%let4%%let3%%let2%%let1%
goto check

:6
set password=%let6%%let5%%let4%%let3%%let2%%let1%
goto check

:5
set password=%let5%%let4%%let3%%let2%%let1%
goto check

:4
set password=%let4%%let3%%let2%%let1%
goto check

:3
set password=%let3%%let2%%let1%
goto check

:2
set password=%let2%%let1%
goto check

:1
set password=%let1%
goto check

:check
if %password% neq %pass% goto bad
if %password% equ %pass% goto reward

:reward
rem Put the rest of your code here
cls
echo Correct!
pause
exit

:bad
cls
echo Incorrect!
set /a tries=%tries%-1
if %tries% equ 0 goto punish
echo.
echo Press any key to try again
pause >nul
goto erase

:punish
rem Put your punishment here
cls
echo Too many incorrect passwords
echo.
pause
exit

:create
cls
echo Create user
echo.
echo Password must only contain characters from a-z and 0-9. Password is non case-sensitive. CANNOT EXCEDE 10 CHARACTERS!
set /p pass=Password:
echo set pass=%pass%> “pass.bat”
cls
goto start

done:
1. Change the length of the password
2. Make it case-sensitive (might take a while)
3. …And many others……
Enjoy!!!!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s