用户登录验证安全问题
2010-05-29 22:04
417 查看
关于登录验证安全问题,用户名和密码使用: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
表 where
user= 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
函数好象不太胜任那怎么办呢??
二、程序控制法
用程序来对客户端输入的内容全部控制起来,这样能全面控制用户端输入的任何可能的危险字符或代码,我就的这个方法!
典型的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
表 where
user= 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 ... %> |
相关文章推荐
- (crm笔记2-5)用户登录问题之验证账户
- 从BeejiveIM 的iPhone的Push(推送通知),用户如何完全授权它登录,是否涉及安全问题?
- 一例登录验证导致的提供的防伪标记适用于其他基于声明的用户,而不适用于当前用户的问题
- H3C交换机dot1X+AD+IAS+CA配置实验五(解决用户尚未登录无法验证问题)
- 解决Linux系统安装后,root用户无法登录,提示“无法验证用户”的错误问题
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
- AngularJs用户登录问题处理(交互及验证、阻止FQ处理)
- 在安装discuz!nt时,数据库用户登录失败的问题时,sql server 2008 数据库更改登录模式(sql server 2008 混合登陆中SqlServer身份验证用户名密码)
- 利用POST进行用户登录的安全问题剖析
- JAVA Web 安全机制----使用filter验证session用户和页面缓存问题处理
- 解决Linux系统安装后,root用户无法登录,提示“无法验证用户”的错误问题
- 关于用户登录的记住密码实现思路(考虑到安全问题)
- thinkphp框架模块部署,验证用户登录问题
- 用户登录安全问题
- CAS单点登录之mysql数据库用户验证及常见问题
- H3C交换机dot1X+AD+IAS+CA配置实验五(解决用户尚未登录无法验证问题)
- H3C交换机dot1X+AD+IAS+CA配置实验(解决用户尚未登录无法验证问题)
- 用户安全登录问题
- Oracle 验证机制 -- 解决刚创建数据库后未赋权新建用户以dba登录问题
- 用户登录记住密码功能(记住登陆状态),下次不需要重新登录,注意安全问题!实现原理