Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:49:01+00:00 2026-05-10T21:49:01+00:00

I’m working with SQL Server 2005 and Windows Server 2000 and wonder if there

  • 0

I’m working with SQL Server 2005 and Windows Server 2000 and wonder if there are any ‘automated’ ways of blocking SQL Injection attacks while I shore up my code.

Some have suggested that there are ways to:

  1. Put in some kind of ISAPI or HTTP module that filters request post and querystrings for injection-oriented symbols and fails the request before it even hits the application. Most of these solutions specific IIS 6 or higher. I’m running 5.
  2. Guarantee that each command object runs only a single SQL command at a time.

Any other ideas for my configuration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:49:01+00:00Added an answer on May 10, 2026 at 9:49 pm

    When I had a bunch of injection attack attempts on my server, I was worried that they were taking up unnecessary resources. I wrote (hacked!) an HttpModule in c# that would filter out most xss and sql injection attacks. The code is pasted below, along with the config section required to make a website use it. It should be put in a project and compiled to WebSecurityFilter.dll, which should then be referenced by the web project (or otherwise dropped in the bin directory).

    This will only work with asp.net, so hopefully your site is asp.net based (I did ask in a comment, but got no answer).

    Web config section (add it in the <httpModules> section of <system.web>:

      <add name='SecurityHttpModule' type='WebSecurityFilter.SecurityHttpModule, WebSecurityFilter' /> 

    Code for module (SecurityHttpModule.cs):

    using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Text.RegularExpressions;  namespace WebSecurityFilter {     class SecurityHttpModule : IHttpModule     {         class RegexWithDesc : Regex         {             string _errorText;              public string ErrorText             {                 get { return _errorText; }             }              public RegexWithDesc(string regex, RegexOptions options, string errorText)                 :base(regex, options)             {                 _errorText = errorText;             }         }         /// <summary>         /// error text displayed when security violation is detected         /// </summary>         private string _errorhtml =         @'<!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.1//EN'' ''http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd''>' +         @'<html xmlns=''http://www.w3.org/1999/xhtml'' >' +         @'<body style=''background:black;''>' +         @'<table style=''width:100%'' >' +         @'<tr><td align=''center''>' +         @'<div style=''border:3px solid red;text-align:center;width:95%;color:red;padding:10px;text-decoration:blink;''>' +         @'SECURITY VIOLATION' +         @'<br/>' +         //@'<br/>' +         //@'go away' +         //@'<br/>' +         @'<br/>' +         @'{0}' +         @'<br/>' +         @'</div>' +         @'</td></tr>' +         @'</table>' +         @'</body>' +         @'</html>';          // regex for default checks         // http://www.securityfocus.com/infocus/1768         static RegexOptions _defaultRegexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace;          RegexWithDesc[] _regexCollection = new RegexWithDesc[]          {              new RegexWithDesc(@'((¼|<)[^\n]+(>|¾)*)|javascript|unescape', _defaultRegexOptions, 'XSS 1'), //3.3             // new RegexWithDesc(@'(\')|(\-\-)', _defaultRegexOptions, 'SQL 1'), //2.1             new RegexWithDesc(@'(=)[^\n]*(\'|(\-\-)|(;))', _defaultRegexOptions, 'SQL 2'),    //2.2             //new RegexWithDesc(@'\w*(\')(or)', _defaultRegexOptions, 'SQL 3'),  //2.3             new RegexWithDesc(@'(\')\s*(or|union|insert|delete|drop|update|create|(declare\s+@\w+))', _defaultRegexOptions, 'SQL 4'),   //2.4             new RegexWithDesc(@'exec(((\s|\+)+(s|x)p\w+)|(\s@))', _defaultRegexOptions, 'SQL 5')    //2.5         };         #region IHttpModule Members          public void Dispose()         {            // nothing to do         }          public void Init(HttpApplication context)         {             context.BeginRequest += new EventHandler(context_BeginRequest);         }          void context_BeginRequest(object sender, EventArgs e)         {             try             {                 List<string> toCheck = new List<string>();                 foreach (string key in HttpContext.Current.ApplicationInstance.Request.QueryString.AllKeys)                 {                     toCheck.Add(HttpContext.Current.ApplicationInstance.Request[key]);                 }                 foreach (string key in HttpContext.Current.ApplicationInstance.Request.Form.AllKeys)                 {                     toCheck.Add(HttpContext.Current.ApplicationInstance.Request.Form[key]);                 }                 foreach (RegexWithDesc regex in _regexCollection)                 {                     foreach (string param in toCheck)                     {                         string dp = HttpUtility.UrlDecode(param);                         if (regex.IsMatch(dp))                         {                             HttpContext.Current.ApplicationInstance.Response.Write(string.Format(_errorhtml, regex.ErrorText));                             HttpContext.Current.ApplicationInstance.CompleteRequest();                             return;                         }                     }                 }              }             catch (System.Threading.ThreadAbortException x)             {                 throw;             }             catch (Exception ex)             {                 HttpContext.Current.ApplicationInstance.Response.Write(string.Format(_errorhtml, 'Attack Vector Detected'));                 HttpContext.Current.ApplicationInstance.Response.Write(string.Format(_errorhtml, ex.GetType().ToString()));                 HttpContext.Current.ApplicationInstance.CompleteRequest();                 return;             }         }          #endregion     } } 

    Hopefully it all formatted okay…

    I’ll try to post a link to the complete project in a zip this evening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There are a couple of different ways that you can… May 11, 2026 at 12:17 pm
  • added an answer 'prototype' was not the correct word, I like 'DLLImport declaration'… May 11, 2026 at 12:17 pm
  • added an answer Firstly, if you dereference the NULL pointer standard C++ does… May 11, 2026 at 12:17 pm

Related Questions

I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I have a web-service that I will be deploying to dev, staging and production.
I'm thinking of starting a wiki, probably on a low cost LAMP hosting account.
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.