Mass IDOR Enumeration
Repeat what you learned in this section to get a list of documents of the first 20 user uid's in /documents.php, one of which should have a '.txt' file with the flag.
If you followed along the section, you are probably trying to get the uid parameter from the URL.


The uid parameter is actually been sent in the POST Request. You can confirm this in the inspect element or intercept the Request with Burp Suite.
Since we have the POST data lets try to use curl with the following command to get the html code.

We get the filenames in the HTML. Now we need to found a way to automate this process and get only .txt matches:
Here is a breakdown for the script:
Define URL:
Set the variable
urltohttp://SERVER_IP:SERVER_PORT.
Outer Loop:
Iterate
ifrom 1 to 20.
Inner Loop:
Use
curlto send a POST request todocuments.phpwithuid=$i:-soption makescurlsilent (no progress or error messages).
Pipe the response to
grepto find links to.txtfiles:Regex Used:
\/documents\/[^'\" ]*?\.txt\/documents\/: Matches the string/documents/.[^'\" ]*?: Matches any characters that are not a single quote, double quote, or space (non-greedy).\.txt: Matches the string.txtat the end.
Download Files:
For each extracted link, use
wgetto download the file from the constructed URL ($url/$link):-qoption makeswgetquiet (no output).
End of Loops:
Close both the inner and outer loops.


And we got a match! When we open this .txt file we can see indeed that it is our flag!
Last updated