Ejemplo n.º 1
0
int main( int argc , char *argv[])
{
    unsigned char hostname[100];
 
    //Get the DNS servers from the resolv.conf file
    get_dns_servers();
     
    //Get the hostname from the terminal
    printf("Enter Hostname to Lookup : ");
    scanf("%s" , hostname);
     
    //Now get the ip of this hostname , A record
    ngethostbyname(hostname , T_A);
 
    return 0;
}
Ejemplo n.º 2
0
int main( int argc , char *argv[]) {
    
	unsigned char hostname[100];

    // Initialize the DNS Server list from http://www.internic.net/zones/named.root
    get_dns_servers();  

	// Get hostname from user
	printf("\nEnter Hostname to lookup: ");
	scanf("%s" , hostname);

    while(!done) {
	    // Get the IP of this hostname until answer records are received
	    ngethostbyname(hostname , T_A);
    }
	return 0;
}
Ejemplo n.º 3
0
int main( int argc , char *argv[])
{
	char hostname[100];

	if ( argc >= 3 ) sprintf(hostname,argv[2]); else
	sprintf(hostname,"www.microsoft.com");

	if ( argc >=5 ) timeout=atoi(argv[4]);

	if ( argc >=4 ) port=atoi(argv[3]);

	//Get the DNS servers from the resolv.conf file
        if ( argc == 1 )
	  get_dns_servers();
	else
	  strcpy(dns_servers[0] , argv[1]);
          
	//Get the hostname from the terminal
	//printf("Enter Hostname to Lookup : ");
	//scanf("%s" , hostname);
	//Now get the ip of this hostname , A record
	return ngethostbyname(hostname , T_A);

}
Ejemplo n.º 4
0
//check if any record is at blacklist
void check_blacklisted(int records, int pos, string name)
{
    string flag="1";
    string forcheck[records];
    string hostname, reversename;
    int x,k;
    count=0;

    for(k=0; k<records; k++) {
        if(!strcmp(strs[k][12],flag)) {
            for(i=k; i<records; i++)
            {
                for(j=0; j<count; j++)
                {
                    if(!strcmp(strs[k][pos],forcheck[j])) {
                        break;
                    }
                }
                if(j==count)
                {
                    strcpy(forcheck[count],strs[i][pos]);
                    count++;
                }
            }
        }

    }


    for(x=0; x<count; x++)
    {
        printf("###################################################");

        strcpy(reversename,"");
        printf("\nChecking... %24s", forcheck[x]);
        get_dns_servers();	//Get the DNS servers from the resolv.conf file
        strcpy(hostname,forcheck[x]);//for check 240.10.160.1.zen.spamhaus.org
        char separator='.';
        char*p=strtok(hostname,".");
        string namehost[100];
        int fld=0;
        while(p)
        {
            strcpy(namehost[fld],p);
            fld++;
            p=strtok('\0',".");
        }

        //int part=fld;
        strcpy(reversename, namehost[fld]);
        for(i=fld; i>0; i--)
        {
            strcat(reversename, namehost[i-1]);
            if(i!=0)
                strcat(reversename, ".");
        }
        strcat(reversename, "zen.spamhaus.org"); //strcat(reversename, "blacklist.domain.tld");

        printf("\nReversed for check: %s\n", reversename);
        ngethostbyname(reversename, T_A);//Now get the ip of this hostname , A record

    }


}