信息安全工程实践_第1页
信息安全工程实践_第2页
信息安全工程实践_第3页
信息安全工程实践_第4页
信息安全工程实践_第5页
免费预览已结束,剩余16页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实践报告姓名朱杰学号20165346班级软信1603指导教师徐剑王学毅马毅程序实践名称信息安全工程实践二程序实践内容网络程序设计开设学期2017- 2018 第 二学期开设时间第17周 第19周报告日期2018 年 7 月 14 日评定人签字评定成绩评定日期东北大学软件学院一、程序实践概述1 、题目名称:Linux 操作系统及其相关命令,Linux 编程基础Linux 程序设计基础2、时间进度:12 学时3、开发环境:Ubantu二、问题分析1 、功能说明:熟练掌握如下Linux 命令。系统信息命令文件操作命令目录操作命令进程操作命令网络操作命令vi 命令:who,w,du,du,df 等:t

2、ouch,cp,mv,rm,find,grep,cat,more,sort:ls,dir,mkdir,rmdir,cd:ps,top,cal,last,whereis,date:ping,write,telnet,ftp,talk编程实现快速排序算法;实现文本文件拷贝函数copy(f_source, f_target)$ ./copy f1 f2以上程序执行后当前目录会形成一个新的文件编写一个程序,要求: 输入 N 个学生的学号和成绩,对学生成绩进行排序并把排序后的结果输出到平均成绩的学生的学号和成绩。score.txtf2 ,且其内容与f1 完全一致。并保存在stu.txt 文本文件中,文件

3、中 , 同时在屏幕上输出高于编写一个程序找出串str1 和串 str2 的所有最长公共子串。从文件file.in 中读出整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件t.out 中。要求:采用2叉有序树做为存储结构。(选作)2、解决方案:利用PPT中所提供的相关函数使用解决问题三、方案设计1 、模块结构:模块功能图和模块描述根据用户输入数组进行快速排序,然后输出排序后的数组用户创建f1 ,然后运行函数生成f2根据用户输入学生的数据,生成原数据stu 文本以及根据成绩进行排序并把排序后的结果输出到score 文本中,在屏幕上输出高于平均成绩的学生的学号和成绩根据用户输入的两个字

4、符串,找出最长公共子串读出文件中的整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件t.out 中2、数据结构: int a10 FILE *fp1,*fp2 struct studentint number;int score;student10 char a10,b10文本 f13、总体流程:给出流程图54、关键算法:给出关键算法描述 if (num>1) / 重复的判断条件,如果长度小于2,则不需排序while (i != j) for (j=num-1; i<j; j-) m+;if (aj<k) ai = aj;n+;break;for (i=0; i

5、<j; i+) m+;if (ai>k) aj = ai;n+;break;ai = k;sort(a, i);sort(a+i+1, num-i-1); while(c=fgetc(fp1)!=EOF)/ 将 f1 拷贝到 f2 中 fputc(c,fp2);putchar(c); for(i=0;i<m;i+)ai=studenti.score;sort(a,m);for(i=0;i<m;i+)/结构体排序for(j=0;j<m;j+)if(ai=studentj.score)strcpy(student1i.num,studentj.num);student

