Evlz CTF 2019: WeTheUsers [ Basic ]
- Challenge: WeTheUsers
- Category: Web (Basic)
- Functionalities provided: Register user , login interface
- Source code provided: https://pastebin.com/VWmk2Jdy
Analysis
We need to focus on following important code snippets -
Password data storage structure
The password data is stored in “username:password:is_admin” format.
For solving this challenge we need to control third part i.e.is_admin section.
Storage of user registration data
User registration form source code -
If you look carefully , the 3rd parameter is marked as ‘false’
Based on following code, the third parameter controls if user has administrative privileges or not.Therefore, newly created users will always have admin = false.
Let’s check how application validates user permissions -
Parsing of password data
How application distinguish between username and password is defined by following code -
The data in password storage is split based on ’:’ character , therefore our original data username:password:is_admin is split into -
The username and password values are then verified -
The unpack code is suffering from critical issue, the value separation is only based on delimiter character ’:’. This allows us to control how password values are parsed. To exploit this issue and gain admin access, create user with following credentials-
then try to login using -
When application try to unpack values it will treat stored value -
username:password:true as –> username:password:true
Here 3rd parameter ( admin permission ) is true now, so we have admin access.Once we login as admin, flag will be displayed.