My Database was attacked by Sql Injetion.It makes lot of problem.
please Tell me how to stop Sql Injection attacks.
Thanks!..
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rodrigo BeretaPosted Mar 23, 2013, 9:13 AM
Title:
SQL Injection Attacks and Defense, Second Edition
Link:
http://books.google.com.br/books?id=KKqiht2IsrcC&printsec=frontcover&hl=pt-BR&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Regards
Sreejesh SPPosted Mar 23, 2013, 12:59 AM
We have to block sql query,that is first of sql injection prevention
that code is
private bool validatextbox()
{
int f = 1;
String str = txtsearchitem.Text;
string[] words = str.Split(';');
foreach (string word in words)
{
string sql = word;
var p = new TSql100Parser(true);
IList
p.ParseStatementList(new StringReader(sql), out errors);
if (errors.Count == 0)
{
f = 0;
break;
}
}
if (f == 0)
{
return false;
}
else
{
return true;
}
}
the abode code use namespace are
using Microsoft.Data.Schema.ScriptDom;
using Microsoft.Data.Schema.ScriptDom.Sql;
so please add refernce these two namespaces then check your text box entry for the above code
that is
private void btnsearch_Click(object sender, EventArgs e)
{
bool result = validatextbox();
if (result == true)
{
}
}
the result is true you enter sql query then blocked
else continue the operation
so please try this code
Thanks
Sreejesh
Rodrigo BeretaPosted Mar 22, 2013, 9:13 AM