Madmouse

timing attack fundamentals for detecting a hypervisor,

Jan 30th, 2015
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. /// timing attack functions
  2. static inline long unsigned int rdtsc(void) /// simply gets the processor tick count since the machine was turned on
  3. {                       /// it resets every 50 years, so im not too worried about it lol
  4.     long unsigned int x;
  5.     asm volatile ("rdtsc" : "=A" (x));
  6.     return x;
  7. }
  8.  
  9. static long unsigned int StartingTime, EndingTime;
  10. void start_time(void)   /// get the start time and save the value
  11. {
  12.     StartingTime = rdtsc();
  13. }
  14.  
  15. long unsigned int check_time(void)
  16. {
  17.     EndingTime = rdtsc();   /// get the endtime
  18.     return (EndingTime - StartingTime); /// return the difference
  19. }
Advertisement
Add Comment
Please, Sign In to add comment