资源描述:
《08李倩 实验四 端口扫描操作》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、南京理工大学泰州科技学院实验报告书课程名称:《计算机网络安全教程》实验题目:实验四端口扫描操作班级:10信管(1)学号:1009120108姓名:李倩指导教师:袁宝华成绩:批阅教师:袁宝华2013年月日一、1.掌握使用PortScan工具软件进行端口扫描。2.掌握使用Socket实现端口扫描。二、实验内容1.使用工具软件PortScan扫描开放端口;2.利用TCP协议实现端口扫描。三、实验环境Winxp、Windows2000server、10/100MB网卡、IE6.0,VC6.0四、实验步骤Proj4_4#include#include#include
2、#include#defineBUFSIZE64#defineWSVERSMAKEWORD(2,0)#defineWINEPOCH2208988800#defineMSG"Isthisportyouopen?"#defineMAX_PACKET1024SOCKETconnectsock(constchar*host,constchar*service,constchar*transport);voiderrexit(constchar*,...);intmain(intargc,char*argv[]){char*host="localhost"
3、;/*hosttouseifnonesupplied*/char*service="5060";/*defaultservicename*/SOCKETs;/*socketdescriptor*/interrcnt=0;/*errorcount*/WSADATAwsadata;switch(argc){case1:break;case3:service=argv[2];/*FALLTHROUGH*/case2:host=argv[1];break;default:fprintf(stderr,"usage:file1.exe[host[port]]");exit(1);}if(WSASta
4、rtup(WSVERS,&wsadata))errexit("WSAStartupfailed");s=connectsock(host,service,"tcp");;(void)send(s,MSG,strlen(MSG),0);closesocket(s);WSACleanup();return1;}#ifndefINADDR_NONE#defineINADDR_NONE0xffffffff#endif/*INADDR_NONE*//*------------------------------------------------------------------------*co
5、nnectsock-allocate&connectasocketusingTCPorUDP*------------------------------------------------------------------------*/SOCKETconnectsock(constchar*host,constchar*service,constchar*transport){structhostent*phe;/*pointertohostinformationentry*/structservent*pse;/*pointertoserviceinformationentry*/st
6、ructprotoent*ppe;/*pointertoprotocolinformationentry*/structsockaddr_insin;/*anInternetendpointaddress*/ints,type;/*socketdescriptorandsockettype*/memset(&sin,0,sizeof(sin));sin.sin_family=AF_INET;/*Mapservicenametoportnumber*/if(pse=getservbyname(service,transport))sin.sin_port=pse->s_port;elseif((
7、sin.sin_port=htons((u_short)atoi(service)))==0)errexit("can'tget"%s"serviceentry",service);/*MaphostnametoIPaddress,allowingfordotteddecimal*/if(phe=gethostbyname(host))memcpy(&sin.sin_addr,phe->h