1. sayfa
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <time.h> #include <windows.h> #include <winsock.h> /*winsock32.lib kütüphanesini eklemeyi unutmayın */ #define WIN32_LEAN_AND_MEAN void write_file(char *buf); int main (void) { WORD wVersionByCodeC; WSADATA wsaData; SOCKET sock; const int BUF_LEN=10000; struct sockaddr_in address; struct hostent * host; int err; float socklib_ver; char File_Buf[BUF_LEN]; char DomainName[100]; char HostName[100]; time_t tm; printf( "-----------------***************-----------------"); printf("\n----------------- ByCodeC Whois -----------------\n"); printf( "-----------------***************-----------------\n"); printf("ENTER hostname : "); gets(DomainName); strcat(DomainName, "\r\n"); strcat(HostName, "www.uwhois.com"); wVersionByCodeC = MAKEWORD( 1, 1 ); if ( WSAStartup( wVersionByCodeC, &wsaData ) != 0 ) printf("WSAStartup ERROR !!!\n"); socklib_ver = HIBYTE( wsaData.wVersion ) / 10.0; socklib_ver += LOBYTE( wsaData.wVersion ); if ( socklib_ver < 1.1 ) { printf ("\nError: socket versiyon hatasI !!!.\n"); WSACleanup(); exit(0); } time(&tm); sprintf(File_Buf, "Whois ba$LadI [ %.24s. ]\n\n", ctime(&tm)); write_file(File_Buf); if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET ) printf("\nsocket hatası !!!\n"); address.sin_family=AF_INET; address.sin_port = htons(43); sprintf(File_Buf,"Connecting to %s\n", HostName); write_file(File_Buf); if ( (host=gethostbyname(HostName)) == NULL ) printf("\nhostname hatası !!! \n"); address.sin_addr.s_addr=*((unsigned long *) host->h_addr); if ( (connect(sock,(struct sockaddr *) &address, sizeof(address))) != 0) printf("\nconnect hatası !!!\n"); strcpy(File_Buf, DomainName); err=send(sock,File_Buf,strlen(File_Buf),0); err=recv(sock,File_Buf,BUF_LEN,0); err=recv(sock,File_Buf,BUF_LEN,0); write_file(File_Buf); system("pause"); WSACleanup(); exit(0); } void write_file(char *buf) { FILE *fp=fopen("whoislog.txt","a+"); fprintf(fp,"%s\n",buf); fclose(fp); printf("%s\n",buf); }
< Resime gitmek için tıklayın >
derlenmiş ve çalışan hali için
http://www.dosyaupload.net/download.php?file=168141
heyde kolay gele...