At http://10.10.157.185:8080/, only an error page without information is available. We may need to look for other directories and files at the root of the web server.
There is a demo page displaying ErrorDocument 403 /var/www/html/403.html and not so many other files.
I'm clueless when it comes to reverse engineering, and I'm not interested into that part. So rather than trying to play with assembly to modify the shell code (transform my IP address and port into ARM ASM) I'll rather read another write-up solution and copy a ready-to-go PoC for that part:
WU n°1: perl script, doesn't require getting a reverse shell or something, will just enable login over telnet without credentials.
It looks like from the machine we have another behavior on the web server on port 8080, it's asking for credentials instead of just having a HTTP 403.
Browsing with curl is not handy, and there is no tool from the busybox that can be used for pivoting, so let's upload a static binary on it. But first let's check the architecture:
We were previously trapped in /emux/TRI227WF/rootfs.
We have now access to binaries that could help for pivoting like dropbear (SSH server) or socat (socket utility with proxy support).
Note: no need for uploading static binary because after escaping the chroot you can use the host socat, but for what we have to do we don't even need socat, curl is enough and curl is available from the chroot, so we didn't even need to escape.
So as we saw with the HTTP 401, http://10.10.157.185:8080/ is asking for credentials. Let's re-use the ones we found earlier.
With credentials, basic authentication worked, but we are now redirected to /login.php. -u ignore provides the credentials for authentication, --basic is the authentication method by default so no need to provide it, -I to show the response headers instead of the body.
Let's add -L to follow redirections.
We have a login form. Let's try to perform a POST request to authenticate.
We can see tehre is an error message Invalid username or password, let's try the same admin credentials.
Same. Let's try some injections then.
Trying a single quote for SQL injection ('username=admin&password=%27') gives the same result.
Trying a NoSQL injection paylod using [$ne] shows a redirection like if the authentication was a success. -D is for displaying the headers to a file, -D - to display them to STDOUT. -o is for saving the output to a file, -o /dev/null to hide the output (body) so we can see only the headers.
If we are redirected, we will need to store cookies somewhere, else we won't be authenticated on next request and will be redirected to the login page again.
For that we can use -c to store cookies to a file and get session persistence.
But nothing interesting in the response when connected as Frostbite. Maybe we need to get another user. admin doesn't sound to exist. If we weren't lazy enough to use socat to get a proxy, we could have used a blind NoSQLi extraction script using [$regex] to get the username and even the password. But we're to lazy right? 😏 And (some of) lazy persons tend to be the smartest engineers. In the end, you have to get nice idea and efficient solutions in order to save you efforts. So let's keep with curl (and bash).
It's still a bit of effort to write bash. And more seriously we got lucky the username was in our list. So let's find something more reliable (and smarter / more elegant).
We can use NoSQL $nin operator (not in) to exclude some results (the ones we already found and that are giving nothing).
Let's keep adding to the list:
Let's enhance this to build the payload dynamically as it can keep going long (we lost, we'll write bash).
Replace $ with %24 (url-encoded) so we don't have to deal with shell escaping. The shell is old, in newer bash (4.4+) we could use ${payload@Q} syntax instead, allowing escaping so $nin doesn't get interpreted.
So the full list of users is:
Let's see a size difference in response ouput: (yeah still bash now tha twe are used to it)