Page 1 of 1
obfuscated hello world won't print hello world
Posted: 27 Jan 2017 14:51
by NunoLava1998
I'm trying to create a (very) obfuscated "Hello World!" in batch. However, this gives an error or displays nothing rather than displaying "Hello WorlD!"
Code: Select all
set/a_=5-4>nul&&set/a.=5-5>nul&&set "m=^%^t^m^p^:^~^5^,%_%%"&&set "q=%^t^m^p^:^~%.%,%_%%&&set "z=%^t^m^p^:^~6,%_%%&&set "v=%^c^o^m^s^p^e^c^:^~6,%_%%
%m%%q%Ho H%m%%z%%z%o Wor%z%%v%!
Re: obfuscated hello world won't print hello world
Posted: 27 Jan 2017 17:13
by ShadowThief
What's it supposed to look like un-obfuscated?
Re: obfuscated hello world won't print hello world
Posted: 28 Jan 2017 00:48
by thefeduke
NunoLava1998 wrote:this gives an error or displays nothing
Remarkable code. So which is it? An undisclosed error or no display? Or does it act differently based on some external influences?
Oh, where is my tongue-in-cheek icon?
John A.
Re: obfuscated hello world won't print hello world
Posted: 28 Jan 2017 04:33
by penpen
I guess "%m%%q%Ho H%m%%z%%z%o Wor%z%%v%!" should be "echo Hello World!", and
the first line then has to set up the used environment variables.
I see two issues here:
1. Perctentage expansion is only appended once before a line of batch code is interpreted see:
http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/4095133#4095133You may use "call" to realize a second percentage expansion, but this has also other side effects (for example on the circumflex accent character):
Code: Select all
set "AB=de" && set "C=f" && set "ABF=xyz" && call set "D=%%AB%C%%%^"
echo D=%D%
2. Percentage expansion doesn't work the way you (NunoLava1998) assumes (like parentheses):
So "%AB%C%%" would not first expand %C% and then (assumed "%C%"== "f") %ABf%.
Instead percentage expansion first expands "%AB%" (to its value) and then "%%" (to "%").
For more information on percentage expansion see:
http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912.
(Same linked page as above, but different post.)
penpen
Re: obfuscated hello world won't print hello world
Posted: 28 Jan 2017 10:54
by misol101
I'm having trouble with mine as well. How do I write a blank space instead of an underscore?
Code: Select all
@setlocal enabledelayedexpansion&@for /f "delims=" %%H in (%~n0.bat) do @for %%W in (53,2,4,8,5,124,79,30,36,14,16) do @set _=%%H&set /p ="!_:~%%W,1!"<nul
Edit: Ahh, here is a better version:
Code: Select all
@setlocal enabledelayedexpansion&@(for /f "delims=" %%H in (%~n0.bat) do @for %%W in (54,2,4,8,5,9,80,30,37,14,16) do @set _=%%H&set O_=!O_!!_:~%%W,1!)&set /p="!O_!^!"<nul