信息安全工程实践.docx

上传人:b****6 文档编号:6334092 上传时间:2023-01-05 格式:DOCX 页数:18 大小:26.16KB
下载 相关 举报
信息安全工程实践.docx_第1页
第1页 / 共18页
信息安全工程实践.docx_第2页
第2页 / 共18页
信息安全工程实践.docx_第3页
第3页 / 共18页
信息安全工程实践.docx_第4页
第4页 / 共18页
信息安全工程实践.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

信息安全工程实践.docx

《信息安全工程实践.docx》由会员分享,可在线阅读,更多相关《信息安全工程实践.docx(18页珍藏版)》请在冰豆网上搜索。

信息安全工程实践.docx

信息安全工程实践

《信息安全工程实践二》实践报告

姓名

朱杰

学号

班级

软信1603

指导教师

徐剑王学毅马毅

程序实践名称

信息安全工程实践二

程序实践内容

网络程序设计

开设学期

2017-2018第二学期

开设时间

第17周——第19周

报告日期

2018年7月14日

评定成绩

评定人签字

评定日期

东北大学软件学院

一、程序实践概述

1、题目名称:

Linux操作系统及其相关命令,Linux编程基础

Linux程序设计基础

2、时间进度:

12学时

3、开发环境:

Ubantu

二、问题分析

1、功能说明:

熟练掌握如下Linux命令。

①系统信息命令:

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

⑥vi命令

①编程实现快速排序算法;

②实现文本文件拷贝函数copy(f_source,f_target);即实现如下功能:

$./copyf1f2

以上程序执行后当前目录会形成一个新的文件f2,且其内容与f1完全一致。

③编写一个程序,要求:

输入N个学生的学号和成绩,并保存在文本文件中,对学生成绩进行排序并把排序后的结果输出到文件中,同时在屏幕上输出高于平均成绩的学生的学号和成绩。

④编写一个程序找出串str1和串str2的所有最长公共子串。

⑤从文件中读出整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件中。

要求:

采用2叉有序树做为存储结构。

(选作)

2、解决方案:

利用PPT中所提供的相关函数使用解决问题

三、方案设计

1、模块结构:

模块功能图和模块描述

①根据用户输入数组进行快速排序,然后输出排序后的数组

②用户创建f1,然后运行函数生成f2

③根据用户输入学生的数据,生成原数据stu文本以及根据成绩进行排序并把排序后的结果输出到score文本中,在屏幕上输出高于平均成绩的学生的学号和成绩

④根据用户输入的两个字符串,找出最长公共子串

⑤读出文件中的整数,将其中不同整数及其出现次数,按整数由大到小的顺序输出到文件中

2、数据结构:

①inta[10]

②FILE*fp1,*fp2

③structstudent{

intnumber;

intscore;

}student[10]

④chara[10],b[10]

⑤文本f1

3、总体流程:

给出流程图

4、关键算法:

给出关键算法描述

①if(num>1){core;

}

sort(a,m);

for(i=0;i

strcpy(student1[i].num,student[j].num);

student1[i].score=student[j].score;

}

}

}

fp=fopen("","w+");

fwrite(&student1,sizeof(student1),1,fp);

fclose(fp);

④for(i=0;i

for(j=0;j

strcpy(a,"0");

p=i;

q=j;

while(s1[p]==s2[q]&&s2[p]!

=0){

a[m]=s2[q];

p++;

q++;

m++;

}

if(strlen(a)>strlen(b))

{

strcpy(b,a);

}

m=0;

}

}

四、调试记录

给出测试用例

编号

用例描述

测试结果

修改情况

分析

21345678910

12345678910

程序运行正确

在f1中输入asd

生成了f2,打开后里面有asd

程序运行正确

在屏幕中输入12345680

12345770

12345860

屏幕上输出:

比平均成绩高的学生:

12345680

程序运行正确

输入f1=abcdef

输入f2=abcgkt

最长公子串为:

abc

程序运行正确

五、创新说明

①用户可以自行定义数据,根据用户输入的数组进行排序

②将f1的内容同时在屏幕上输出,用户可以直接查看文件内容

③用户可以自行定义学生个数以及在屏幕上输入学生数据,并且将成绩单独放到另一数组排序后根据序号对结构体排序

④用户可以输入任一字符串进行对比

一、程序实践概述

1、题目名称:

Socket编程基础

(1)时间服务器

(2)远程文件备份服务器

2、时间进度:

