In some cases, web applications make hashes or encode their object references, making enumeration more difficult, but it may still be possible.
Let’s say we can download a file called Employment_contract.pdf
.
Download request looks as follows:
Above hash type seems to be in an md5
format.
We can attempt to hash various values, like uid
, username
, filename
, and many others, and see if any of their md5
hashes match the above value. If we find a match, then we can replicate it for other users and collect their files.
For example, let’s try comparing md5
hash of our uid
and see if it matched:
Unfortunately, it doesn’t match.
Function Disclosure
Many web developers may make the mistake of performing sensitive functions on the front-end, which would expose them to attackers.
For example, if the above hash is handled in the front-end, we can learn the function and replicate it.
If we take a look at the link in the source code, we see that it is calling a JavaScript function with javascript:downloadContract('1')
. Looking at the downloadContract()
function in the source code, we see the following:
Knowing the above’s function, we can reverse engineer to get the same hash as such:
Mass Enumeration
Let us write a simple bash script to retrieve all employee contracts.
We can start by calculating the hash for each of the first ten employees using the same previous command while using tr -d
to remove the trailing -
characters, as follows:
Next, we can make a POST
request on download.php
with each of the above hashes as the contract
value, which should give us our final script:
With that, we can run the script, and it should download all contracts for employees 1-10: