After completing the OS Command Injection level on High, I was delving a little deeper so I could write it up. It seems that while the solution works on the web app the same command errors on the linux terminal.
DVWA command for the High level
127.0.0.1| |cat /etc/passwd
This works. Doesn't output the ping result but prints to screen the contents of /etc/passwd
If I use the exact same command on my linux terminal it errors. Code used to mimic the web application
ping -c 3 127.0.0.1| |cat /etc/passwd
I receive the error
bash: syntax error near unexpected token `|'
If I remove the spaces the command works as expected. I can't explain why the shell_exec PHP command passes the command to the OS, the OS runs it and displays the result, yet the direct approach errors. Technically the DVWA command shouldn't work?