8学时

3、开发环境:

Ubantu

二、问题分析

1、功能说明:

①编程实现时间服务器

编写一个网络时间服务器timeserver,该服务器能应具有如下功能:

够为网络上的用户提供时间服务,即为网络用户返回服务器的当前时间;

记录发出请求的网络用户的IP地址(保存到文件中),格式如下:

IP地址请求时间

编写时间服务客户端timeclient,该客户端能够向服务器发送时间服务请求,并把获得的时间返回给用户。

②编程实现远程文件备份服务器

分别采用TCP或UDP协议编写一个远程数据备份服务器,运行客户端将本地文件备份到远程的服务器中。

服务器的功能:

接受客户端请求,把客户端的文件进行备份(可以备份到指定的文件夹)。

客户端的功能:

与远程服务器进行连接,在连接后把本地的文件发送给远程备份服务器。

③设计并实现带身份认证的远程数据备份服务器(选作)

在实验②的基础上增加身份管理和认证功能:

2、解决方案:

服务器端过程就是socket->bind->listen->accept->Read,write

对于客户端则是socket->connect->read,write

三、方案设计

1、模块结构:

2、数据结构:

①文件操作,time_tt,socket

②文件操作,socket

3、总体流程:

4、关键算法:

①time_tt;

if(argc!

=2)//获得ip地址

{

printf("usage%s\n",argv[0]);

return0;

}

if((he=gethostbyname(argv[1]))==NULL)

{

printf("gethostbynameerror\n");

return0;

}

if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)

{

printf("socket()error\n");

return0;

}

bzero(&server,sizeof(server));

=AF_INET;

=htons(PORT);

=*((structin_addr*)he->h_addr);

if(connect(sockfd,(structsockaddr*)&server,sizeof(server))==-1)

{

printf("connetc()error\n");

return0;

}

recv(sockfd,(void*)&t,sizeof(time_t),0);

printf("Timeis%s\n",ctime(&t));

5、界面设计:

直接使用终端界面进行

四、调试记录

给出测试用例

编号

用例描述

测试结果

修改情况

分析

1

connetc()错误

将ip改为

这里的ip地址应使用服务端的ip地址

2

在客户端输入client

isSatJul710:

48:

302018

此时结果正确

3

在客户端输入client客户端输入/home/login/Desktop/

服务端输入/home/login/Desktop/

在服务端的文件夹里找到,并且内容与f1一致

程序运行正确

五、创新说明

①拥有错误提示,即用户可以知道是哪个模块出错,方便进行检查

②拥有用户认证功能,即登录时需要特定的用户名跟密码,客户端在屏幕上输入文件路径上载,服务端再输入存贮的文件路径。

一、程序实践概述

1、题目名称:

Libpcap开发包使用

2、时间进度:

16学时

3、开发环境:

Ubantu

二、问题分析

1、功能说明:

(1)获取网络接口名字和掩码等信息

(2)捕获数据包(单个数据包和多个数据包两种情况)

(3)以太网数据报捕获

(4)ARP数据包捕获

2、解决方案:

使用QT图形化编程,将4个功能分别对应4个按钮点击事件,并把抓包结果输出在文本框中

三、方案设计

1、模块结构:

2、数据结构:

Libpcap

3、总体流程:

4、关键算法:

给出关键算法描述

