#include #include "miosix.h" const int keyLen=16; // Do not change /** * Print a key * \param key a 16 byte nonterminated array */ void printKey(unsigned char key[keyLen]) { for(int i=0;i // #include // using namespace boost; // int main() // { // const int keyLen=16; // unsigned char key[keyLen]; // for(int i=0;i crc; // char data[4]={0,0,0,i+1}; // crc.process_bytes(data,4); // unsigned int out=crc.checksum(); // for(int j=0;j<4;j++) key[4*i+j]=(out>>8*j) & 0xff; // } // for(int i=0;iAHB1ENR |= RCC_AHB1ENR_CRCEN; unsigned char key[keyLen]; for(int i=0;iCR=CRC_CR_RESET; usleep(5); //Quirk: without this delay the write to CRC->DR is ignored CRC->DR=i+1; unsigned int crc=CRC->DR; for(int j=0;j<4;j++) key[4*i+j]=(crc>>8*j) & 0xff; } printKey(key); } int main() { for(;;) { iprintf("\nWelcome to the PoliCTF's C.K.I.C.K.O.W.K.I.S.O. utility\n" "(correct key in correct key out, wrong key in shit out)\n" "Please enter your key\n"); unsigned int key; iscanf("%u",&key); // This is a totally randomly thought function, but for some // input numbers like 740 producea an output greater than 94700 // #include // int main() // { // for(uint32_t i=0;i<1000;i++) printf("%u %u\n",i,177*i & (i<<7)); // } key=177*key & (key<<7); if(key<47300) fuffa1(); else if(key<94700) fuffa2(); else fuffa3(); } }