₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,328,423 members, 8,435,596 topics. Date: Monday, 29 June 2026 at 01:53 AM

Toggle theme

SQL Injection - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersSQL Injection (1057 Views)

1 Reply (Go Down)

SQL Injection by brushesz(op): 2:55pm On Aug 12, 2013
A lot of database driven websites are designed without the consideration of SQL injection; a technique where someone could actually (legally or illegally) query the database of a particular database driven website via form text fields or URL manipulations to retrieve data.

Feel free to share your experience and knowledge and if you are a Database/SQL guru who's not comfortable with releasing a whole lot of information to novices, then you can comment transparently in encryption.
Re: SQL Injection by Slyr0x: 4:02pm On Aug 12, 2013
brushesz: Feel free to share your experience and knowledge
How do you mean?
Re: SQL Injection by instinctg(m): 7:58pm On Aug 12, 2013
grin grin grin
Re: SQL Injection by brushesz(op): 9:44pm On Aug 12, 2013
Slyr0x: How do you mean?
//Have you successfully injected via data fields or "?" edit before?

if (true){
then post a light comment about it;
}
else{ ignore_thread();
}
Re: SQL Injection by Slyr0x: 10:12pm On Aug 12, 2013
brushesz: //Have you successfully injected via data fields or "?" edit before?
Yes.

brushesz: if (true){
then post a light comment about it;
}
else{ ignore_thread();
}
It was an enlightening experience grin
Re: SQL Injection by Yinksey(m):
When u are using PDO Extension with php to deal with mysql, i think you dont need to worry about sql injection.
Re: SQL Injection by brushesz(op): 10:43pm On Aug 12, 2013
pasted this s*#@ on a friend's website(http://www.abcdef.com/index.php?) username's field

SELECT*FROM "Bleep.self::$users." WHERE id={$id};
Definitely, $id = 0

Submit and Got it.
Re: SQL Injection by Slyr0x: 11:13pm On Aug 12, 2013
Yinksey: When u are using PDO Extension with php to deal with mysql, you dont need to worry about sql injection.
This is not entirely true.

Using the PDO prepared statement is sufficient to prevent 1st order injection (i.e. it takes this input and filters it before inserting into the DB). .

However, for 2nd order injection, let's look at this scenario :

We have an ecommerce web application that has the "wish list" enabled. .Imagine the user types in
'; DELETE Users;-
. .Using prepared statement, the initial apostrophe gets deleted however the seemingly innocent-looking text gets inserted like this

INSERT Wishlist (ID, Item, City, Country) 
VALUES(1, ''';DELETE Users;--', 'Lagos', 'Nigeria')


Now, 1st order injection has been prevented. .However, when the user decides to display his wishlists with the query

SELECT * FROM Wishlist WHERE ID = '', Item);
becomes
SELECT * FROM Wishlist WHERE ID = '', DELETE Users;--);

This innocent-looking query just deleted the Table "Users". .

Having said this, Using only prepared statements is not sufficient to protect against sql injection attacks. .however, it's a step in the right direction
Re: SQL Injection by brushesz(op): 1:25am On Aug 13, 2013
Yinksey: When u are using PDO Extension with php to deal with mysql, you dont need to worry about sql injection.
Let's not go too far. Let's look at the connection method from your beloved pdo class.

public PDO::__construct() ( string $dsn [, string $username
[, string $password [, array $driver_options ]]] )

From above, I have three revealed variables to play with; $dns, $username, $password.

I won't need to inject. All I need do is to {die mysql connection} from $dns.

That's iff pdo is used as a template class or not instantiated
Re: SQL Injection by Yinksey(m): 7:22am On Aug 13, 2013
Well maybe am still a kid in this, i only thought pdo got it all, but what are the real steps to take to prevent this dreadful attack @slyrox since i know u be an hacker. and @op.
Re: SQL Injection by Nobody: 11:06am On Aug 13, 2013
Have you heard of magic quotes? With magic quotes you are saved. If you want I can paste the code for you.
Re: SQL Injection by brushesz(op): 12:36am On Aug 14, 2013
didadavid: Have you heard of magic quotes? With magic quotes you are saved. If you want I can paste the code for you.
Don't paste it yet. Let's look @ how magical your " " could bend injections.

Came across magic_" " from lYnDaDoTcOm BtB & the abstraction was too easy to get.

Even PHP stopped magic_quotes() further development in recent versions.

I quote this from; www.php.net/manual/en/security.magicquotes.why.php

"There is no reason to use magic quotes
because they are no longer a supported
part of PHP. However, they did exist and
did help a few beginners blissfully and
unknowingly write better (more secure)
code. But, when dealing with code that
relies upon this behavior it's better to
update the code instead of turning
magic quotes on. So why did this feature
exist? Simple, to help prevent SQL
Injection. Today developers are better
aware of security and end up using
database specific escaping mechanisms
and/or prepared statements instead of
relying upon features like magical
quotes."
Re: SQL Injection by brushesz(op): 2:19am On Aug 14, 2013
Yinksey: but what are the real steps to take to prevent this dreadful attack
If I don't know what your key looks like,
It may take me months to crack your lock {no matter how i try to interpret your URL}.
But if I have the least idea of how your key looks like,
it's a matter of minutes and your lock's busted.

That's what happens when people use factory-made locks like magic_" "

PHP answers: www.php.net/manual/en/security.magicquotes.why.php
Re: SQL Injection by brushesz(op): 2:41am On Aug 14, 2013
pasted this s*#@ on a friend's website(http://www.abcdef.com/index.php?) pazzword's field to login /*after registering as a user.*/

**********'; DROP table pazzworde--&ALL went=>*************************************

Submit and Got it.
Re: SQL Injection by brushesz(op): 3:16am On Aug 15, 2013
Hola chicos!

Do you know that "indexDoTphp" is an easy injection initiator, especially for those site without directories?

Try the relational functions and apply them on indexDoTphp. Experimenting on unknown-pages in the same directory with index.

Unknown becomes known!
Re: SQL Injection by brushesz(op): 12:48pm On Aug 29, 2013
That great joy when you see a .php on a site's URL. You run a test for escape data value and it's NULL.

You LOL! after the delimiter.
1 Reply

Over A Million Web Sites Affected In Mass Sql Injection AttackMysql.com Vulnerable To Blind Sql Injection VulnerabilityQuick Sql Injection Vulnerability Test234

Who Can Help Me Repackage My Phpbb ForumWill Google Remove Adsense From My Blog?Webmasters Pls Help