SQL Injection Type 6 :- Adding new members

Adding new members

Given that we know the partial structure of the members table, it seems like a plausible approach to attempt adding a new record to that table: if this works, we’ll simply be able to login directly with our newly-inserted credentials.

This, not surprisingly, takes a bit more SQL, and we’ve wrapped it over several lines for ease of presentation, but our part is still one contiguous string:

SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x';
        INSERT INTO members ('email','passwd','login_id','full_name')
        VALUES ('steve@unixwiz.net','hello','steve','Steve Friedl');--';

Even if we have actually gotten our field and table names right, several things could get in our way of a successful attack:

  1. We might not have enough room in the web form to enter this much text directly (though this can be worked around via scripting, it’s much less convenient).
  2. The web application user might not have INSERT permission on the members table.
  3. There are undoubtedly other fields in the members table, and some may require initial values, causing the INSERT to fail.
  4. Even if we manage to insert a new record, the application itself might not behave well due to the auto-inserted NULL fields that we didn’t provide values for.
  5. A valid “member” might require not only a record in the members table, but associated information in other tables (say, “accessrights”), so adding to one table alone might not be sufficient.

In the case at hand, we hit a roadblock on either #4 or #5 – we can’t really be sure — because when going to the main login page and entering in the above username + password, a server error was returned. This suggests that fields we did not populate were vital, but nevertheless not handled properly.

A possible approach here is attempting to guess the other fields, but this promises to be a long and laborious process: though we may be able to guess other “obvious” fields, it’s very hard to imagine the bigger-picture organization of this application.

We ended up going down a different road.

Nitesh Shah

Share
Published by
Nitesh Shah

Recent Posts

How to setup first Azure Virtual Machine?

Setting up your first Azure Virtual Machine can be done by following these steps: Create…

1 year ago

How to setup Amazon Cloudfront and S3 to serve static resources

Amazon CloudFront is a content delivery network (CDN) that helps you serve static content such…

1 year ago

Step-By-Step Guide To Setting Up An AWS Application Load Balancer

Step-By-Step Guide To Setting Up An AWS Application Load Balancer Are you looking for a…

1 year ago

How to restore MySQL database from .frm and .ibd files?

MySQL databases often get corrupted due to issues like hardware failure, file system failure etc.…

4 years ago

SQL Server Replication

SQL Server Replication is the process of copying databases from one node to another to…

5 years ago

101 System Admin Tools to make life easy

Here are 101 System Admin tools which make System Admins' life easy.

7 years ago

This website uses cookies.