Hello, I want to cach input, which seems to be like SQL injection. I know now, that Reg-ex usage for finding SQL-injections is not a best way, but i simply need to do some researcha about it and I'm asking for help to fix some errors. So I wrote the method:
public static bool IsInjection(string inputText)
{
bool isInj = false;
string regexForTypicalInj = @"/\w*((\%27)|(\'))((\%6F)|o|(\%4F))((\%72)|r|(\%52))/ix";
Regex reT = new Regex(regexForTypicalInj);
if (reT.IsMatch(inputText))
isInj = true;
string regexForUnion = @"/((\%27)|(\'))union/ix";
Regex reUn = new Regex(regexForUnion);
if (reUn.IsMatch(inputText))
isInj = true;
string regexForSelect = @"/((\%27)|(\'))select/ix";
Regex reS = new Regex(regexForSelect);
if (reS.IsMatch(inputText))
isInj = true;
string regexForInsert = @"/((\%27)|(\'))insert/ix";
Regex reI = new Regex(regexForInsert);
if (reI.IsMatch(inputText))
isInj = true;
string regexForUpdate = @"/((\%27)|(\'))update/ix";
Regex reU = new Regex(regexForUpdate);
if (reU.IsMatch(inputText))
isInj = true;
string regexForDelete = @"/((\%27)|(\'))delete/ix";
Regex reDel = new Regex(regexForDelete);
if (reDel.IsMatch(inputText))
isInj = true;
string regexForDrop = @"/((\%27)|(\'))drop/ix";
Regex reDr = new Regex(regexForDrop);
if (reDr.IsMatch(inputText))
isInj = true;
string regexForAlter = @"/((\%27)|(\'))alter/ix";
Regex reA = new Regex(regexForAlter);
if (reA.IsMatch(inputText))
isInj = true;
string regexForCreate = @"/((\%27)|(\'))create/ix";
Regex reC = new Regex(regexForCreate);
if (reC.IsMatch(inputText))
isInj = true;
return isInj;
}
"inputText" - here comes tring type text from some textBoxes. But seems I have done some mistakes, becouse my code do not detects simple sql- injections. What i do wrong? I guess theres something wrong in defining Regex expressions or something with comparing two values. Please help me just to fix some of these Reg-ex'es to get work. Thanks