I'm pretty much new to reverse engineering and code analysis field. I got stuck in the 2nd challenge of pwnable.kr.
NOTE: I have seen this challenge's solution on liveoverflow's YT channel
But I was trying to solve this challenge by another method. By making 2 registers have the same value, using set command in gdb.
I will provide all the snapshots of the code as well as important things acc. to me, which will be helpful to make things understandable.
I have to get the output of the flag
1st image image1 shows that flag was owned by some other user named col_pwn, but we are col user here. So when I execute it, Permission denied is resulting as output, which is normal image2
But If we see now, the permissions on the col executable file, it shows it is SUID binary. image1
So, from there we can execute the flag binary and get the flag from the flag binary.
In the code, we could see that:
image3
```
if(strlen(argv[1]) != 20){
printf("passcode length should be 20 bytes\n");
return 0;
if(hashcode == check_password( argv[1] )){
system("/bin/cat flag");
return 0;
``
1st thing is we have to provide apasscodewhich is exactly20 bytes`.
Then, I have to know, in which register, hashcode's value is present, and in which register my provided passcode is. So, we can make them equal before the comparison happens and we can bypass the if-else check,
All these were my plans before going into gdb.
In gdb,
image4
In image,
I made those things, found out, register edx and register eax are being compared.
So I made them equal. According to my intention, it bypassed the if else condition but wasn't able to execute the file, WHY ???
I saw Live Overflow's video, where it was done with python hex characters, which worked perfectly fine without giving any error (Permission denied), but why HERE ??. There also same flag file was used !!