Pwnable Task: [Cmd1]
I have solved another pwnable CTF challenge, this time it was the “Cmd1″ challenge. The code file for this particular challenge was rather small, only around 10 lines. The code was fairly straight forward. If your input contained the certian terms “flag”, “sh”, or “tmp” it would be rejected, otherwise, it would place the input into the system() function. I looked up what the system() function does and it simply takes its input and runs it as code. I noticed that the code that would provide us with the flag would be along the lines of “cat flag” however this would be rejected to the the “flag” check in filter. I was also curious as to what exactly the putenv(...) line of code was doing so I checked the file path and found that it was a list of all the directories where the data was located. After trying to figure out exactly what this would do, I found at that it meant I needed to enter the whole path of the cat data (i.e. add /bin to it). This resolved the environment issue but I was still at a loss over how to get around the filter function. After looking up how to get around it, I found that adding quotation marks when entered result in an output without the quotation marks (i.e. ‘f’’l’’a’’g’, would lead to flag). I thought I may as well try this and entered the input “/bin/cat ‘f’’l’’a’’g’” which turned out to work and printed out the flag.
From this challenge, I learnt what the putenv() function does and how quotation marks in a line of input can be removed when entered in output.










