// relevant stuff only regarding to the challenge
uint8_t FLAG1[16] = {'G', 'H', '{', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '}', '\0'}; // flag level 1
uint8_t NOPE[16] = {'*', 'a', 'c', 'c', 'e', 's', 's', ' ', 'd', 'e', 'n', 'i', 'e', 'd', '*', '\0'};
#if SS_VER == SS_VER_2_1
uint8_t password_GH(uint8_t cmd, uint8_t scmd, uint8_t len, uint8_t* pw)
#else
uint8_t password_GH(uint8_t* pw, uint8_t len)
#endif
{
const static char passwd[] = "GH{XXXXXXXXXXX}"; // flag level 2
uint8_t result = 0;
int cnt;
trigger_high();
//Simple test - doesn't check for too-long password!
for(uint8_t i=0; i < 15; i++) {
result |= pw[i] ^ passwd[i];
}
if (result == 0) {
simpleserial_put('r', 15, FLAG1); // impossible path without good password, you need to glitch to go there
} else {
simpleserial_put('r', 15, NOPE);
}
trigger_low();
#if SS_VER == SS_VER_2_1
return (result == 0) ? 0x10 : 0x00;
#else
return (cnt != 2500);
#endif
}
.....
int main(void)
{
platform_init();
init_uart();
trigger_setup();
.....
simpleserial_addcmd('z', 15, password_GH);
.....
}