I'm currently doing some practice about security and facing challenges provided in a website. One of them talks about LFI and I did figure out what to do, but I have no idea how to do this, so let's show you the problem:
Here is the url to hack:
http://example.com/challenge27/?page=contact
I'm asked to get the password in /etc/passwd
, so the first idea that comes is to try some directory transversal:
http://example.com/challenge27/?page=.
This throws an exception:
Warning: assert(): Assertion "strpos('includes/..php', '..') === false" failed
What is obvious is that the strpos
detects every occurrence of '..'
in the path and the assertion checks that this function returns a false value
Then I try it by adding a null byte at the end of the same url
http://example.com/challenge27/?page=.%00
which gives me another hint:
Warning: file_exists() expects parameter 1 to be a valid path
But here I'm blocked, my goal is to inject the path to /etc/passwd
like this:
http://example.com/challenge27/?page=../../../../etc/passwd
I feel like I can exploit the null byte solution but after trying many different urls either I got the file_exists() warning or the assert() one, I'm running out of ideas now, does somebody have one more hint to give?