Top 10 attacks list for a web application

Posted: February 6th, 2009 | Author: | Filed under: Interesting | Tags: | No Comments »

I suggest you to check out  The Open Web Application Security Project.

Here is a Top 10 list for commonly faced attacks to a web application.

OWASP Top 2007 abbreviated list

Cross Site Scripting (XSS)

  • XSS flaws occur whenever an application takes user supplied data and sends it to a web browser without first validating or encoding that content. XSS allows attackers to execute script in the victim’s browser which can hijack user sessions, deface web sites, possibly introduce worms, etc.

Injection Flaws

  • Injection flaws, particularly SQL injection, are common in web applications. Injection occurs when user-supplied data is sent to an interpreter as part of a command or query. The attacker’s hostile data tricks the interpreter into executing unintended commands or changing data.

Malicious File Execution

  • Code vulnerable to remote file inclusion (RFI) allows attackers to include hostile code and data, resulting in devastating attacks, such as total server compromise. Malicious file execution attacks affect PHP, XML and any framework which accepts filenames or files from users.

Insecure Direct Object Reference

  • A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, database record, or key, as a URL or form parameter. Attackers can manipulate those references to access other objects without authorization.

Cross Site Request Forgery (CSRF)

  • A CSRF attack forces a logged-on victim’s browser to send a pre-authenticated request to a vulnerable web application, which then forces the victim’s browser to perform a hostile action to the benefit of the attacker. CSRF can be as powerful as the web application that it attacks.

Information Leakage and Improper Error Handling

  • Applications can unintentionally leak information about their configuration, internal workings, or violate privacy through a variety of application problems. Attackers use this weakness to steal sensitive data, or conduct more serious attacks.

Broken Authentication and Session Management

  • Account credentials and session tokens are often not properly protected. Attackers compromise passwords, keys, or authentication tokens to assume other users’ identities.

Insecure Cryptographic Storage

  • Web applications rarely use cryptographic functions properly to protect data and credentials. Attackers use weakly protected data to conduct identity theft and other crimes, such as credit card fraud.

Insecure Communications

  • Applications frequently fail to encrypt network traffic when it is necessary to protect sensitive communications.

Failure to Restrict URL Access

  • Frequently, an application only protects sensitive functionality by preventing the display of links or URLs to unauthorized users. Attackers can use this weakness to access and perform unauthorized operations by accessing those URLs directly.

Solving Sudoku with Assembly Code

Posted: February 4th, 2009 | Author: | Filed under: My Little Projects, Programming | Tags: , , | 2 Comments »

Who wants to solve the popular sudoku game with assembly code while there are lots of high level languages? Yes, I did. This was one of my home experiment and I wanted to make post about it. Actually assembly code is quite error prone language if you are not careful enough, but with some simple principals and being awake while coding you can create really effective algorithms. The solution does not include backtracking, and able to solve sudokus which don’t require backtrackings.

Here is how the algorithm works;

As you might already know in a sudoku board every cell has 9 possible values from 1 to 9. So while the algorithm traverses the sudoku grid (which is 9×9 matrix) it considers that every single cell has initially 9 possible values, and traverses the 3×3 grid of cell in evaluation and removes the existing values from possibility array. Does the same thing for row and column of the cell. At the and if there is only one possible value it puts the value to the cell, if not continues searching/traversing.

Consider the following example, there are cell that their value is certain. Check the left up most cell of the grid. There is only one possible value which is 2. By the time it puts values to the cells the puzzle gets easier.

Sudoku_example_2

And for this board here is the output of the algorithm;

image

And one last thing to mention; algorithm is assembly function which can be called in from C++ with the help of most compilers;

image

Here is the code!


For C# “typeof”, “GetType()”, “is” explained

Posted: February 2nd, 2009 | Author: | Filed under: Programming | Tags: , , , | No Comments »

So what is the difference between typeof and object.GetType() in .NET C#?

Type myType = typeof(Foo);
 
Type myType = foo.GetType();

Results of both are exactly the same. To be able use GetType() you need an instance of the class, however typeof can be used by the name of class. So GetType() is resolved in run-time while typeof is resolved in compile-time, which is an important difference.

And what about when there is inheritence?

class Bar : Foo
{
  .....
}
 
static void Main()
{
   Foo c = new Bar();
   c.GetType(); // returns typeof(Bar)
}

 

In the example above c.GetType() returns the type of Bar since the real instance is created using Bar() and handle is not important.

So here is how -is- behaves:

Bar bar = new Bar();
 
// false, even though bar is a child of foo.
if (bar.GetType() == typeof(Foo))
 
// However this is true
if (bar is Foo)