The Best C# Programmer In The World - Ben Perkins Member Login  | Newsletter | RSS Feeds


 
 
 
TheBestCSharpProgrammerInTheWorld.com 
 
The Best C# Programmer In The World - Ben Perkins
Hacked  
 
Hacked
 
Please rate:
 
A few weeks ago I had to fend off a hacker. Some of the database statements I created for another website were susceptible to SQL injection. This means I created the statements like this.
 
                        
                        string query = "select name, email, comment " +
                            "from blogs where postdate >= " + DateTime.Now.AddDays(-15);

                        
 
This is not good because a hacker can place something like:
 
                        
                        "’ or 1=1 "
                        
                        
 
Into the query value and get all the data versus avoiding the constraint. This is an extra problem with login and password functionality. If you have a query which is formatted like the above which checks user id and password using a simple where clause, then your system is open to the simplest attack known to man.
 
But anyway, I fixed the problem, I won’t share what I did because it could open other holes so, just know that I am watching, on the ball and the problem is fixed. This is NOT a challenge, leave my website alone.
 
And recently another attack happened on this website. I have a feedback form with limited validation, so really anyone can put anything into the fields and submit. Others will see the entered data. What someone or people have done was put other web addresses or JavaScript into the comment form which either redirected or presented the person with some advertisement. So, I fixed that one using the RegularExpressionValidator server control. You can still put in web addresses however no links or special characters are allowed.
 
I still enjoy getting comments, please continue and keep learning…
 
The tools below represent some of the restrictions I have placed on the website sue to hackers.
 
Download the source
 
Comment (server side validation):

 



Entered Text

System Safe Text



Comment (client side validation):

 



 

Save Status:
Status: Pending

 
 
Feedback / Question
 
Your Name:Your Email:
 
Subject:
 
Feedback/Question:
 
 
 
I had to remove the capability to leave feedback due to this. Will be back soon.
 
 
page.Translate()
 
 
blog.Stats()
 
  Posts: 113
  Comments: 86
  Fundamentals: 16
 
my.Book()

 
me.About()
 
 
 
 
 
blog.Archive()
 
2012 May  (4)
2012 April  (5)
2012 March  (4)
2012 February  (4)
2012 January  (5)
2011 December (2)
2011 November (6)
2011 October (7)
2011 September (7)
2011 August (9)
2011 July (9)
2011 June (8)
2011 May (9)
2011 April (7)
2011 March (9)
2011 February (8)
2011 January (8)
2010 December (7)
2010 November (8)
2010 October (4)
 
site.Visits()
 
free counters
 
tag.Cloud()
 
code.Disclaimer()
 
The sample code on this website is provided to illustrate a concept and should not be used in applications or Web sites without proper professional consultation, as it may not illustrate the safest coding practices. I assume no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
 
   


The Best C# Programmer In The World - Ben Perkins, © 2010, All Rights ReservedContact Ben