用户登录验证安全问题
来源:互联网 发布:类似于ps的软件 编辑:程序博客网 时间:2024/05/03 17:06
关于登录验证安全问题,用户名和密码使用:1=1 or 1=1;
典型的SQL:<!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:36.0pt;mso-footer-margin:36.0pt;mso-paper-source:0;}div.Section1{page:Section1;}--> sql="select * from 表where user= "&user&" and pass= "&pass&""
为避免:<!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:36.0pt;mso-footer-margin:36.0pt;mso-paper-source:0;}div.Section1{page:Section1;}-->sql="select * from 表 whereuser= 1 = 1 or 1=1 and pass= 1=1 or 1 = 1 "
<!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:595.3pt 841.9pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:42.55pt;mso-footer-margin:49.6pt;mso-paper-source:0;layout-grid:15.6pt;}div.Section1{page:Section1;}-->
解决方法:
一、函数替代法:
用REPLACE将用户端输入的内容中含有特殊字符进行替换,达到控制目的啊!sql="select * from 表 where user="&replace(user," "," ")&" and pass="&replace(pass," "," ")&" "
这种方法每次只能替换一个字符,其实危险的字符不只是" ",还有如">"、"<"、"&"、"%"等字符应该全控制起来。但用REPLACE函数好象不太胜任那怎么办呢??
二、程序控制法
用程序来对客户端输入的内容全部控制起来,这样能全面控制用户端输入的任何可能的危险字符或代码,我就的这个方法!
<%
捕捉用户端提交的表单内容
user=request.from("user")
pass=request.from("pass")
...
循环控制开始
for i=1 to len(user)
用MID函数读出变量user中i 位置的一个字符
us=mid(user,i,1)
将读出的字符进行比较
if us=" " or us="%" or us="<" or us=">" or us="&" then
如果含有以上字符将出错提示,不能含有以上特殊字符
response.redirect "err2.htm"
response.end
end if
next
...
%>
- 用户登录验证安全问题
- 用户登录安全问题
- Jstl验证用户登录
- 用户登录验证
- RCP用户登录验证
- 用户登录验证完整版
- 用户登录验证
- 用户登录验证
- 用户登录验证
- ajax 验证用户登录
- 验证用户登录
- 用户登录验证
- Yii 用户登录验证
- Yii 用户登录验证
- 用户登录验证码
- 用户登录验证
- yii2-用户登录验证
- 验证用户登录(perl)
- STM32 keil mdk启动代码发分析
- STM32 keil mdk启动代码发分析
- 为向OOP转变而采取的策略
- 有道搜索框题解
- const 与 *
- 用户登录验证安全问题
- WorldWind学习系列六:渲染过程解析篇
- sizeof 操作符
- 唐僧的家书!
- 5月29日 2010网易挑战赛
- 我不忍了!
- VC++读取文件夹下的所有文件
- 手记02之安装Linux User's Manual
- 第一次来