Skip to content

Instantly share code, notes, and snippets.

@R3DHULK
Created February 10, 2023 15:33
Show Gist options
  • Save R3DHULK/ac1488a54a2600e59256e8469d22ad9d to your computer and use it in GitHub Desktop.
Save R3DHULK/ac1488a54a2600e59256e8469d22ad9d to your computer and use it in GitHub Desktop.
DNS Enumeration In C
#include <stdio.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: %s <domain>\n", argv[0]);
return 1;
}
char *domain = argv[1];
struct hostent *host;
host = gethostbyname(domain);
if (host == NULL) {
perror("gethostbyname");
return 1;
}
printf("[+] DNS Records for %s:\n", domain);
for (int i = 0; host->h_addr_list[i]; i++) {
struct in_addr addr;
memcpy(&addr, host->h_addr_list[i], sizeof(struct in_addr));
printf("[-] %s\n", inet_ntoa(addr));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment