___ ........#..'..$ 东西呢, 那再写个程序搞定它,
/*************************superscan clear.c************************/
#include <stdio.h>
main(int argc,char *argv[])
{
FILE *in; /* inputfile定义 */
FILE *out; /* outputfile 定义 */
char buf[1024]; /* 缓冲区 */
int i,j;
if(argc<3)
{
printf("usage : %s <inputfile> <outputfile>",argv[0]);
exit();
}
in = fopen(argv[1],"r"); /* 读文件并差错 */
if(in == NULL)
puts("File open error");
out = fopen(argv[2],"w"); /* 写文件并查错 */
if(out == NULL)
puts("File write error");
while(fgets(buf,21,in) != NULL) /* 输入字串 */
{
for(i=0;i<18;i++)
{
if(buf[i] == '*') /* 字串替换 */
{
for(j=0;j<17;j++)
{
buf[i+j] = buf[i+4+j];
}
buf[i+17]='\n';
fputs(buf,out); /* 写入 */
}
}
}
fclose(in);
fclose(out);
}
/**************************************************************************/
用tc来编辑,可达到最好效果.
使用:
c:\> clear inputfile.txt outputfile.txt
inputfile 是superscan扫描结果文件
outputfile 是处理后要生成的文件,生成后为IP文件
第2步
通过telnet的返回banner来确定对反的系统类型.比如
c:\>telnet 209.249.249.171
SunOS 5.8
login:
从而判断对反的系统类型。
/**************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define PORT 23 /* 定义端口 */
#define MAX 1024 /* buf的长度 */
FILE *output; /* 定义outputfile */
main(int argc,char *argv[])
{
FILE *input; /* 定义inputfile */
char scan_ip[1024];
if(argc < 4)
{
usage(argv[0]);
exit(1);
}
if(argc== 4) {
if((output = fopen(argv[2],"w")) == NULL) { /* 创建并写入文件 */
printf("could not creat the outputfile\n");
exit(2);
}
fputs("\n",output);
if((input = fopen(argv[1],"r")) == NULL) { /* 读文件 */
printf("could not read the inputfile\n");
exit(2);
}
}
while(fscanf(input,"%s",&scan_ip) != EOF) /* 读取IP */
{
telnet_banner(scan_ip,argv[3]); /* telnet_banner()判断系统类型 */
}
exit(1);
}
int usage(char *pro) /* 帮助 */
{
printf(" System OS detector V0.1\n");
printf(" Welcome to www.9836.com \n");
printf("usage: %s <inputfile> <outputfile> <System OS>\n",pro);
printf("System OS 1.Sunos 2. Redhat 3. FreeBSD \n");
}
telnet_banner(char *ip,char *os)
{
struct sockaddr_in addr;
u_char buf[MAX];
int sock,size,i;
if((sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == -1) {
printf(" socket failt");
exit(1);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
addr.sin_addr.s_addr = inet_addr(ip);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr)) == -1) {
printf("connect failt");
exit(1);
}
while (1) { /* 接收banner的循环 */
memset (buf, 0, sizeof (buf)); /* buf的内容置为0 */
if ((size = read (sock, buf, 1)) <= 0) /* 从 sock缓冲中读出第一个字 */
break; /* 等待接收完毕 */
if (*buf == (unsigned int) 255) { /* 如何为空的话,在读入2个字 */
read (sock, (buf + 1), 2);
if (*(buf + 1) == (unsigned int) 253 && !(u_char) * (buf + 2) )
;
else if ((u_char) * (buf + 1) == (unsigned int) 253) { /* 如果buf[1]的内容为 253的话, 设置buf[1]为252,写入sock缓冲 */
*(buf + 1) = 252;
write (sock, buf, 3);
}
} else {
if (*buf != 0) {
bzero (buf, sizeof (buf));
read (sock, buf, sizeof (buf));
close(sock);
if( *os == 49) /* system os 为 1 */
if(strstr(buf,"SunOS") != 0) {
fprintf(output,"* scanhost %s",ip);
buf[12] = buf[14];
fprintf(output," \tOS : %s",(buf+3)); /* 写入文件 */
}
if( *os == 50) /* system os 为 2 */
if(strstr(buf,"Red Hat") != 0) {
fprintf(output,"* scanhost %s",ip);
buf[39] = ' ';
fprintf(output," \tOS : %s",(buf+1));
}
if( *os == 51) /* system os 为 3 */
if(strstr(buf,"FreeBSD") != 0) {
fprintf(output,"* scanhost %s",ip);
buf[20] = buf[27];
fprintf(output," \tOS : %s\n",(buf+1));
}
}
}
}
}
/**************************************************************************/
使用方法
$./detector
usage: ./detectop <inputfile> <outputfile> <system os>
systemos : 1. SunOS 2. Red Hat 3. FreeBSD
./detector 1.txt 2.txt 1
1.txt 为处理后的superscan扫描文件.
2.txt 为使用detector用的文件.
1 表示要找Sunos , 2 表示 Redhat , 3 表示FreeBSD
处理后
* scanhost 209.249.249.171 OS : SunOS 5.8
* scanhost 209.249.249.172 OS : SunOS 5.8
一目了然.
第三步
sunos_telnet的入侵,网上多的是。
网络的神奇作用吸引着越来越多的用户加入其中,正因如此,网络的承受能力也面临着越来越严峻的考验―从硬件上、软件上、所用标准上......,各项技术都需要适时应势,对应发展,这正是网络迅速走向进步的催化剂。
关键词:从编程到入侵