I'm doing a small exercise with command injections, and I have this command that I can make injections into:
grep -i $key dictionary.txt
where $key is the part I can inject something into.
Now, I know the intended solution here is to use ; to terminate one statement, and then construct a new one.
But I wanted to see if I could use the grep in my attempt.
What I want to do is to run ls, in order to see the files in a specific directory.
I want to use the two in conjunction like so:
ls | grep -i "."
But, since I'm doing an injection, I need the grep -i to be first.
So is there anything I can do? perhaps a pipe operator that works in the "reverse" order?
grep -i "." <| ls
EDIT
There seems to be a bit of confusion as to what I am doing here, and what I am trying to achieve.
I am doing some introductory exercises on pen-testing.
My current exercise is to do a injection on a website, that has this string in it:
grep -i $key dictionary.txt
and then uses that string to run a command. I need to inject something into this string, which will be a command injection.
I do not have control over the string as it is already written on the server, and thus I cannot put anything in to the left of grep -i.
I have a solution already, where I inject the following:
; ls /etc/natas_webpass #
Which then (when I inject it) creates this command which runs on the server
grep -i ; ls /etc/natas_webpass # dictionary.txt
Buy I would like to try to solve this exercise not using the semicolon, but perhaps actually use grep that is already there.
EDIT 2
A suggestion has been made that I am simply looking for <(ls).
I tried testing this by running:
$ grep -i <(ls)
This does not work, though; nothing happens.