计算机网络完全.docx
- 文档编号:7981931
- 上传时间:2023-01-27
- 格式:DOCX
- 页数:13
- 大小:37.07KB
计算机网络完全.docx
《计算机网络完全.docx》由会员分享,可在线阅读,更多相关《计算机网络完全.docx(13页珍藏版)》请在冰豆网上搜索。
计算机网络完全
网络安全课程设计
名称:
基于加密技术的网站安全防护软件设计
专业:
计算机科学与技术
组员:
指导老师:
日期:
引言
在当前网络信息快速发展情况下,网站安全和信息知识产权成为一个备受关注的话题。
每年网站被篡改和信息产权丢失的数量在逐年上升。
因此,许多公司因为网站安全的缺陷受到了极大的损失。
同时,因为人们对网络服务质量的要求也越来越高,一般的网站开发在安全上不能满足社会的发展和用户的需要。
由此可知,一个网站的安全防护软件对一个公司或者企业有多么重要。
一、设计目的
在当前信息安全领域、防杀毒软件和防火墙仍是公司网站防护主力产品,2004年上半年防火墙的市场容量达到5.5亿元,在整个安全市场中的比重为41.7%。
防病毒产品的销售额达到2.8亿元,占整个安全市场的21.2%。
然而,每年因为信息安全带来的经济损失,却仍旧逐年上升。
因此可见,在当今市场上网站系统最大的问题还是安全隐患。
因此,我们此次设计开发的基于网页的加密工具软件在一种主动式网页安全防护软件。
通过对网页的加密、备份和轮询检测,能即时检测网页是否被攻击篡改并作出相应的恢复网站内容,有效的保护了网页的安全。
二、开发环境
需要一台装有windowsNT或者windowsXP系统的计算机,其中安装有VisualC++6.0、VisualC++2005、VisualC++2005java6.0或者MinGWDeveloperStudio等集成开发环境软件。
本次开发采用JAVA程序设计语言编写源程序。
三、设计内容
本次设计的主要内容有三个:
第一是对网页的重要信息进行加密备份保护,防止丢失重要信息。
第二是对网站系统的一个轮询检测保护,发现攻击后立刻报警通知服务器并做出相应的处理。
第三是支持网页的备份和恢复,以至于在被篡改攻击后能即时恢复,让用户访问到正常的网页。
四、功能介绍
报警功能:
在使用本次开发软件之前,将要求客户进行配置,一项为管理员的联系方式,另一项是设定需要报警的等级。
采用外挂轮询检测技术检测网页,发现网站遭受攻击或者遇到某些不正常的状况,软件将根据事先提供的联系方式向管理员报警。
本次设计的软件目前支持邮件报警方式。
恢复功能:
如果Web服务器上的内容遭到破坏,根据破坏的程度和范围,选择性的调用备份端的文件对相应的文件进行部分或者全部的恢复,从而有效的保证了文件和数据的完整性和原始性。
同时,在备份端,将对整个网站的文件和数据进行备份,将完完全全的保存所有的信息,这样就可以在Web服务器遭到破坏时,采用监测服务器上的数据或文件进行还原。
备份功能:
由于在日常运行中,对网站的日常更新是非常频繁的,此数据是在不断变动的。
因此,如果备份端数据备份功能由管理员来完成的话,将会是非常繁重而且低效的工作。
所以本次设计的工具提供了自动备份功能。
加密功能:
本次采用的加密算法主要有AES、DES、RC4等,通过对服务器上的源文件进行备份加密保护,攻击者不能正常访问备份文件。
在发现网页内容被攻击或者篡改后可以立即执行恢复功能,在一定的程度上提高了网站的安全性能。
五、详细设计
本次设计一共分为文件加密解密、备份恢复、检测报警和主框架版块,其详细设计如下:
加密解密模块:
首先建立一个接口调用函数,函数名为Algorithm,代码如下:
publicinterfaceAlgorithm{
publicbyte[]encrypt(byte[]src,Stringkey)throwsException;
publicbyte[]decrypt(byte[]src,Stringkey)throwsException;
}
然后建立加密解密模块,其函数名为Handle。
通过调用里面的open()函数打开需要进行加密的文件进行加密操作。
代码如下:
Stringopen(){
Stringfullpath=null;
intindex=0;
if(chooseFile.showOpenDialog(win)==JFileChooser.APPROVE_OPTION){
infile=chooseFile.getSelectedFile();
filesize=infile.length();
fullpath=infile.getPath();
index=fullpath.lastIndexOf(File.separator);
path=fullpath.substring(0,index);
name=fullpath.substring(index+1);
//win.filePath.setToolTipText(Float.parseFloat(filesize/1024+"")
//+
//"kb");
}
returnfullpath;
}
打开文件后,调用加密函数,函数名为encrypt(),代码如下:
publicvoidencrypt(){
key=win.txtkey.getText().trim();
byte[]buf=null;
inti=0;
if(path!
=null&&key.length()%8==0){
readFile(infile);
try{
buf=alg.encrypt(src.getBytes("UTF-8"),key);
intlen=buf.length;
while(i code.append((char)buf[i++]); } }catch(Exceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); } } } 调用加密算法代码为: publicvoidsetAlg(Stringselect){ if(select.equals(str.DES)){ alg=newDes(); }elseif(select.equals(str.DES3)){ alg=newDes3(); }elseif(select.equals(str.AES)){ alg=newAes(); }elseif(select.equals(str.RC4)){ alg=newRc4(); } } publicAlgorithmgetAlg(){ returnalg; } 对文件加密后需进行保存,其函数名为save(),代码如下: voidsave(){ if(chooseFile.showSaveDialog(win)==JFileChooser.APPROVE_OPTION){ writeFile(chooseFile.getSelectedFile(),code.toString()); } } 解密设计函数名为decrypt(),代码设计如下: publicvoiddecrypt(){ byte[]buf=null; inti=0; if(path! =null&&key.length()%8==0){ readFile(infile); try{ buf=alg.decrypt(src.getBytes("UTF-8"),key); intlen=buf.length; while(i code.append((char)buf[i++]); } }catch(Exceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); } } } 当需要进行解密操作时,首先要从内存中读取需要加密的文件,读取函数名为voidreadFile(Fileinfile),代码如下: *@paramfilename *文件名 */ voidreadFile(Fileinfile){ FileReaderread=null; StringBufferbuf=newStringBuffer(); inttemp=0; if(! infile.exists()){ try{ infile.createNewFile(); }catch(IOExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace(); } } try{ read=newFileReader(infile); while((temp=read.read())! =-1){ buf.append((char)temp); } }catch(IOExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); }finally{ try{ read.close(); }catch(IOExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); } read=null; } setSrc(buf.toString()); } 解密过程与加密过程一样,需要一个与加密相对应的密钥,调用相应的解密算法。 在此,不重复上述过程。 主框架模块: 主框架设计函数名为initWindow(),包含整体布局和各个木块的设置。 代码如下: *Window.java *程序窗口——可视部分 */ importjava.awt.BorderLayout; importjava.awt.Toolkit; importjava.awt.event.ActionEvent; importjava.awt.event.ActionListener; importjava.awt.event.KeyEvent; importjava.awt.event.KeyListener; importjavax.swing.ButtonGroup; importjavax.swing.JButton; importjavax.swing.JComponent; importjavax.swing.JFrame; importjavax.swing.JLabel; importjavax.swing.JPanel; importjavax.swing.JProgressBar; importjavax.swing.JRadioButton; importjavax.swing.JTextField; publicclassWindowextendsJFrameimplementsActionListener,KeyListener{ privatestaticfinallongserialVersionUID=3642648220303388102L; staticStringResourcestr; Toolkittool; JLabeltitle; JLabelfp; JTextFieldfilePath; JButtonopenFile; publicButtonGroupalgorithm; JRadioButtonrdoDes; JRadioButtonrdo3Des; JRadioButtonrdoAes; JRadioButtonrdoRc4; JLabellbkey; JTextFieldtxtkey; JButtonencrypt; JButtondecrypt; JButtonsave; JButtonexit; JProgressBarproc; Handlehandle; Stringencode; Window(){ super("Cryptiontool"); handle=newHandle(this); initComponent(); initWindow(); } voidinitComponent(){ fp=newJLabel(str.FILEPATH); filePath=newJTextField(20); openFile=newJButton(str.OPENFILE); algorithm=newButtonGroup(); rdoDes=newJRadioButton(str.DES,true); rdo3Des=newJRadioButton(str.DES3); rdoAes=newJRadioButton(str.AES); rdoRc4=newJRadioButton(str.RC4); rdoDes.setActionCommand(str.DES); rdo3Des.setActionCommand(str.DES3); rdoAes.setActionCommand(str.AES); rdoRc4.setActionCommand(str.RC4); lbkey=newJLabel(str.LBKEY); txtkey=newJTextField(20); encrypt=newJButton(str.ENCRYPTION); decrypt=newJButton(str.DECRYPTION); save=newJButton(str.SAVE); exit=newJButton(str.EXIT); proc=newJProgressBar(); algorithm.add(rdoDes); algorithm.add(rdo3Des); algorithm.add(rdoAes); algorithm.add(rdoRc4); //encrypt.setEnabled(false); //decrypt.setEnabled(false); //save.setEnabled(false); filePath.setToolTipText(str.TOOLTIPFILEPATH); openFile.setToolTipText(str.TOOLTIPOPENFILE); txtkey.setToolTipText(str.TOOLTIPKEY); proc.setMinimum(0); proc.setMaximum(100); proc.setSize(320,40); proc.setValue(50); proc.setStringPainted(true); //addListener(filePath); addListener(openFile); addListener(rdoDes); addListener(rdo3Des); addListener(rdoAes); addListener(rdoRc4); //addListener(txtkey); addListener(encrypt); addListener(decrypt); addListener(exit); addListener(save); } voidinitWindow(){ tool=this.getToolkit(); intw=tool.getScreenSize().width; inth=tool.getScreenSize().height; intwidth=400; intheight=200; this.setBounds((int)(w-width)/2,(int)(h-height)/2,width, height); this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setResizable(false); JPaneltop=newJPanel(); top.add(fp); top.add(filePath); top.add(openFile); JPanelcenter=newJPanel(); center.setToolTipText(str.TOOLTIPSELECT); center.add(rdoDes); center.add(rdo3Des); center.add(rdoAes); center.add(rdoRc4); JPanelctlButtons=newJPanel(); ctlButtons.add(encrypt); ctlButtons.add(decrypt); ctlButtons.add(save); ctlButtons.add(exit); JPanelbottom=newJPanel(); bottom.setLayout(newBorderLayout()); JPanelpkey=newJPanel(); pkey.add(lbkey); pkey.add(txtkey); bottom.add(pkey,BorderLayout.NORTH); //bottom.add(proc,BorderLayout.CENTER); bottom.add(ctlButtons,BorderLayout.SOUTH) this.add(top,BorderLayout.NORTH); this.add(center,BorderLayout.CENTER); this.add(bottom,BorderLayout.SOUTH); validate(); } voidaddListener(JComponentcp){ if(cpinstanceofJButton){ ((JButton)cp).addActionListener(this); }elseif(cpinstanceofJRadioButton){ ((JRadioButton)cp).addActionListener(this); }elseif(cpinstanceofJTextField){ ((JTextField)cp).addKeyListener(this); } } @Override publicvoidkeyPressed(KeyEvente){ //TODOAuto-generatedmethodstub } @Override publicvoidkeyReleased(KeyEvente){ if(e.getSource()==filePath){ if(save.getText()! ="") save.setEnabled(true); else save.setEnabled(false); }elseif(e.getSource()==txtkey){ if(txtkey.getText()! =""){ encrypt.setEnabled(true); decrypt.setEnabled(true); }else{ encrypt.setEnabled(false); encrypt.setEnabled(false); } } } @Override publicvoidkeyTyped(KeyEvente){ //TODOAuto-generatedmethodstub } @Override publicvoidactionPerformed(ActionEvente){ //TODOAuto-generatedmethodstub if(e.getSource()==openFile){ this.filePath.setText(this.handle.open()); }elseif(e.getSource()==encrypt){ this.handle.encrypt(); }elseif(e.getSource()==decrypt){ this.handle.decrypt(); }elseif(e.getSource()==save){ handle.save(); }elseif(e.getSource()==exit){ System.exit(JFrame.EXIT_ON_CLOSE); } } 主要接口参数: publicinterfaceStringResource{ staticfinalStringFILEPATH="文件路径"; staticfinalStringOPENFILE="选择文件"; staticfinalStringDES="DES"; staticfinalStringDES3="3DES"; staticfinalStringAES="AES"; staticfinalStringRC4="RC4"; staticfinalStringLBKEY="密钥"; staticf
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机网络 完全