悬赏园豆:15
[已解决问题]
解决于 2008-05-08 14:06
<P>用如下语句过滤</P>
<P>private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";<BR> private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";</P>
<P> public static bool CheckKeyWord(string sWord) <BR> {<BR> if (Regex.IsMatch(sWord, StrKeyWord, RegexOptions.IgnoreCase) || Regex.IsMatch(sWord, StrRegex))<BR> return true;<BR> return false;<BR> }</P>
<P> </P>
<P>在页面中</P>
<P>if(CheckKeyWord(TextBox1.Text))</P>
<P>{</P>
<P>--包含非法字符<BR>}</P>
<P>else</P>
<P>{<BR>}</P>
<P> </P>
<P>时出错了</P>
<H2><I>正在分析“select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|"|or|and”- ) 不足。参数名: select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|"|or|and</I> </H2>
<P> </P>
叶子绿了
|
初学一级
|
园豆:
50
提问于:2008-05-07 16:38