| Advanced Search |
|
| Web Programming Talk about languages such as html, php, javascript |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) | |||||||||
| Junior Member
Join Date: Apr 2010
Posts: 1
Rep Power: 0 ![]() | SQL Injection Attacks ?? Script Php An SQL injection attack occurs when an attacker exploits a legitimate user input mechanism on your site to send SQL code that your unsuspecting script will pass on to the database to execute. The golden rule: escape all data from external sources before letting it near your database. That rule doesn’t just apply to INSERT and UPDATE queries, but also to SELECT queries. No doubt many PHP developers have been saved from the worst SQL injection attacks by the limitations of MySQL, which will only allow a single SQL statement to be performed with each call to mysql_query. On other databases, the effect of an SQL injection can be disastrous, as an attacker can send a second query that, for example, deletes the entire contents of a table. With MySQL, however, problems can still occur, as the following code demonstrates: Quote:
‘ OR username LIKE ‘% Assuming magic quotes is disabled on your server, and you have no other measures in place to prevent it, this clever attack alters the meaning of the query: SELECT * FROM users WHERE username=” AND password=” OR username LIKE ‘%’ The modified query will select all records in the user table! When the script checks whether any users matched the supplied user name and password combination, it will see this big result set and grant access to the site! This can be prevented if we escape the incoming variables: $sql = “SELECT * FROM users WHERE username=’” . safeEscapeString($_POST['username']) . “‘ AND password=’” . safeEscapeString($_POST['password']) . “‘”; In some cases, depending on the circumstances, this may not be necessary. But if you value your sleep, remember that golden rule: escape all data from external sources. More tutorial About php please visit : Register to see links | |||||||||
|
| | #3 (permalink) | ||||||||
| Member
Join Date: Apr 2010 Location: Somewhere in Europe
Posts: 77
Rep Power: 2 ![]() | Good tutorial. Although every major login script already escapes all unwanted characters from the form data. Just browse your favorite PHP script repository... Btw... If you use MySQL, then PHP has already a native function that takes care of this: mysql_real_escape_string(). More Register to see links! | ||||||||
|
| | #7 (permalink) | ||||||||
| Junior Member
Join Date: Mar 2011
Posts: 21
Rep Power: 0 ![]() | I have some ways, via SQL injection may possible. SQL Injection: Attacking Via URLs SQL Injection Prevention: Editing Lengths Of Form Components SQL Injection Prevention: Data Type Validation SQL Injection Prevention: User Privileges SQL Injection Prevention: Magic Quotes (Which Aren’t So Magical) SQL Injection: Closing Comments | ||||||||
|
![]() |
| Thread Tools | |
| Display Modes | |