voidgetip(){

charerror_content[PCAP_ERRBUF_SIZE];

structin_addrnet_ip_address;//网络地址

structin_addrnet_mask_address;//掩码地址

char*net_interface;//接口名字

char*net_ip_string;//网络地址字符串形式

char*net_mask_string;//掩码地址字符串形式

u_int32_tnet_ip;//网络地址

u_int32_tnet_mask;//掩码地址

net_interface=pcap_lookupdev(error_content);//获取网络接口

pcap_lookupnet(//获取网络和掩码地址

net_interface,

&net_ip,

&net_mask,

error_content

);

printf("接口名字为:

%s\n",net_interface);

=net_ip;

net_ip_string=inet_ntoa(net_ip_address);//网络地址转为字符串形式

printf("网络地址为:

%s\n",net_ip_string);

=net_mask;

net_mask_string=inet_ntoa(net_mask_address);//掩码地址转为字符串形式

printf("掩码地址为:

%s\n",net_mask_string);

}

voidgetpacket(){

charerror_content[PCAP_ERRBUF_SIZE];

structpcap_pkthdrprotocol_header;//数据包头

pcap_t*pcap_handle;//libpcap句柄

structbpf_programbpf_filter;//BPF过滤规则

charbpf_filter_string[]="ip";//过滤规则

constu_char*packet_content;//数据包内容

bpf_u_int32net_mask;//掩码地址

bpf_u_int32net_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,&bpf_filter,bpf_filter_string,0,net_ip);

//编译过滤原则

pcap_setfilter(pcap_handle,&bpf_filter);//设置过滤原则

packet_content=pcap_next(pcap_handle,&protocol_header);//捕获一个数据包

printf("从%s捕获了一个数据包\n",net_interface);

printf("数据包长度为:

%d\n",;

pcap_close(pcap_handle);

}

voidgetpackets(){

voidpacket_callback(u_char*argument,conststructpcap_pkthdr*packet_header,constu_char*packet_content){

staticintpacket_number=1;

printf("捕获数据包的个数为:

%d\n",packet_number);

packet_number++;

}

charerror_content[PCAP_ERRBUF_SIZE];

structpcap_pkthdrprotocol_header;//数据包头

pcap_t*pcap_handle;//libpcap句柄

structbpf_programbpf_filter;//BPF过滤规则

charbpf_filter_string[]="ip";//过滤规则

constu_char*packet_content;//数据包内容

bpf_u_int32net_mask;//掩码地址

bpf_u_int32net_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,&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);

}

voidgetethernet(){

structether_header{

u_int8_tether_dhost[8];//目的以太网地址

u_int8_tether_shost[8];//源以太网地址

u_int16_tether_type;//以太网类型

};

charerror_content[PCAP_ERRBUF_SIZE];

structpcap_pkthdrprotocol_header;//数据包头

pcap_t*pcap_handle;//libpcap句柄

structbpf_programbpf_filter;//BPF过滤规则

charbpf_filter_string[]="ip";//过滤规则

bpf_u_int32net_mask;//掩码地址

bpf_u_int32net_ip;//网络地址

char*net_interface;//网络接口

constu_char*packet_content;//数据包缓存

u_char*mac_string;//以太网地址

u_shortethernet_type;//以太网类型

structether_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_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_handle,&protocol_header);//捕获一个网络数据包

printf("从%s捕获了一个数据包\n",net_interface);

printf("数据包长度为:

%d\n",;

ethernet_protocol=(structether_header*)packet_content;

ethernet_type=ntohs(ethernet_protocol->ether_type);//获得以太网类型

printf("以太网类型为:

%04x\n",ethernet_type);

switch(ethernet_type){

case0x0800:

printf("协议类型为IP协议\n");break;

case0x0806:

printf("协议类型为ARP协议\n");break;

case0x8035:

printf("协议类型为RARP协议\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_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);

}

voidgetarp(){

pcap_t*pcap_handle;

charerror_content[PCAP_ERRBUF_SIZE];

char*net_interface;

structbpf_programbpf_filter;

charbpf_filter_string[]="arp";

bpf_u_int32net_mask;//掩码地址

bpf_u_int32net_ip;//网络地址

pcap_lookupnet(//获取网络和掩码地址

net_interface,

&net_ip,

&net_mask,

error_content

);

structether_header{

u_int8_tether_dhost[8];//目的以太网地址

u_int8_tether_shost[8];//源以太网地址

u_int16_tether_type;//以太网类型

};

typedefu_int32_tin_addr_t;

structarp_header{//arp协议格式

u_int16_tarp_hardware_type;//硬件地址类型

u_int16_tarp_protocol_type;//协议地址类型

u_int8_tarp_hardware_length;//硬件地址长度

u_int8_tarp_protocol_length;//协议地址长度

u_int16_tarp_operation_code;//操作类型

u_int8_tarp_source_ethernet_address[6];//源以太网地址

u_int8_tarp_source_ip_address[4];//源IP地址

u_int8_tarp_destination_ethernet_address[6];//目的以太网地址

u_int8_tarp_destination_ip_address[4];//目的IP地址

};

voidarp_protocol_packet_callback(u_char*argument,conststructpcap_pkthdr*packet_header,constu_char*packet_content){

structarp_header*arp_protocol;//arp协议变量

u_shortprotocol_type;//协议类型

u_shorthardware_type;//硬件类型

u_shortoperation_code;//操作类型

u_char*mac_string;//以太网地址

structin_addrsource_ip_address;//源IP地址

structin_addrdestination_ip_address;//目的I

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1