hey having trouble understanding wha the program does
Nov 2, 2014 at 4:28am UTC
i know that the password can't be less the 13 but is the username in asII form i don' get the point if the first few if
Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
int main(int argc, char ** argv) {
int8_t str[255];
int8_t v1[255];
// bb
printf("Enter your username:" );
scanf("%s" , v1);
printf("Enter password:" );
scanf("%s" , str);
int32_t puts_rc; // 0x80485a6
if (v1[0] == 101) {
// 0x8048562
if (v1[1] == 116) {
// 0x804856e
if (v1[2] == 0) {
int32_t str_as_i = atoi(str); // 0x8048581
if (str_as_i < 13) {
// 0x804859f
puts_rc = puts("Incorrect username or password. Goodbye." );
if (str_as_i == 12) {
// 0x80485ce
return puts_rc;
}
} else {
// 0x80485b9
puts_rc = puts("Welcome" );
// branch -> 0x80485c9
}
// 0x80485c9
__stack_chk_fail();
// branch -> 0x80485ce
// 0x80485ce
return puts_rc;
}
}
}
// 0x80485b9
puts_rc = puts("Incorrect username and/or password. Goodbye." );
// branch -> 0x80485c9
// 0x80485c9
__stack_chk_fail();
// branch -> 0x80485ce
// 0x80485ce
return puts_rc;
Nov 2, 2014 at 4:59am UTC
There if (v1[2] == 0)
in ascii 0 is null character and inside c string null character mark the end of string, that means the user name can't be more than 2 character -.-)a