|
Re: external internet/process calls from a preprocessor: msg#00009security.ids.snort.devel
Hope this helps, here's the function I drunkenly glued together to try and make a DNS query: int dnscaller(int argc, char argv[NUM][LEN]) { char *addr, list[LEN]; int found = FALSE; f1 = fopen("bunchofcrap.txt", "a+"); if(argc<2) printf("incorrect input\n"); else { he = gethostbyname(argv[1]); if (he) { printf("name:\t\t\t %s\n", he->h_name); while (*he->h_aliases) printf("alias:\t\t\t %s\n", *he->h_aliases++); while (*he->h_addr_list) { bcopy(*he->h_addr_list++, (char *) &a, sizeof(a)); printf("address:\t\t %s\n", addr = (char*)inet_ntoa(a)); while ( fgets(list, sizeof(list), f1) != NULL) { list[strlen(list)-1] = '\0'; if (strcmp(list, addr) == 0) { found = TRUE; break; } } if(!found) fprintf(f1, "%s\n", addr); } } else { printf("dns failed.\n"); herror("gethostbyname"); return -1; } } fclose(f1); return 0; } NOTE: I added the herror("gethostbyname"); line just today, to try and spit out whatever error the DNS function was returning. I'm not sure if I'm invoking it properly, but it outputs something to the effect of "gethostbyname: Resolver Error 0: No Error" to stderr (console in this case). It should just print the resolved IP's to a textfile, but no text file is created obviously, since no resolving takes place. Also, I understand the performance concerns, but we're only invoking this function under very limited and specific circumstances, and even a few seconds to resolve the DNS wouldn't result in a significant performance problem under our circumstances; I just need to get this to work. Thanks again, --Dave Jason wrote: David Cann wrote: ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: external internet/process calls from a preprocessor: 00009, Jason |
|---|---|
| Next by Date: | Re: external internet/process calls from a preprocessor: 00009, Jason |
| Previous by Thread: | Re: external internet/process calls from a preprocessori: 00009, Jason |
| Next by Thread: | Re: external internet/process calls from a preprocessor: 00009, Jason |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |