ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
View previous topic :: View next topic
Author
Message
vahid بي تو هرگز Joined: 26 Nov 2004 Posts: 3067 Location: Tehran
Posted: Sun Jun 27, 2010 2:02 pm Post subject: SQl Injection Hack قسمت 1
یکی از عمومی ترین راه های ایجاد فرم لوگین که اکثر برنامه نویس ها ازش استفاده می کنند کد زیر است.
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("نام کاربری یا رمز ورود نادرست است.");
}
}
حالا اگر کاربری در فیلد نام کاربری مقدار زیر را وارد کند :
چی می شه؟
کاربر لوگین می شه چون دستور سلکت به شکل زیر تغییر پیدا می کند:
"SELECT Count(*) FROM tblUsers WHERE UsrName='' Or 3=3 --' AND Passwd=''"
دو خط تیره ادامه دستور سلکت را کامنت می کند.
Back to top
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
s
Powered by phpBB © 2001, 2010 phpBB Group
آمار