Created
February 10, 2023 15:33
-
-
Save R3DHULK/ac1488a54a2600e59256e8469d22ad9d to your computer and use it in GitHub Desktop.
DNS Enumeration In C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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