# Blind OS command injection with output redirection (ENG 🇬🇧 | PL 🇵🇱)
Link: https://portswigger.net/web-security/os-command-injection/lab-blind-output-redirection
After clicking "Access the lab," we see a store page.

We click "Submit feedback."

While executing the command during this exercise, we will try to redirect the result of this command to a file located in the directory:
/var/www/imagesWe fill out the form with data and submit:

We go to Burp Suite, find our request, and send it to "Repeater":

Here we can test individual parameters:

Let's now check if we are able to execute any command. We will adjust our payload to see if this is possible. Our payload looks like this:
csrf=Obk1aI10DvBcnBIIm4cW4jcUTL7pZIU9&name=Adrian&email=adrian%40maryniewski.pl;sleep 10;&subject=SUBJECT&message=EVEN+BETTER+MESSAGE%21%2111oneoneAnd it works. I waited 10 seconds for this response:

The goal of this exercise is to check which user I have and save it to a file that will be in the directory:
/var/www/imagesLet's therefore change the command to whoami and redirect the result of this command, with the greater-than sign (">"), to the file output.txt:
/www/var/images/output.txtSo we change our command in this way:
csrf=pebQ5r7IcCmvSHnFar8ftsin5Zg7iCk4&name=Adrian&email=adrian%40maryniewski.pl;whoami > /var/www/images/output.txt;&subject=OH+SO+CLEVER+SUBJECT&message=EVEN+BETTER+MESSAGE%21%2111oneoneIn response from the server, we get a 500, but there is a good chance that the command was executed:

We can now go to any request that allows us to load, for example, images. We click on Home to go to the main page (where images are loaded). We have this disabled in our proxy, so let's deal with it first:

We click on "Filter settings: Hiding CSS, image and general binary content." We select the "images" option, then "Apply":

We refresh the main page ("Home").
We can now see what file display looks like - in the "Logger" tab: 
We see that we have such a request as:
GET /image?filename=47.jpg HTTP/2
We send it to the "Repeater" tab.
We change the file name from 47.jpg to output.txt:


We see the information that we completed the task:

Link: https://portswigger.net/web-security/os-command-injection/lab-blind-output-redirection
Po kliknięciu "Access the lab", widzimy stronę sklepu.

Klikamy "Submit feedback".

Wykonując komendę podczas wykonywania tego ćwiczenia, będziemy starali się przekierować wynik tej komendy do pliku, który znajduje się w katalogu:
/var/www/imagesWypełniamy formularz danymi i wysyłamy:

Przechodzimy do Burp Suite, odnajdujemy nasz request i wysyłamy go do "Repetera":

Tutaj możemy testować poszczególne parametry:

Sprawdźmy teraz, czy jesteśmy w stanie wykonać jakąś komendę. Dostosujemy nasz payload tak, aby sprawdzić, czy jest to możliwe. Nasz payload wygląda tak:
csrf=Obk1aI10DvBcnBIIm4cW4jcUTL7pZIU9&name=Adrian&email=adrian%40maryniewski.pl;sleep 10;&subject=SUBJECT&message=EVEN+BETTER+MESSAGE%21%2111oneoneI działa. Czekałem 10 sekund na tę odpowiedź:

Celem tego ćwiczenia jest to, żeby sprawdzić jakiego mam użytkownika i zapisać go do pliku, który będzie w katalogu:
/var/www/imagesZmieńmy zatem komendę na whoami i przekierujmy wynik działania tej komendy, znakiem większości (">") do pliku output.txt:
/www/var/images/output.txtZmieniamy zatem naszą komendę w ten sposób:
csrf=pebQ5r7IcCmvSHnFar8ftsin5Zg7iCk4&name=Adrian&email=adrian%40maryniewski.pl;whoami > /var/www/images/output.txt;&subject=OH+SO+CLEVER+SUBJECT&message=EVEN+BETTER+MESSAGE%21%2111oneoneW odpowiedzi od serwera dostajemy 500, ale istnieje spora szansa, że komenda się wykonała:

Możemy teraz przejść do jakiegoś requestu, który pozwala nam zaczytywać na przykład obrazki. Klikamy w Home, aby przejść na stronę główną (gdzie ładują się obrazki). W naszym proxy mamy to wyłączone, więc najpierw zajmijmy się tym:

Klikamy na "Filter settings: Hiding CSS, image and general binary content." Zaznaczamy opcję "images", a następnie "Apply":

Odświeżamy stronę główną ("Home").
Możemy teraz zobaczyć jak wygląda wyświetlanie plików - w zakładce "Logger": 
Widzimy, że mamy taki request jak:
GET /image?filename=47.jpg HTTP/2
Wysyłamy go do zakładki "Repeater".
Zmieniamy nazwę pliku z 47.jpg na output.txt:


Widzimy informację, że ukończyliśmy zadanie:
