Computer Hope

Microsoft => Microsoft DOS => Topic started by: behad-007 on July 27, 2011, 12:57:43 AM

Title: Someone please explain to me how this code work?
Post by: behad-007 on July 27, 2011, 12:57:43 AM
Someone please explain to me how this code work?

@echo off
setlocal
%1 %0 :: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
set A=%5&set B=%6&set C=%8&set D=%3
for %%? in (1 2 3 4 5 6 7 8 9) do shift
set A=%C%%7%A%&set C=%D%%4%B%&set D=%7
for %%? in (1 2 3 4 5 6 7 8 9) do shift
echo %A% %C%%2%2 %8%D%%4!

output > GOD BLESS YOU!

tnx
Title: Re: Someone please explain to me how this code work?
Post by: patio on July 27, 2011, 05:52:30 PM
Closed.
Title: Re: Someone please explain to me how this code work?
Post by: Computer Hope Admin on July 29, 2011, 02:23:09 AM
Re-opening this question since it was never answered after being interrupted by Bill and moved into spam.

To answer the question, Ahh got to love obfuscated code, probably why I like Perl. ;)

Here is a modification of the code to help explain what it is doing, hope it helps. Just added echo and REM statements to help explain and illustrate what is being done as the batch file is being ran.

Code: [Select]
@echo off
REM Setlocal environmental variables - http://www.computerhope.com/setlocal.htm
setlocal
REM Set A-Z starting with %2 being A
%1 %0 :: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
echo Alphabet = %2%3%4%5%6%7%8%9
REM set the A,B,C,D variables - http://www.computerhope.com/sethlp.htm
set A=%5&set B=%6&set C=%8&set D=%3
echo 1:A=%a% -- B=%B% -- C=%C% -- D=%D%  (2=%2 4=%4 8=%8)
REM Go through for loop and shift %1-9 - FOR: http://www.computerhope.com/forhlp.htm | SHIFT: http://www.computerhope.com/shift.htm
for %%? in (1 2 3 4 5 6 7 8 9) do shift
echo Alphabet = %2%3%4%5%6%7%8%9
echo 2:A=%a% -- B=%B% -- C=%C% -- D=%D%  (2=%2 4=%4 8=%8)
REM Set the new shifted characters into the A,B,C,D variables again.
set A=%C%%7%A%&set C=%D%%4%B%&set D=%7
echo 3:A=%a% -- B=%B% -- C=%C% -- D=%D%  (2=%2 4=%4 8=%8)
REM Shift again
for %%? in (1 2 3 4 5 6 7 8 9) do shift
echo Alphabet = %2%3%4%5%6%7%8%9
echo 4:A=%a% -- B=%B% -- C=%C% -- D=%D% (2=%2 4=%4 8=%8)
REM Finally, just add the %2%2 for double 's' after BLE (which is what %C% is equal to and the %8 for Y and %4 for U
echo %A% %C%%2%2 %8%D%%4!
Title: Re: Someone please explain to me how this code work?
Post by: behad-007 on July 30, 2011, 04:32:56 AM
thanks so much for reply
i got that :)
that was very helpful.