I am practicing the Astalavista Wargames and i came across this challenge. The question is: Bob wrote a piece of software but the password verification doesn't seem to work. You must find a way to log on. We were able to recover some part of the source:
typedef struct {char pass[5],valid;} password;
int main(){
password s;
s.valid=0;
scanf("%s",s.pass);
verifypass(s);
//if password is correct the value of s.valid will change to 1
if(s.valid==1)login();
else printf("Wrong passwordn");
system("Pause");
return 0;
}
Link to original provided executable file in the question . Note that the question does not provide anything else beside this part of code and executable file.
My initial thought was that this should be done using buffer overflow attacks, so just as a common approach on my x64 machine I try to enter 1 to change the valid bit to TRUE.
when I enter this number of 1's "1111111111111111111111111111" the program allows me to enter the password again, BUT not logging in. If I enter less, it would show the wrong password and exit and if I enter more it would crash.
How can I come up with a solution to this challenge?
(char)1, not with the digit'1'(ascii 49)? – CodesInChaos Feb 21 at 15:55verifypassfunction??? – Rook Feb 21 at 16:0449('1') into thevalidbyte would fail the==1test, but writing1would pass. – CodesInChaos Feb 21 at 18:04