6、1i.score=studentj.score; fp=fopen("score.txt","w+");fwrite(&student1,sizeof(student1),1,fp); fclose(fp); for(i=0;i<len;i+)for(j=0;j<length;j+) strcpy(a, "0");p=i;q=j;while(s1p=s2q&&s2p!=0) am=s2q;p+;q+; m+; if(strlen(a)>strlen(b) strcpy(b,a); m=0;四、

7、调试记录给出测试用例编号用例描述测试结果修改情况分析2 1 3 4 5 6 7 8 9 101 2 3 4 5 6 7 89 10无程序运行正确在 f1 中输入asd生成了f2 ,打开后里面有asd无程序运行正确在屏幕中输入123456 80123457 70123458 60屏幕上输出:比平 均 成 绩 高的学 生 : 12345680无程序运行正确输入f1=abcdef输入f2=abcgkt最长公子串为: abc无程序运行正确五、创新说明用户可以自行定义数据,根据用户输入的数组进行排序将 f1 的内容同时在屏幕上输出,用户可以直接查看文件内容用户可以自行定义学生个数以及在屏幕上输入学生数据

8、,并且将成绩单独放到另一数组 排序后根据序号对结构体排序用户可以输入任一字符串进行对比一、程序实践概述1 、题目名称:Socket 编程基础( 1 )时间服务器( 2)远程文件备份服务器2、时间进度:8 学时3、开发环境:Ubantu二、问题分析1 、功能说明: 编程实现时间服务器编写一个网络时间服务器timeserver ,该服务器能应具有如下功能:够为网络上的用户提供时间服务,即为网络用户返回服务器的当前时间;记录发出请求的网络用户的IP 地址(保存到文件中),格式如下:IP 地址请求时间编写时间服务客户端timeclient , 该客户端能够向服务器发送时间服务请求,并把获得的时间返回给

9、用户。 编程实现远程文件备份服务器分别采用TCP或 UDP协议编写一个远程数据备份服务器,运行客户端将本地文件备份到远程的服务器中。服务器的功能:接受客户端请求,把客户端的文件进行备份(可以备份到指定的文件夹) 。客户端的功能:与远程服务器进行连接,在连接后把本地的文件发送给远程备份服务器。 设计并实现带身份认证的远程数据备份服务器(选作)在实验的基础上增加身份管理和认证功能:2、解决方案:服务器端过程就是socket->bind->listen->accept->Read,writesocket->connect->read,write对于客户端则是三、方

10、案设计1 、模块结构:2、数据结构:文件操作,time_t t , socket文件操作,socket3、 总体流程:4、关键算法: time_t t;if(argc!=2) / 获得 ip 地址printf("usage %s<ip address>n",argv0);return 0;if(he = gethostbyname(argv1) = NULL)printf("gethostbyname errorn");return 0;if(sockfd = socket(AF_INET, SOCK_STREAM, 0) = -1) pri

11、ntf("socket() error n");return 0;bzero(&server, sizeof(server);server.sin_family = AF_INET;server.sin_port = htons(PORT);server.sin_addr = *(struct in_addr *)he->h_addr);if(connect(sockfd, (struct sockaddr *)&server, sizeof(server) = -1) printf("connetc() errorn");retu

12、rn 0;recv(sockfd,(void *)&t,sizeof(time_t),0);printf("Time is %sn",ctime(&t);5、界面设计: 直接使用终端界面进行 四、调试记录给出测试用例编号用例描述测试结果修改情况分析1在 客 户 端 输 入 client connetc() 错 误将 ip 改 为 4这里的ip 地址应使用服 务端的ip 地址2在 客 户 端 输 入 client 4Time is SatJul710:48:30 2018此时结果正 确3在 客 户 端

13、输 入 client 4客户端输入/home/login/Desktop/f1.txt服务端输入/home/login/Desktop/f2.txt在服务端的文件夹里找到f2.txt,并且内容与f1 一致无程序运行正 确五、创新说明 拥有错误提示,即用户可以知道是哪个模块出错,方便进行检查 拥有用户认证功能,即登录时需要特定的用户名跟密码,客户端在屏幕上输入文件路径 上载,服务端再输入存贮的文件路径。2一、程序实践概述1 、题目名称:Libpcap 开发包使用2、时间进度:16 学时3、开发环境:Ubantu二、问题分析1 、功能说明:( 1)获取网络接口名字和掩码等信息(

14、 2)捕获数据包(单个数据包和多个数据包两种情况)( 3)以太网数据报捕获( 4) ARP数据包捕获2、解决方案:并把抓包结果输出在文使用QT图形化编程,将 4个功能分别对应4 个按钮点击事件,本框中三、方案设计1 、模块结构:2、数据结构:Libpcap3、总体流程:4、关键算法: 给出关键算法描述void getip()char error_contentPCAP_ERRBUF_SIZE;struct in_addr net_ip_address; /网络地址struct in_addr net_mask_address;/掩码地址/接口名字/网络地址字符串形式/掩码地址字符串形式/网络地

15、址/掩码地址char *net_interface;char *net_ip_string;char *net_mask_string;u_int32_t net_ip;u_int32_t net_mask;net_interface=pcap_lookupdev(error_content);/获取网络接口pcap_lookupnet(/获取网络和掩码地址net_interface,&net_ip,&net_mask,error_content) ;printf(" 接口名字为:%sn",net_interface);net_ip_address.s_ad

16、dr=net_ip;net_ip_string=inet_ntoa(net_ip_address);/网络地址转为字符串形式printf(" 网络地址为:%sn",net_ip_string);net_mask_address.s_addr=net_mask;net_mask_string=inet_ntoa(net_mask_address);/掩码地址转为字符串形式 printf(" 掩码地址为:%sn",net_mask_string);void getpacket()char error_contentPCAP_ERRBUF_SIZE;struc

17、t pcap_pkthdr protocol_header; /数据包头/libpcap 句柄/BPF 过滤规则/过滤规则/数据包内容/掩码地址/网络地址/网络接口content);/获取网络接口/获取网络和掩码地址pcap_t *pcap_handle;struct bpf_program bpf_filter;char bpf_filter_string="ip"const u_char *packet_content;bpf_u_int32 net_mask;bpf_u_int32 net_ip;char *net_interface;net_interface=pc

18、ap_lookupdev(error pcap_lookupnet(net_interface,&net_ip,&netmask,error_content) ;pcap_handle=pcap_open_live(net_interface,BUFSIZ,1,0,error_content);/网络接口,数据包大小,混杂模式,等待时间,错误信息pcap_compile(pcap_handle,&bpf_filter,bpf_filter_string,0,net_ip);/编译过滤原则pcap_setfilter(pcap_handle,&bpf_filter

19、); /设置过滤原则packet_content=pcap_next(pcap_handle,&protocol_header);/ 捕获一个数据包printf(" 从 %s 捕获了一个数据包n",net_interface);printf(" 数据包长度为:%dn",protocol_header.len);pcap_close(pcap_handle);void getpackets()void packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,c

20、onst u_char* packet_content)static int packet_number=1;printf(" 捕获数据包的个数为:%dn",packet_number);packet_number+;char error_contentPCAP_ERRBUF_SIZE;/数据包头/libpcap 句柄/BPF 过滤规则/过滤规则/数据包内容/掩码地址/网络地址/网络接口content); /获取网络接口/获取网络和掩码地址struct pcap_pkthdr protocol_header;pcap_t *pcap_handle;struct bpf_pr

21、ogram bpf_filter;char bpf_filter_string="ip"const u_char *packet_content;bpf_u_int32 net_mask;bpf_u_int32 net_ip;char *net_interface;net_interface=pcap_lookupdev(error pcap_lookupnet(netinterface,&net_ip,&net_mask,error_content) ;pcap_handle=pcap_open_live(net_interface,BUFSIZ,1,0,

22、error_content);/网络接口,数据包大小,混杂模式,等待时间,错误信息pcap_compile(pcap_handle,&bpf_filter,bpf_filter_string,0,net_ip);/编译过滤原则pcap_setfilter(pcap_handle,&bpf_filter);/设置过滤原则pcap_loop(pcap_handle,10,packet_callback,NULL);pcap_close(pcap_handle);void getethernet()struct ether_headeru_int8_t ether_dhost8; /

23、 目的以太网地址u_int8_t ether_shost8;/ 源以太网地址u_int16_t ether_type; /以太网类型 ;char error_contentPCAP_ERRBUF_SIZE;/数据包头/libpcap 句柄/BPF 过滤规则/过滤规则/掩码地址/网络地址/网络接口/数据包缓存/以太网地址/以太网类型struct pcap_pkthdr protocol_header;pcap_t *pcap_handle;struct bpf_program bpf_filter;char bpf_filter_string="ip"bpf_u_int32

24、net_mask;bpf_u_int32 net_ip;char *net_interface;const u_char *packet_content;u_char *mac_string;u_short ethernet_type;struct ether_header *ethernet_protocol;/ 以太网协议变量net_interface=pcap_lookupdev(error_content);/获取网络接口pcap_lookupnet(/获取网络和掩码地址 net_interface, &net_ip, &net_mask,error_content)

25、;pcap_handle=pcap_open_live(net_interface,BUFSIZ,1,0,error_content);/网络接口,数据包大小,混杂模式,等待时间,错误信息pcap_compile(pcap_handle,&bpf_filter,bpf_filter_string,0,net_ip); /编译过滤原则pcap_setfilter(pcap_handle,&bpf_filter);/设置过滤原则if(pcap_datalink(pcap_handle)!=DLT_EN10MB)return;packet_content=pcap_next(pcap

26、_handle,&protocol_header);/ 捕获一个网络数据包printf(" 从 %s 捕获了一个数据包n",net_interface);printf(" 该数据包时间信息为:%sn",ctime(const time_t*)&protocol_header.ts.tv_sec);printf(" 数据包长度为:%dn",protocol_header.len);ethernet_protocol=(struct ether_header*)packet_content;ethernet_type=nt

27、ohs(ethernet_protocol->ether_type);/ 获得以太网类型printf(" 以太网类型为:%04xn",ethernet_type);switch(ethernet_type)case 0x0800: printf(" 协议类型为IP 协议 n");break;case 0x0806: printf(" 协议类型为ARP 协议 n");break;case 0x8035: printf(" 协议类型为RARP 协议 n");break;default: break;mac_str

28、ing=ethernet_protocol->ether_shost;/ 获得源以太网地址printf("源以太网地址为 : %02x:%02x:%02x:%02x:%02x:%02x",*mac_string,*(mac_string+1),*(mac_string+2),*(mac_string+3),*(mac_string+4),*(mac_string+5);mac_string=ethernet_protocol->ether_dhost;/ 获得目的以太网地址printf("目的以太网地址为 : %02x:%02x:%02x:%02x:%

29、02x:%02x",*mac_string,*(mac_string+1),*(mac_string+2),*(mac_string+3),*(mac_string+4),*(mac_string+5);pcap_close(pcap_handle); void getarp()pcap_t* pcap_handle;char error_contentPCAP_ERRBUF_SIZE;char *net_interface;/掩码地址/网络地址/获取网络和掩码地址struct bpf_program bpf_filter; char bpf_filter_string="

30、arp" bpf_u_int32 net_mask;bpf_u_int32 net_ip;pcap_lookupnet( net_interface, &net_ip,&net_mask, errorcontentstruct ether_headeru_int8_t ether_dhost8; / 目的以太网地址u_int8_t ether_shost8;/ 源以太网地址 u_int16_t ether_type; /以太网类型 ;typedef u_int32_t in_addr_t;struct arp_header/arp 协议格式u_int16_t arp_

31、hardware_type;/ 硬件地址类型u_int16_t arp_protocol_type;/ 协议地址类型u_int8_t arp_hardware_length;/ 硬件地址长度u_int8_t arp_protocol_length;/ 协议地址长度u_int16_t arp_operation_code;/ 操作类型u_int8_t arp_source_ethernet_address6;/源以太网地址u_int8_t arp_source_ip_address4;/ 源 IP 地址u_int8_t arp_destination_ethernet_address6;/ 目的

32、以太网地址u_int8_t arp_destination_ip_address4;/ 目的 IP 地址;void arp_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)struct arp_header *arp_protocol; /arp 协议变量u_short protocol_type;/ 协议类型u_short hardware_type;/硬件类型u_short operation_code;/操作类型u_

33、char *mac_string;/ 以太网地址struct in_addr source_ip_address;/源 IP 地址struct in_addr destination_ip_address;/ 目的 IP 地址u_char hardware_length;/硬件长度u_char protocol_length;/ 协议长度arp_protocol=(struct arp_header*)(packet_content+14);hardware_type=ntohs(arp_protocol->arp_hardware_type);protocol_type=ntohs(a

34、rp_protocol->arp_protocol_type);operation_code=ntohs(arp_protocol->arp_operation_code);protocol_length=arp_protocol->arp_protocol_length;hardware_length=arp_protocol->arp_hardware_length;printf("ARP硬件类型为:%dn",hardware_type);printf("ARP协议类型为:%dn",protocol_type);printf(

35、"ARP硬件长度为:%dn",protocol_length);printf("ARP协议长度为:%dn",protocol_length);printf("ARP操作类型为:%dn",operation_code);switch(operation_code)case 1:printf("ARP 查询协议n");break;case 2:printf("ARP 应答协议n");break;case 3:printf("RARP 查询协议n");break;case 4:pr

36、intf("RARP 应答协议n");break;default: break;mac_string=arp_protocol->arp_source_ethernet_address;printf("源以太网地址为 : %02x:%02x:%02x:%02x:%02x:%02x",*mac_string,*(mac_string+1),*(mac_string+2),*(mac_string+3),*(mac_string+4),*(mac_string+5);memcpy(void*)&source_ip_address,(void*)

37、&arp_protocol->arp_source_ip_address,sizeof(struct in_addr);printf(" 源 IP 网地址为:%sn",inet_ntoa(source_ip_address);mac_string=arp_protocol->arp_destination_ethernet_address;printf("目的以太网地址为 : %02x:%02x:%02x:%02x:%02x:%02x",*mac_string,*(mac_string+1),*(mac_string+2),*(mac

38、_string+3),*(mac_string+4),*(mac_string+5);memcpy(void*)&destination_ip_address,(void*)&arp_protocol->arp_destination_ip_address,sizeof(struct in_addr);printf(" 目的 IP 网地址为:%sn",inet_ntoa(destination_ip_address);void ethernet_protocol_packet_callback(u_char *argument,const struct

39、 pcap_pkthdr* packet_header,const u_char* packet_content)u_short ethernet_type;struct ether_header *ethernet_protocol;u_char *mac_string;static int packet_number=1;printf(" 捕获了 %d 个 ARP 数据包 n",packet_number);ethernet_protocol=(struct ether_header*)packet_content;ethernet_type=ntohs(ethernet_protocol->ether_type);printf(" 以太网类型为:%04xn",ethernet_type);switch(ethernet_type)case 0x0800: printf("

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论