diff --git a/Part2-FlushReload/attacker.c b/Part2-FlushReload/attacker.c index 80c4f35..86ddc14 100644 --- a/Part2-FlushReload/attacker.c +++ b/Part2-FlushReload/attacker.c @@ -17,6 +17,7 @@ int main() { int flag = -1; CYCLES time = -1; int offset = 0; + int new_offset = 0; // buf is shared between the attacker and the victim char *buf = allocate_shared_buffer(); @@ -26,7 +27,13 @@ int main() { } for(int i = 0; i < WAIT_TIME; i++); for(int i = 0; i < 10000; i++) { - offset = (AVAR * offset + CVAR) % 1024; + new_offset = (AVAR * offset + CVAR) % 1024; + if(offset == new_offset||offset-new_offset==1||offset-new_offset==-1) { + offset = (offset + 712) % 1024; + } + else { + offset = new_offset; + } time = measure_one_block_access_time((ADDR_PTR)buf + offset * 128); if(time < CACHE_HIT_THRESHOLD) { flag = offset;