⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkos.c

📁 非常高效的扫描器
💻 C
字号:
#include "mscan.h"#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/wait.h>#include <sys/ioctl.h>#include <sys/stat.h>#include <netdb.h>#include <netinet/in.h>#include <string.h>int ADMtelnet (u_long, int port);char FILE_CMD_NAME[1024] = "cmd";u_long TIMEMETHAT = 50000;extern struct opts opts;void checkos(char *ip, int port) // -js{unsigned long temp;if(port == 23) {if(!opts.truncate)printf("\n - checking OS for %s \n", ip);}if(!opts.truncate) {if(port == 110)printf("\n - checking pop banner for %s\n",ip);}temp = inet_addr(ip);ADMtelnet(temp, port);}intADMtelnet (u_long ip, int port){  struct sockaddr_in sin;  u_char buf[4000];  int dasock, len;  int longueur = sizeof (struct sockaddr_in);  dasock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);	/* gimme a socket */  sin.sin_family = AF_INET;  sin.sin_port = htons (port);  sin.sin_addr.s_addr = ip;  if (connect (dasock, (struct sockaddr *) &sin, longueur) == -1)    return (-1);  while (1)    {      memset (buf, 0, sizeof (buf));      if ((len = read (dasock, buf, 1)) <= 0)	break;      if (*buf == (unsigned int) 255)	{	  read (dasock, (buf + 1), 2);	  if (*(buf + 1) == (unsigned int) 253 && !(u_char) * (buf + 2));	  else if ((u_char) * (buf + 1) == (unsigned int) 253)	    {	      *(buf + 1) = 252;	      write (dasock, buf, 3);	    }	}      else	{	  if (*buf != 0)	    {	      bzero (buf, sizeof (buf));	      read (dasock, buf, sizeof (buf));	      usleep(40000);if(!opts.truncate) printf("%s\n", buf); // js	if((strstr(buf, "Gate>") != NULL)) {	if(!opts.truncate)        printf("%s: SCAN: runs wingate.\n", inet_ntoa(ip));        return _WINGATE;        }	if((strstr(buf, "Red") != NULL)) {		if(!opts.truncate)	  printf("%s: SCAN: runs Red Hat linux.\n", inet_ntoa(ip));	return _REDHAT;	}        if((strstr(buf, "Linux") != NULL)) {	if(!opts.truncate)         printf("%s: SCAN: runs linux.\n", inet_ntoa(ip));        return _LINUX;        }        if((strstr(buf, "IRIX") != NULL)) {	if(!opts.truncate)         printf("%s: SCAN: runs IRIX.\n", inet_ntoa(ip));        return _IRIX;        }	if((strstr(buf, "AIX") != NULL)) {	if(!opts.truncate)	 printf("%s: SCAN: runs AIX.\n", inet_ntoa(ip));	return _AIX;	}        if((strstr(buf, "UNIX") != NULL)) {	if(!opts.truncate)        printf("%s: SCAN: runs solaris.\n", inet_ntoa(ip));        return _SOLARIS;        }        if((strstr(buf, "Sun") != NULL))        {	if(!opts.truncate)         printf("%s: SCAN: runs solaris.\n", inet_ntoa(ip));        return _SOLARIS;        }        if((strstr(buf, "Open") != NULL)) {	if(!opts.truncate)         printf("%s: SCAN: runs OpenBSD.\n", inet_ntoa(ip));        return _OPENBSD;        }        if((strstr(buf, "FreeBSD") != NULL)) {	if(!opts.truncate)         printf("%s: SCAN: runs FreeBSD.\n", inet_ntoa(ip));             return _FREEBSD;        }   	      sleep (1);	      return 1;	    }	}    }  return 0;}char *host2ip (char *serv){  struct sockaddr_in sinn;  struct hostent *hent;  hent = gethostbyname (serv);  if (hent == NULL)    return 0;  bzero ((char *) &sinn, sizeof (sinn));  memcpy ((char *) &sinn.sin_addr, hent->h_addr, hent->h_length);  return (inet_ntoa(sinn.sin_addr.s_addr));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -