1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
static void searchchar(char *chaine);
int main(int argc, char *argv[])
{
remove("testip.txt");
printf("\n[ Tests standards ]\n\n ");
char ip[20] = {0};
printf("\nAdresse ip de l'hote : ");
fgets(ip, sizeof ip, stdin);
searchchar(ip);
char out[] = " >> testip.txt";
char commande [512];
strcpy(commande, "ping -n 10 ");
strcat(commande, ip);
strcat(commande, out);
int ret = system (commande);
if (ret==1)
{
printf("\nHote %s injoignable \n\n", ip);
system ("type testip.txt");
}
else
{
system ("type testip.txt");
}
char commande2 [512];
strcpy(commande2, "nbtstat -A ");
strcat(commande2, ip);
strcat(commande2, out);
int ret2 = system (commande2);
if (ret2==1)
{
printf("Recuperation de la MAC => Erreur !\n\n");
system ("type testip.txt");
}
else
{
system ("type testip.txt");
}
char commande3 [512];
strcpy(commande3, "nslookup ");
strcat(commande3, ip);
strcat(commande3, out);
int ret3 = system (commande3);
if (ret3==1)
{
printf("nslookup => Erreur !\n\n");
system ("type testip.txt");
}
else
{
system ("type testip.txt");
}
char commande4 [512];
strcpy(commande4, "tracert ");
strcat(commande4, ip);
strcat(commande4, out);
int ret4 = system (commande4);
if (ret4==1)
{
printf("tracert => Erreur !\n\n");
system("pause");
system ("type testip.txt");
}
else
{
system ("type testip.txt");
}
printf("\n");
system("pause");
return 0;
}
static void searchchar(char *chaine)
{
char *p = strchr(chaine, '\n');
if (p)
{
*p = 0;
}
} |
Partager