I'm trying to write a program that takes a host and outputs the name of the httpd they are running, but this one doesnt seem to work:
When I compile and run it, it just sits there, does nothing after:Code:/* Httpd-Chk, by Tal0n 03-20-04 */ /* Uses fingerprints to try and identify httpd's... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(int argc, char *argv[]) { char buffer[4096]; char *data = "HEAD / HTTP/1.1"; int len = strlen(data); if(argc != 2) { printf("\nHttpd-Chk, by Tal0n 03-20-04\n"); printf("\nUsage: %s <host>\n\n", argv[0]); return 0; } if(argc == 2) { int sock; struct sockaddr_in remote; remote.sin_family = AF_INET; remote.sin_port = htons(80); remote.sin_addr.s_addr = inet_addr(argv[1]); if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("\nERROR: Can't create socket!\n\n"); return -1; } if(connect(sock,(struct sockaddr *)&remote, sizeof(struct sockaddr)) < 0) { printf("\nERROR: Can't connect to %s!\n\n", argv[1]); return -1; } printf("\nTrying to identify httpd on %s...\n", argv[1]); if(send(sock, data, len, 0) < 0) { printf("\nERROR: Can't send data to %s!\n\n", argv[1]); return -1; } sleep(5); memset(buffer, 0, sizeof(buffer)); read(sock, buffer, sizeof(buffer)); sleep(3); if(strstr(buffer, "Apache")) { printf("\n%s is running Apache Httpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "Xitami")) { printf("\n%s is running Xitami Httpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "Netscape")) { printf("\n%s is running Netscape Enterprise Server!\n\n", argv[1]); return 0; } if(strstr(buffer, "Zeus")) { printf("\n%s is running Zeus Httpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "IIS")) { printf("\n%s is running Microsoft IIS!\n\n", argv[1]); return 0; } if(strstr(buffer, "thttpd")) { printf("\n%s is running Thttpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "AOL")) { printf("\n%s is running AOLServer!\n\n", argv[1]); return 0; } if(strstr(buffer, "Lotus")) { printf("\n%s is running Lotus Httpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "Akami")) { printf("\n%s is running Akami Httpd!\n\n", argv[1]); return 0; } if(strstr(buffer, "Null")) { printf("\n%s is running Null Httpd!\n\n", argv[1]); return 0; } close(sock); return 0; } return 0; }
All help is much appreciated.Code:Trying to identify httpd on xx.x.xxx.xx...
Thanks,
-Tal0n



LinkBack URL
About LinkBacks


