collision
Source code :
Challenge contraints:
Length of the passcode should be 20 bytes (line number 19)
After the magic done in the function
check_password
the returned value should be equal tohashcode(hex: 0x21DD09EC, int: 568134124)
(line number 24)
The first constraint is not a problem, however, to solve the second contraint we will have to take a look at the check_password
function and understand exactly what is it doing.
check_password
function source code:
Function input: const char* p
and the value passed while calling is the argv[1]
i.e. a user controlled value.
In the line number 2 (check_password
) the parameter of const char*
has been casted to int*
, this is an important thing to notice as this will change how we will interpret the code that follows.
The for loop
on line 5-7 iterates over the int*
casted parameter and stores the sum of 5 values pointed by the pointer into a variable called res
NOTE:
++ operator
on achar*
pointer increments the value of the pointer by1 byte
and by4 bytes
if the pointer is of typeint*
This means we have to provide 5 integers in argv[1]
whose sum equals the value of hashcode (568134124)
After getting the 5 values we’ll have to send this within 20 bytes
of data, as evident now the number of bytes if we send this as text will be greater than 20 bytes, this can only be achieved if we send data as in hexadecimal values
and packed in little endian
format as follows:
Once we have all the little endian
packed bytes we can create our payload which will bypass the check_password if condition
on line 24 (main
)
Final Payload:
Run the payload using follwing command
Last updated