Created
February 4, 2023 16:46
-
-
Save R3DHULK/802c3600d0ea033d62356064be880034 to your computer and use it in GitHub Desktop.
Subdomain Finder In C Programming
This file contains 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> | |
#include <string.h> | |
#define MAX_SUBDOMAINS 1000 | |
#define MAX_HOSTNAME_LEN 100 | |
int main(int argc, char *argv[]) | |
{ | |
int i; | |
char hostname[MAX_HOSTNAME_LEN]; | |
struct addrinfo hints, *res, *p; | |
if (argc != 2) { | |
fprintf(stderr, "Usage: %s <domain>\n", argv[0]); | |
return 1; | |
} | |
memset(&hints, 0, sizeof hints); | |
hints.ai_family = AF_UNSPEC; // allow IPv4 or IPv6 | |
hints.ai_socktype = SOCK_STREAM; | |
for (i = 0; i < MAX_SUBDOMAINS; i++) { | |
snprintf(hostname, MAX_HOSTNAME_LEN, "%d.%s", i, argv[1]); | |
if (getaddrinfo(hostname, "http", &hints, &res) == 0) { | |
printf("%s\n", hostname); | |
freeaddrinfo(res); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment