Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <signal.h>
  8. #include <sys/wait.h>
  9.  
  10. #define SECONDS 10
  11.  
  12. void sigHandler(int sigNum);
  13.  
  14. void main(int argc, char** argv)
  15. {
  16. signal(SIGALRM, sigHandler);
  17. alarm(SECONDS);
  18. /*รงa marche pas !!!!!
  19. const char* myStr = "Hello vorld.\n";
  20. int output;
  21. asm("mov $39, %eax");
  22. asm("mov %1, %ebx" : "=r" (output) : "r" (&myStr));
  23. asm("mov $0x0, %ecx");
  24. asm("int $0x80");
  25. //*/
  26. char* buffer = malloc(255);
  27. printf("Entrez le mot de passe:\n");
  28. scanf("%s", buffer);
  29. if(strcmp(buffer, "testlol") == 0)
  30. {
  31. printf("Bravo :o\n");
  32. }
  33.  
  34. }
  35.  
  36. void sigHandler(int sigNum)
  37. {
  38. if(sigNum == SIGALRM)
  39. {
  40. static int amnt = 3;
  41. amnt--;
  42. if(amnt > 0)
  43. {
  44. printf("10s ecoulees. Il vous reste %d essai%s.\n", amnt, amnt!=1?"s":"");
  45. alarm(SECONDS);
  46. }
  47. else
  48. {
  49. perror("Temps total ecoule. Fermeture du programme.\n");
  50. exit(0);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement