下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、信息安全工程实践二 实践报告一、程序实践概述1 、题目名称:Linux 操作系统及其相关命令,Linux 编程基础Linux 程序设计基础2、时间进度:12 学时3、开发环境:Ubantu二、问题分析1 、功能说明:熟练掌握如下Linux 命令。系统信息命令文件操作命令目录操作命令进程操作命令网络操作命令vi 命令:who,w,du,du,df 等:touch,cp,mv,rm,find,grep,cat,more,sort:ls,dir,mkdir,rmdir,cd:ps,top,cal,last,whereis,date:ping,write,telnet,ftp,talk编程实现快速排序
2、算法;;即实现如下功能:f2 ,且其内容与f1 完全一致。实现文本文件拷贝函数copy(f_source, f_target)$ ./copy f1 f2以上程序执行后当前目录会形成一个新的文件成绩进行排序并把排序后的结果输出到文件中学号和成绩。编写一个程序,要求:输入 N个学生的学号和成绩,并保存在文本文件中,对学生, 同时在屏幕上输出高于平均成绩的学生的编写一个程序找出串str1 和串 str2 的所有最长公共子串。从文件中读出整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件中。要求:采用2 叉有序树做为存储结构。(选作)2、解决方案:利用PPT中所提供的相关函数使用解决问
3、题-、口、 1三、方案设计1 、模块结构:模块功能图和模块描述根据用户输入数组进行快速排序,然后输出排序后的数组用户创建f1 ,然后运行函数生成f2根据用户输入学生的数据,生成原数据 stu文本以及根据成绩进行排序并把排序后的结果输出到score 文本中,在屏幕上输出高于平均成绩的学生的学号和成绩根据用户输入的两个字符串,找出最长公共子串读出文件中的整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件中2、数据结构: int a10 FILE *fp1,*fp2 struct student int number;int score;student10 char a10,b10文本
4、 f13、总体流程:给出流程图4、关键算法:给出关键算法描述 if (num>1) core;sort(a,m);for(i=0;i<m;i+) core)strcpy(student1i.num,studentj.num);student1i.score=studentj.score;fp=fopen("","w+");fwrite(&student1,sizeof(student1),1,fp);fclose(fp); for(i=0;i<len;i+)for(j=0;j<length;j+)strcpy(a, &qu
5、ot;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;四、调试记录给出测试用例编P用例描述测试结果修改情况分析2 1 3 4 5 6 7 8 9 101 2 3 4 5 6 7 89 10无程序运行正确在fl中输入asd生成了 f2 ,打 开后里面后asd无程序运行正确在屏幕中输入123456 80123457 70123458 60屏幕上输出:比 平均成绩高的 学生:12345680无程序运行正确输入 f1=abcdef输入 f2=a
6、bcgkt最长公子串为:abc无程序运行正确五、创新说明用户可以自行定义数据,根据用户输入的数组进行排序将fl的内容同时在屏幕上输出,用户可以直接查看文件内容用户可以自行定义学生个数以及在屏幕上输入学生数据,并且将成绩单独放到另一数组 排序后根据序号对结构体排序用户可以输入任一字符串进行对比一、程序实践概述1、题目名称:Socket编程基础(1)时间服务器(2)远程文件备份服务器2、时间进度:8学时3、开发环境:Ubantu二、问题分析1、功能说明:编程实现时间服务器编写一个网络时间服务器timeserver ,该服务器能应具有如下功能:够为网络上的用户提供时间服务,即为网络用户返回服务器的当
7、前时间;记录发出请求的网络用户的IP地址(保存到文件中),格式如下:IP地址请求时间编写时间服务客户端 timeclient ,该客户端能够向服务器发送时间服务请求,并把获得的时间返回给用户。编程实现远程文件备份服务器分别采用TCP或UDPW议编写一个远程数据备份服务器,运行客户端将本地文件备份到远程的服务器中。服务器的功能:接受客户端请求,把客户端的文件进行备份(可以备份到指定的文件夹)。客户端的功能:与远程服务器进行连接,在连接后把本地的文件发送给远程备份服务器。设计并实现带身份认证的远程数据备份服务器(选作)在实验的基础上增加身份管理和认证功能:2、解决方案:服务器端过程就是 socke
8、t->bind->listen->accept->Read,write对于客户端贝 U 是 socket->connect->read,write二、万案设计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("
9、gethostbyname errorn");return 0;if(sockfd = socket(AF_INET, SOCK_STREAM, 0) = -1)printf("socket() error n");return 0;bzero(&server, sizeof(server);=AF_INET;=htons(PORT);=*(struct in_addr *)he->h_addr);if(connect(sockfd, (struct sockaddr *)&server, sizeof(server) = -1) print
10、f("connetc() errorn");return 0;recv(sockfd,(void *)&t,sizeof(time_t),0);printf("Time is %sn",ctime(&t);5、界面设计:直接使用终端界面进行四、调试记录给出测试用例编P用例描述测试结果修改情况分析1在connetc() 错误将ip改为这里的ip地 址应使用服 务端的ip地 址2在客户端输入clientis Sat Jul710:48:302018此时结果正 确3在客户端输入client 客户端输入 /home/login/Desktop/服
11、务端输入/home/login/Desktop/在服务端的文 件夹里找到, 并且内容与f1无程序运行正 确五、创新说明拥有错误提示,即用户可以知道是哪个模块出错,方便进行检查拥有用户认证功能,即登录时需要特定的用户名跟密码,客户端在屏幕上输入文件路径 上载,服务端再输入存贮的文件路径。一、程序实践概述1 、题目名称:Libpcap 开发包使用2、时间进度:16 学时3、开发环境:Ubantu二、问题分析1)获取网络接口名字和掩码等信息2)捕获数据包(单个数据包和多个数据包两种情况)3)以太网数据报捕获4)1 、功能说明: 获取网络接口名字和掩码等信息捕获数据包(单个数据包和多个数据包两种情况)
12、以太网数据报捕获ARP数据包捕获 2、解决方案:使用QT图形化编程,将4个功能分别对应4个按钮点击事件,并把抓包结果输出在文 本框中1 、模块结构:2、数据结构:3、总体流程:4、关键算法:、方案设计 模块结构: 数据结构: Libpcap 总体流程: 关键算法:给出关键算法描述void getip()char error_contentPCAP_ERRBUF_SIZE;struct in_addr net_ip_address; /struct in_addr net_mask_address;/char *net_interface;char *net_ip_string;char *ne
13、t_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, errorcontent/获取网络和掩码地址) ;printf(" 接口名字为:%sn",net_interface);=net_ip;net_ip_string=inet_nto
14、a(net_ip_address); /printf(" 网络地址为:%sn",net_ip_string);=net_mask;网络地址转为字符串形式net_mask_string=inet_ntoa(net_mask_address);/掩码地址转为字符串形式printf(" 掩码地址为:%sn",net_mask_string);void getpacket()char error_contentPCAP_ERRBUF_SIZE;struct pcap_pkthdr protocol_header; /数据包头pcap_t *pcap_handle
15、;/libpcap句柄struct bpf_program bpf_filter; /BPF过滤规则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_content); /获取网络接口pcap_lookupnet(/获取网络和掩码地址net_interface,&
16、net_ip,&net_mask,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); /设置过滤原则packet_content=pcap_next(pcap_handle,&
17、protocol_header);/捕获一个数据包printf(" 从 %s 捕获了一个数据包n",net_interface);printf(" 数据包长度为:%dn",;pcap_close(pcap_handle);void getpackets()void packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)static int packet_number=1;printf(" 捕获数据
18、包的个数为:%dn",packet_number);packet_number+;char error_contentPCAP_ERRBUF_SIZE;struct pcap_pkthdr protocol_header; /数据包头pcap_t *pcap_handle;/libpcap句柄struct bpf_program bpf_filter; /BPF过滤规则char bpf_filter_string="ip" /过滤规则const u_char *packet_content; /数据包内容bpf_u_int32 net_mask;/掩码地址bpf_
19、u_int32 net_ip;/网络地址char *net_interface;/网络接口net_interface=pcap_lookupdev(error_content); /获取网络接口pcap_lookupnet(/获取网络和掩码地址net_interface,&net_ip,&net_mask,error_content) ;pcap_handle=pcap_open_live(net_interface,BUFSIZ,1,0,error_content);/网络接口,数据包大小,混杂模式,等待时间,错误信息pcap_compile(pcap_handle,&
20、;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_header目的以太网地址 源以太网地址 以太网类型u_int8_t ether_dhost8; / u_int8_t ether_shost8;/ u_int16_t ether_type; /
21、;数据包头句柄过滤规则过滤规则掩码地址网络地址网络接口数据包缓存以太网地址以太网类型以太网协议变量获取网络接口char error_contentPCAP_ERRBUF_SIZE; struct pcap_pkthdr protocol_header; / pcap_t *pcap_handle;/libpcapstruct bpf_program bpf_filter; /BPF char bpf_filter_string="ip"/bpf_u_int32 net_mask;/bpf_u_int32 net_ip;/char *net_interface;/const
22、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) ;pcap_handle=pcap_open_live(net_interface,BUFSIZ,1,0,error_con
23、tent);/网络接口,数据包大小,混杂模式,等待时间,错误信息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_handle,&protocol_header);/捕获一个网络数据包printf(" 从 %s 捕获
24、了一个数据包n",net_interface);printf(" 数据包长度为:%dn",;ethernet_protocol=(struct ether_header*)packet_content;ethernet_type=ntohs(ethernet_protocol->ether_type);/获得以太网类型printf(" 以太网类型为:%04xn",ethernet_type);switch(ethernet_type)case 0x0800: printf(" 协议类型为IP 协议 n");break;
25、case 0x0806: printf("协议类型为 ARP协议 n");break;case 0x8035: printf("协议类型为 RAR曲议 n");break;default: break;mac_string=ethernet_protocol->ether_shost;/获得源以太网地址printf("源以太网地址为: %02x:%02x:%02x:%02x:%02x:%02x",*mac_string,*(mac_string+1),*(mac_string+2) ,*(mac_string+3),*(mac_
26、string+4),*(mac_string+5);mac_string=ethernet_protocol->ether_dhost;/获得目的以太网地址printf("目的以太网地址为: %02x:%02x:%02x:%02x:%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
27、_contentPCAP_ERRBUF_SIZE;char *net_interface;struct bpf_program bpf_filter;掩码地址 网络地址 获取网络和掩码地址目的以太网地址char bpf_filter_string="arp"bpf_u_int32 net_mask;/bpf_u_int32 net_ip;/pcap_lookupnet(/net_interface,&net_ip,&net_mask,error_content) ;struct ether_headeru_int8_t ether_dhost8; /u_in
28、t8_t ether_shost8;/源以太网地址u_int16_t ether_type; /以太网类型;typedef u_int32_t in_addr_t;struct arp_header /arp协议格式u_int16_t arp_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_sou
29、rce_ethernet_address6;/源以太网地址u_int8_t arp_source_ip_address4;/ 源 IP 地址u_int8_t arp_destination_ethernet_address6;/目的以太网地址u_int8_t arp_destination_ip_address4;/;void arp_protocol_packet_callback(u_char packet_header,const u_char* packet_content)struct arp_header *arp_protocol; /arpu_short protocol_ty
30、pe;/协议类型u_short hardware_type;/硬件类型u_short operation_code;/ 操作类型u_char *mac_string;/ 以太网地址struct in_addr source_ip_address;/struct in_addr destination_ip_address;/u_char hardware_length;/硬件长度u_char protocol_length;/协议长度目的 IP 地址*argument,const struct pcap_pkthdr*协议变量IP 地址目的 IP 地址printf("ARP prin
31、tf("ARP printf("ARP printf("ARP printf("ARP硬件类型为: 协议类型为: 硬件长度为: 协议长度为: 操作类型为:arp_protocol=(struct arp_header*)(packet_content+14);hardware_type=ntohs(arp_protocol->arp_hardware_type);protocol_type=ntohs(arp_protocol->arp_protocol_type);operation_code=ntohs(arp_protocol->
32、arp_operation_code);protocol_length=arp_protocol->arp_protocol_length;hardware_length=arp_protocol->arp_hardware_length;%dn",hardware_type);%dn",protocol_type);%dn",protocol_length);%dn",protocol_length);switch(operation_code) case 1:printf("ARP case 2:printf("ARP
33、 case 3:printf("RARP case 4:printf("RARP default: break;查询协议n");break;应答协议n");break;查询协议n");break;应答协议n");break;%dn",operation_code);mac_string=arp_protocol->arp_source_ethernet_address;printf("源以太网地址为: %02x:%02x:%02x:%02x:%02x:%02x",*mac_string,*(mac_
34、string+1),*(mac_string+2) ,*(mac_string+3),*(mac_string+4),*(mac_string+5);memcpy(void*)&source_ip_address,(void*)&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
35、_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*)&destination_ip_address,(void*)&arp_protocol->arp_destination_ip_address,sizeof(struct in_addr);printf(" 目的 IP
36、 网地址为:%sn",inet_ntoa(destination_ip_address);*argument,const structvoid ethernet_protocol_packet_callback(u_charpcap_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(" 捕获了 个
37、 ARP据包 n",packet_number);ethernet_protocol=(struct ether_header*)packet_content;ethernet_type=ntohs(ethernet_protocol->ether_type);printf(" 以太网类型为:%04xn",ethernet_type);协议类型为IP 协议 n");break;协议类型为ARP协议n");break;协议类型为RAR曲议n");break;switch(ethernet_type) case 0x0800: printf("
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 品牌授权合作协议及品牌维护责任条款
- 趣味语文知识大全比赛
- 软件开发团队项目管理指南
- 土地综合治理与现代农业发展合同
- 《数轴的概念及其性质:初中数学基础概念教案》
- 趣味保险知识
- 机械臂技术研发工程师绩效评定表
- 项目安全生产全方位管理责任承诺书7篇范文
- 小区土地流转合同补充协议
- 银行产品运营官绩效评定表
- 2025年住院医师规培-广西-广西住院医师规培(骨科)历年参考题库含答案解析(5卷套题【单选100题】)
- 医院收费员个人年终总结范文(2篇)
- 肝性脑病的分级及护理
- 2025年湖北高考真题化学试题(原卷版)
- 2025年中考数学二轮复习专题一 数与式中的化简与计算(含答案)
- T/CECS 10011-2022聚乙烯共混聚氯乙烯高性能双壁波纹管材
- GA/T 2157-2024毛细管电泳遗传分析仪
- 《胰高血糖素抵抗》课件
- 艾滋病实验室课件
- (高清版)AQ 1056-2008 煤矿通风能力核定标准
- 高中名校自主招生考试数学重点考点及习题精讲讲义上(含答案详解)
评论
0/150
提交评论