日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

解析防網(wǎng)站登陸被破解的簡單方法_.Net教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:asp.net程序中實現(xiàn)checkbox全選代碼
程序開發(fā)中經(jīng)常會要用到checkbox的全選,通常情況下是在一些數(shù)據(jù)綁定控件中如gridview等。下面以repeater為例,在repeater的header和item中放入checkbox控件 asp:RepeaterID=rptGrouprunat=server HeaderTemplate tablewidth=100%cellspacing=1class

    在大多數(shù)的基于數(shù)據(jù)庫的身份認證登陸模塊,大多數(shù)的程序員只是用一個簡單的SQL查詢語句來實現(xiàn),這樣很容易被用戶以簡單的(   1’ or ’1’=’1  )查詢替換給破解.其實只要稍微的修改一下代碼,便可以防止.具體請參看以下兩個函數(shù)的實現(xiàn):
    以下代碼基于C#,數(shù)據(jù)庫為Access
1.  未防止  1’ or ’1’=’1   替換的情況:

 private bool ValidateUser(string LoginId, string LoginPwd)
        {
            bool isCorrect = false;             

            try
            {
                DBAccept.conn.Open();

                string sql = String.Format("select UserName from UserManagement where [UserName]=’{0}’ and [Password]=’{1}’", LoginId, LoginPwd);
           
                OleDbCommand command = new OleDbCommand(sql, DBAccept.conn);
               
                if (command.ExecuteReader().HasRows)
                {
                    isCorrect = true;
                }
                else
                {
                    isCorrect = false;
                    MessageBox.Show("此管理員用戶不存在或者密碼錯誤,請重試", "失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作數(shù)據(jù)庫出錯", "失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                DBAccept.conn.Close();
            }
     
            return isCorrect;
        }

2.修正版,可正常阻止 1’ or ’1’=’1 登陸
private bool ValidateUser(string LoginId, string LoginPwd)
        {
            bool isCorrect = false;  //定一個bool變量
            try
            {
                DBAccept.conn.Open();

                string sql = String.Format("select Password from UserManagement where [UserName]=’{0}’", LoginId);
                OleDbCommand command = new OleDbCommand(sql, DBAccept.conn);
                 if (command.ExecuteScalar().ToString() == LoginPwd)
                {
                    isCorrect = true;
                }
                else
                {
                    isCorrect = false;
                    MessageBox.Show("此管理員用戶不存在或者密碼錯誤,請重試", "失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作數(shù)據(jù)庫出錯", "失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                DBAccept.conn.Close();
            } 
            return isCorrect;
        }        

分享:解析五種ADO.NET數(shù)據(jù)庫連接知識
ADO.NET提供了多種對象模型,比較典型的以下有五種,它們全部歸類在System.Data.SqlClient名稱空間下。 一、SqlConnection對象 ADO.NET使用SqlConnection對象與SQLServer進行連接。連接字符串的常用形式有兩種: 1.使用Windows集成安全身份認證,例如:strin

來源:模板無憂//所屬分類:.Net教程/更新時間:2010-04-11
相關.Net教程