BAT Character Filter [Revision Edition] (AlLeesno)

xiaoxiao2021-03-06  66

FreexPloit Original article @echo offman Thank you ZZZEVAZZZ to the code improved REM About set errorlevel => nul set password => NUL I still chose to keep this to avoid other programs REM If calling these two variables will cause errors ^ password = ph4NT0M $ Very good, I originally wanted to use Sortrem to make the order now. Now it's better to use zZZEVAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ Z. set password = allyesno is a pig> nulset / p password = set password | findstr "^ password = ph4nt0m $" if "% errorlevel%" == "0" echo the password is correct & goto endecho password error & goto allyesno: endset password => nulset ErrorLevel => Nulecho You successfully log in to the system Note: Please save the above scripts to Key.bat to perform the Benevo (above the final determined script):

As early as a small game for writing BAT, I studied how this problem has been used to filter any characters to input any characters in bat that CODZ:

IF "% 1" == "Character to filter" Echo You entered illegal word: if "% 1" == "Wrongpassword" Echo Error Password Set Errorlevel = 0 Echo To filter the characters | Find "to filter Character "IF"% errorlevel% "==" 0 "Echo you entered is an illegal character if"% errorle% == "1" echo This string is not in illegal list

Mainly used in these two methods, these two methods can filter numbers and English letters but don't work for special characters. [~ `! @ # $% ^ & * () _ | - = / []} ; ':,. / <>?] (Including spaces and tab keys), we have to CODZ:

Echo "Anyword" | Find "Anywrod"

Notice what is different? Yes, we joined "" to contain anyword, but it is not completed. It doesn't finish finding less characters you want to filter. "The character is unable to perfect this method. Filter "Character Bear" When the value is odd and even, it is possible to filter her with the condition. This problem may be reported to this problem. I have been in Ansochemical. I have to filter it. Not so simple, let's write a few triggers that verify passwords first. See the react of the program in different situations. We first write a small program that verifies the password login: Authorized login CODZ when password verification character is PH4NT0M:

@echo off cls: AlLeesno set error => NUL Echo Please enter the login password set / p password = echo "% password%" | FINDSTR "pH4NT0M" if "% erroorle%" == "0" Echo password correct & goto end echo password Error & Goto Allyesno: End Echo You successfully logged in to save the BAT to Key.bat execution results CODZ:

C: test> Key Please enter the login password Test Password error Please enter the login password ph4NT0M "pH4NT0M" password correctly you successfully log in

In fact, the above code is used to perform a general password verification is enough, but it is necessary to meet our destination any character filtering, don't do it, do it, do it, do it, see the execution result CODZ:

C: Test> Key Please enter the login password Test Password error Please enter the login password "" "| FindStr" pH4NT0M "password error Please enter the login password ph4NT0M" PH4NT0M "password correctly you successfully log in to the system

Did you see it? When the character is entered, the program is wrong and shows why the password will be like this? We look at the syntax structure of this statement Echo "% password%" | FINDSTR "PH4NT0M" When% password% = "is Echo "" "|" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "

I:> echo "| CD i:> echo" | CD i: i:> echo "" | cd "" | cd i:> echo "" "| CD i:

When "When it is odd, print the whole line" is an even number, the command is executed on the previous command, the command executed by the program is CD here I think a way to bypass the Echo error. I use the set instead of the Echo program CODZ. :

@echo off cls: AlLeesno Set Errorlevel => Nul Echo Please enter the login password set / p password = set | findstr "pH4NT0M" IF "% errorlevel%" == "0" echo password correct & goto end echo password error & goto allyesno: End echo you successfully log in

The execution result is as follows:

Please enter the login password Test Password error Please enter the login password "password error Please enter the login password ph4NT0M password = ph4NT0M password correctly you successfully log in to the system C: / Test>

The program is further perfect, but there is still a problem D Let's see another way to perform CODZ:

Please enter the login password Test Password error Please enter the login password ph4NT0MALLYESNO Password = ph4NT0MALLYESNO password correctly you successfully log in to the system C: test>

Since the verification method of the program is SET | FINDSTR "Ph4NT0M" So as long as the password containing the PH4NT0M character is used as the correct password, the password pH4NT0MALLYESNO also passed the problem to avoid this problem I set the matching parameter / to verify the data The program is as follows:

@echo off cls: AlLeesno Set Errorlevel => Nul Echo Please enter the login password set / p password = set | findstr "/ " if "% errorle%" == "0" ECHO password correct & goto end echo password error & goto allyesno: End echo You successfully logged in system execution results CODZ:

Please enter the login password TEST password error Please enter the login password ph4NT0MALLYESNO password error Please enter the login password ph4NT0M password = ph4NT0M password correctly you successfully log in to the system C: Test>

Finally, we will then trim down the following CODZ:

@echo off cls: allyeesno set error => Nul Echo Please enter the login password set / p password = remote If the password string contains this list ~ `! @ # $% ^ & * () _ | - = [ ] {}; ':,. / <>, The matching mode <> REM needs two-write character REM can be used as a password character "set password | FINDSTR" / "if"% errorle% " == "0" echo password correct & goto end echo password error & goto allyesno: End set password => Nul echo you successfully log in

Note: When you have character / character ////> "" FindStr "/ " when you have character ////> ", you only need to write / do not need to double-write when you log in. String If the password string contains this list of characters ~ `! @ # $% ^ & * () _ | - = []}; ':,. / <> • Match mode /

转载请注明原文地址:https://www.9cbs.com/read-87579.html

New Post(0)