Jerkiller

crackme

Dec 14th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <stdlib.h>
  3. #include <signal.h>
  4. #include <string.h>
  5.  
  6. #define POUT "tmpPipeInput"
  7. #define PIN "tmpPipeOutput"
  8.  
  9. void die(char *s) {
  10.     perror(s);
  11.     exit(EXIT_FAILURE);
  12. }
  13.  
  14. int main() {
  15.     int out;
  16.     int in;
  17.     int codice = 0;
  18.     char leggi[100];
  19.      
  20.     mkfifo(POUT,0666);    // crea la pipe, se esiste gia' non fa nulla
  21.     mkfifo(PIN,0666);    // crea la pipe, se esiste gia' non fa nulla
  22.      
  23.     if ( (out = open(POUT,O_RDWR)) < 0 )
  24.         die("errore apertura pipe\n");
  25.      
  26.     if ( (in = open(PIN,O_RDWR)) < 0 )
  27.         die("errore apertura pipe\n");
  28.      
  29.     while(codice < 99999){
  30.         write(out, &codice, sizeof(int));
  31.          
  32.         int r=0;
  33.         while ( r<100 && read(in, &leggi[r], 1 ) && leggi[r] != 0 )
  34.             r++;
  35.          
  36.         if (leggi[4] == 'c'){
  37.             printf("il pin corretto รจ:%d\n", codice);
  38.             return 0;
  39.         }
  40.         codice++;
  41.     }
  42.      
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment