




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、網(wǎng)絡(luò)端口掃描實驗報告 1、 網(wǎng)絡(luò)端口掃描簡介TCP/IP協(xié)議在網(wǎng)絡(luò)層是無連接的,而“端口”,就已經(jīng)到了傳輸層。端口便是計算機與外部通信的途徑。一個端口就是一個潛在的通信通道,也就是一個入侵通道。對目標計算機進行端口掃描,能得到許多有用的信息。進行掃描的方法很多,可以是手工進行掃描,也可以用端口掃描軟件進行。在手工進行掃描時,需要熟悉各種命令,對命令執(zhí)行后的輸析出進行分,效率較低。用掃描軟件進行掃描時,許多掃描器軟件都有分析數(shù)據(jù)的功能。通過端口掃描,可以得到許多有用的信息,從而發(fā)現(xiàn)系統(tǒng)的安全漏洞。掃描工具根據(jù)作用的環(huán)境不同可分為:網(wǎng)絡(luò)漏洞掃描工具和主機漏洞掃描工具。前者指通過網(wǎng)絡(luò)檢測遠程目標網(wǎng)絡(luò)
2、和主機系統(tǒng)所存在漏洞的掃描工具。后者指在本機運行的檢測本地系統(tǒng)安全漏洞的掃描工具。本實驗主要針對前者。端口是TCP協(xié)議中定義的,TCP協(xié)議通過套接字(socket)建立起兩臺計算機之間的網(wǎng)絡(luò)連接。它采用【IP地址:端口號】形式定義,通過套接字中不同的端口號來區(qū)別同一臺計算機上開啟的不同TCP和UDP連接進程。端口號在065535之間,低于1024的端口都有確切的定義,它們對應(yīng)著因特網(wǎng)上常見的一些服務(wù)。這些常見的服務(wù)可以劃分為使用TCP端口(面向連接如打電話)和使用UDP端口(無連接如寫信)兩種。端口與服務(wù)進程一一對應(yīng),通過掃描開放的端口就可以判斷計算機中正在運行的服務(wù)進程。2、 實驗?zāi)康?.
3、了解熟悉MFC及的基本原理和方法。2. 加深對tcp的理解,學(xué)習(xí)端口掃描技術(shù)和,原理熟悉socket編程。3. 通過自己編程實現(xiàn)簡單的IP端口掃描器模型。4.通過端口掃描了解目標主機開放的端口和服務(wù)程序。三、實驗環(huán)境Windows操作系統(tǒng)VC+6.0開發(fā)環(huán)境四、實驗設(shè)計實驗原理通過調(diào)用socket函數(shù)connect()連接到目標計算機上,完成一次完整的三次握手過程,如果端口處于偵聽狀態(tài),那么connect()就可以成功返回,否則這個端口不可用,即沒有提供服務(wù)。實驗內(nèi)容1. 設(shè)計實現(xiàn)端口掃描器 2. IP地址、端口范圍可以用戶輸入。 3. 要求有
4、有好的可視化操作界面。實驗步驟: 1、用戶界面:使用vc6.0里的MFC來開發(fā)用戶界面 2、端口掃描:使用socket函數(shù)中的connect()連接計算機來判定目標計算機是否開放了要測試的端口五、代碼實現(xiàn)#include <afxext.h>#include <winsock.h>#pragma comment(lib,"wsock32.lib")#define ZERO (fd_set *)0int maxth, scanok, scannum;int portip, hoststart, hoststop, startport
5、, endport; long searchnum, searched;void usage(char *); void playx(int);void setip2(char *); void customport(char *, char *, char *); void portscannow(int);int main(int argc, char *argv)WSADATA wsadata;system("cls.exe");printf("rn= 命令行端口掃描器 PortScanner V1.0 =");if (argc < 3) |
6、 (argc > 4)usage(argv0);return -1;if(!(stricmp(strlwr(argv1), "-p") = 0)usage(argv0);return -1;if (WSAStartup(MAKEWORD(1,1), &wsadata) != 0) printf("rnWsatartup error"); return -1;if (argc = 3)setip2(argv2);elseif (argc = 4)customport(argv0, argv2, argv3);elseusage(argv0);
7、return -1;portscannow(argc);WSACleanup();return 0;void usage(char * prog)printf("Usage: %s <Option>", prog);printf("rnn <Option>:");printf("rn -p Port|StartPort-EndPort < HostName|IP|StartIP-EndIP >");printf("rnn Example: ");printf("rn %
8、s -p 192.168.0.1", prog);printf("rn %s -p 192.168.0.1-192.168.0.254", prog);printf("rn %s -p 21-80 192.168.0.1", prog);printf("rn %s -p 21-80 192.168.0.1-192.168.0.254rn", prog);return;void playx(int play = 0)char *plays12=" | "," / "," - &
9、quot;," "," | "," / "," - "," "," | "," / "," - "," ",;if (searchnum != 0)for (int i = 0 ; i <= 3; i +) printf(" =%s= %d%s Completed. r", plays , searched * 100 / (searchnum + 1), "%"); S
10、leep(5);else printf(" =%s=r", playsplay); Sleep(10);void setip2(char *cp)int host;struct hostent *testhost;char *startip = "", *endip = ""if (strstr(cp, "-") && strlen(cp) > 15 && strlen(cp) < 32)endip = strchr(cp, '-') + 1;strncp
11、y(startip, cp, strlen(cp) - strlen(strchr(cp, '-');hoststart = ntohl(inet_addr(startip);hoststop = ntohl(inet_addr(endip);elsetesthost = gethostbyname(startip); if(!testhost) WSACleanup( ); printf("rnCan't get ip of: %s", cp); exit(-1);memcpy(&host, testhost->h_addr, 4);
12、hoststop = hoststart = ntohl(host);void TestThread(int thread = 200)for (;)playx();if (maxth > thread) Sleep(100);else break;return;void WaitThreadEnd()Sleep(6000);printf("r rn");printf(" Wait ( %d )Thread end.rn", maxth);for(;)if (maxth > 0) Sleep(100); playx(); continue;e
13、lse break;printf("rn");return;void customport(char *cp, char *cp2, char *cp3)int intport;char *checker;startport = atoi(cp2);endport = atoi(cp2);if (strstr(cp2,"-")intport = atoi(checker = strchr(cp2, '-') + 1);if (intport > 0 && intport < 65536) endport = i
14、ntport;if (startport < 0 | startport > 65536 | endport < 0 | endport > 65535)usage(cp);exit(-1);setip2(cp3);UINT portscan(LPVOID port)int addr = portip; int sock;struct fd_set mask;struct timeval timeout;struct sockaddr_in server;unsigned long flag = 1;sock = socket(AF_INET, SOCK_STREAM,
15、 0);if (sock = INVALID_SOCKET)printf("rnSock Error:%s", WSAGetLastError();maxth -;return -1;server.sin_family=AF_INET;server.sin_addr.s_addr = htonl(addr);server.sin_port = htons(short(port); playx();if (ioctlsocket(sock, FIONBIO, &flag) != 0)printf("rnSock Error:%s", WSAGetL
16、astError();closesocket(sock);maxth -;return -1;connect(sock, (struct sockaddr*)&server, sizeof(server);timeout.tv_sec = 18;timeout.tv_usec = 0;FD_ZERO(&mask); FD_SET(sock, &mask); switch(select(sock + 1, ZERO, &mask, ZERO, &timeout)case -1: printf("rnSelect() error"); m
17、axth -; return -1;case 0: maxth -; closesocket(sock); return -1;default:if(FD_ISSET(sock, &mask) shutdown(sock, 0); printf(" Found: %s Port: %d open.rn", inet_ntoa(server.sin_addr), ntohs(server.sin_port); closesocket(sock); scanok +; maxth -; return 1;return 0;void portscannow(int xp)
18、int sport;char *timenow, timebuf32;char *ports32="21","22","23","25","53","79","80","110","111","113","123","135","139","143","443","512",&q
19、uot;513","514","515","540","1080","1433","1521","1524","3306","3389","5631","6000","6112","8000","8080","12345"timenow = _strtime(timebuf);printf
20、("rnPortScan Start Time: %srnn",timenow);maxth = 0;scanok = 0;scannum = 0;searched = 0;searchnum = hoststop - hoststart +1;if(xp = 3)searchnum = searchnum * 32;if(xp = 4)searchnum = searchnum * (endport - startport +1);for (portip = hoststart; portip <= hoststop; portip +, scannum +)if
21、(portip % 256) = 0 | (portip % 256) = 255) if(xp = 3) searchnum = searchnum - 32; if(xp = 4) searchnum = searchnum - (endport - startport +1); scannum -; playx(); continue;if (xp = 3) for (sport = 0; sport < 32; sport +, maxth +, searched +) TestThread(180); CWinThread * pthread = AfxBeginThread(portscan,LPVOID(atoi(char*)portssport); Sleep(120); if (xp = 4) sport = endport - startport; if(sport > 500 ) for(sport = startport; sport <= endport; sport +, maxth +, searched +) TestThread(2000); CWinThread * pthread = AfxB
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 個人財產(chǎn)安全設(shè)備銷售與租賃合同
- 外墻保溫裝飾一體板施工合同
- 學(xué)校專家聘用合同
- 關(guān)于提高工作效率的溝通機制研究報告
- 鄉(xiāng)村發(fā)展行動指導(dǎo)書
- 制造業(yè)企業(yè)數(shù)字化轉(zhuǎn)型實施方案
- 核電安全施工方案模板
- 籃球場工程施工方案
- 河南電力電纜線槽施工方案
- 建筑工程切險保險合同
- DB12T 1315-2024城市內(nèi)澇氣象風險等級
- 歷史-浙江天域全國名校協(xié)作體2025屆高三下學(xué)期3月聯(lián)考試題和解析
- 軟膠囊成本結(jié)構(gòu)分析-深度研究
- 2025年安徽國防科技職業(yè)學(xué)院單招職業(yè)技能考試題庫必考題
- 客房專業(yè)知識培訓(xùn)課件
- 高等數(shù)學(xué)(慕課版)教案 教學(xué)設(shè)計-1.3 極限的運算法則;1.4 極限存在準則與兩個重要極限
- GA/T 761-2024停車庫(場)安全管理系統(tǒng)技術(shù)要求
- 大學(xué)生創(chuàng)新創(chuàng)業(yè)基礎(chǔ)(創(chuàng)新創(chuàng)業(yè)課程)完整全套教學(xué)課件
- 人教版小學(xué)數(shù)學(xué)四年級下冊第一單元測試卷附答案(共9套)
- (完整版)形式發(fā)票模版(國際件通用)
- GM∕T 0036-2014 采用非接觸卡的門禁系統(tǒng)密碼應(yīng)用指南
評論
0/150
提交評論