|
導(dǎo)讀網(wǎng)絡(luò)技術(shù)是從1990年代中期發(fā)展起來的新技術(shù),它把互聯(lián)網(wǎng)上分散的資源融為有機(jī)整體,實(shí)現(xiàn)資源的全面共享和有機(jī)協(xié)作,使人們能夠透明地使用資源的整體能力并按需獲取信息。資源包括高性能計(jì)算機(jī)、存儲(chǔ)資源、數(shù)據(jù)... 網(wǎng)絡(luò)技術(shù)是從1990年代中期發(fā)展起來的新技術(shù),它把互聯(lián)網(wǎng)上分散的資源融為有機(jī)整體,實(shí)現(xiàn)資源的全面共享和有機(jī)協(xié)作,使人們能夠透明地使用資源的整體能力并按需獲取信息。資源包括高性能計(jì)算機(jī)、存儲(chǔ)資源、數(shù)據(jù)資源、信息資源、知識(shí)資源、專家資源、大型數(shù)據(jù)庫(kù)、網(wǎng)絡(luò)、傳感器等。 當(dāng)前的互聯(lián)網(wǎng)只限于信息共享,網(wǎng)絡(luò)則被認(rèn)為是互聯(lián)網(wǎng)發(fā)展的第三階段。 大家是不是大都使用別人的工具來搞入侵呢, 我也是, 不過從學(xué)了編程以后, 老是想自己寫點(diǎn)程序, 然后用它來入侵,這里就是教你如何實(shí)現(xiàn)自己的的夢(mèng)想。 今天所要演示的是telnet的入侵, 近來的sunos_telnet搞的風(fēng)風(fēng)火火. 1.掃描一個(gè)IP段, 所以要寫個(gè)IP掃描器 2.Telnet banner check, 看telnet的反應(yīng), 所以要寫個(gè)system os check depent op telnet. 3.用sunos_telnet來測(cè)試, sunos_telnet.exe網(wǎng)上有下載. 第一步: /* simple tcp portscan */ /* 只對(duì)一個(gè)IP的掃描 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <netdb.h> #define START_PORT 1 #define STOP_PORT 1024 struct sockaddr_in addr; /* 以struct sockaddr_in 結(jié)構(gòu)定義 addr */ struct hostent *host; struct servent *reply; int sock, i; int start_port; /* 起始端口 */ int stop_port; /* 結(jié)束端口 */ int usage(char *pro) /* 幫助 */ { printf(" simple TCP scanner\n"); printf("usage: %s <Remote-host> <start port> <end port>\n",pro); exit(1); } int scan(int port) /* scan()掃描 */ { if((sock = socket(AF_INET,SOCK_STREAM,0)) < 0) { /* 建立socket描述符 */ printf("scan errno -> socket\n"); exit(1); } addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr = *(struct in_addr *)host->h_addr; if((connect(sock,(struct sockaddr *)&addr,sizeof(addr))) == 0) /* 建立連接,判斷端口 */ return 0; /* 成功 */ else return 1; /* 失敗 */ } int main(int argc,char *argv[]) /*主程序 */ { char *service; if(argc != 4) usage(argv[0]); start_port = atoi(argv[2]); /* 將argv[2]轉(zhuǎn)換成整數(shù)*/ stop_port = atoi(argv[3]); /* 將argv[3]轉(zhuǎn)換成整數(shù)*/ if(strcmp(argv[2],"-")== 0 && strcmp(argv[3],"-")== 0) { /* 對(duì)比 argv[2] argv[ 3] 和 "-"符號(hào) */ start_port = START_PORT; /* 如果是 "-" 的話,起始端口等于1 */ stop_port = STOP_PORT; /* 如果是 "-" 的話,結(jié)束端口等于1 */ } if(start_port > stop_port) { /* 如果起始端口大于結(jié)束端口 */ printf(" start port can not greater than stop port.\n"); usage(argv[0]); exit(1); } if((host = gethostbyname(argv[1])) == NULL) { /* 用gethostbyname() 來得到對(duì)方的信息 */ printf("can't get host info %s \n",argv[1]); exit(1); } printf("Scanning host %s from %d to %d ......................\n",argv[1], start_port,stop_port); for(i=start_port;i<=stop_port;i++) /* 使用for語(yǔ)句對(duì)每個(gè)端口進(jìn)行連接 */ { if(scan(i) == 0) { reply = getservbyport(htons(i),"tcp"); /* 用getservbyport得到端口信息 */ if(reply == NULL) /* 無(wú)法得到端口信息 */ service = "Uknown"; else service = reply->s_name; /* reply->s_name 是端口服務(wù) */ printf("Port %5d is open. \tservice <%s>\n",i,service); } close(sock); } } /*****************************************************************************/ 看懂上面的代碼嗎? 如果你看不懂的話, 或編寫不成功, 就用superscan吧, superscan掃描結(jié)果: * + 209.249.191.73 |___ 23 Telnet |___ ............ * + 209.249.191.74 |___ 23 Telnet * + 209.249.191.75 |___ 23 Telnet |___ ..... ..#..' * + 209.249.191.76 |___ 23 Telnet |___ ..... ..#..' * + 209.249.191.77 |___ 23 Telnet * + 209.249.191.78 |___ 23 Telnet |___ ..... ..#..' * + 209.249.202.166 |___ 23 Telnet |___ ..... ..#..' * + 209.249.202.167 |___ 23 Telnet |___ ..... ..#..' * + 209.249.202.168 |___ 23 Telnet |___ ..... ..#..' * + 209.249.242.3 |___ 23 Telnet |___ ............ * + 209.249.242.14 |___ 23 Telnet |___ ................User Access Verification....Password: * + 209.249.249.171 |___ 23 Telnet |___ ........#..'..$ * + 209.249.249.172 |___ 23 Telnet |___ ........#..'..$ 是不是很討厭前面的 * + 和 |___ 23 Telnet |___ ........#..'..$ 東西呢, 那再寫個(gè)程序搞定它, /*************************superscan clear.c************************/ #include <stdio.h> main(int argc,char *argv[]) { FILE *in; /* inputfile定義 */ FILE *out; /* outputfile 定義 */ char buf[1024]; /* 緩沖區(qū) */ int i,j; if(argc<3) { printf("usage : %s <inputfile> <outputfile>",argv[0]); exit(); } in = fopen(argv[1],"r"); /* 讀文件并差錯(cuò) */ if(in == NULL) puts("File open error"); out = fopen(argv[2],"w"); /* 寫文件并查錯(cuò) */ 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來編輯,可達(dá)到最好效果. 使用: c:\> clear inputfile.txt outputfile.txt inputfile 是superscan掃描結(jié)果文件 outputfile 是處理后要生成的文件,生成后為IP文件 第2步 通過telnet的返回banner來確定對(duì)反的系統(tǒng)類型.比如 c:\>telnet 209.249.249.171 SunOS 5.8 login: 從而判斷對(duì)反的系統(tǒng)類型。 /**************************************************************************/ #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的長(zhǎng)度 */ 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) { /* 創(chuàng)建并寫入文件 */ 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()判斷系統(tǒng)類型 */ } 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的循環(huán) */ memset (buf, 0, sizeof (buf)); /* buf的內(nèi)容置為0 */ if ((size = read (sock, buf, 1)) <= 0) /* 從 sock緩沖中讀出第一個(gè)字 */ break; /* 等待接收完畢 */ if (*buf == (unsigned int) 255) { /* 如何為空的話,在讀入2個(gè)字 */ 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]的內(nèi)容為 253的話, 設(shè)置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的入侵,網(wǎng)上多的是。 網(wǎng)絡(luò)的神奇作用吸引著越來越多的用戶加入其中,正因如此,網(wǎng)絡(luò)的承受能力也面臨著越來越嚴(yán)峻的考驗(yàn)―從硬件上、軟件上、所用標(biāo)準(zhǔn)上......,各項(xiàng)技術(shù)都需要適時(shí)應(yīng)勢(shì),對(duì)應(yīng)發(fā)展,這正是網(wǎng)絡(luò)迅速走向進(jìn)步的催化劑。 |
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!