Dig Computer - Discussion Forum - Help Forum
Advanced Search

Dig Computer - PC Help ForumHome Computer ForumComputer Forum ContestContests TutorialsTutorials Computer SoftwareSoftware Computer SecuritySecurity Off Topic ChatOff Topic Chat
 

Go Back   Dig Computer - Discussion and Help Forum Web Design and Development Web Programming

Notices

Web Programming Talk about languages such as html, php, javascript

Reply
 
LinkBack Thread Tools Display Modes
Old 04-15-2010, 05:20 AM   #1 (permalink)
Junior Member
Points: 137, Level: 2 Points: 137, Level: 2 Points: 137, Level: 2
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2010
Posts: 1
Rep Power: 0
gilang38 is on a distinguished road
Default SQL Injection Attacks ?? Script Php

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:
$sql = “SELECT * FROM users
WHERE username=’” . $_POST['username'] . “‘
AND password=’” . $_POST['password'] . “‘”;
echo ‘Query: ‘ . $sql . ‘<br />’;
$result = mysql_query($sql);$rows = mysql_num_rows($result);
if ($rows > 0) {
echo ‘You are logged in!<br />’;
} else {
echo ‘You are not allowed here!<br />’;
}
?>
<form method=”post” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<input type=”text” name=”username” /><br />
<input type=”text” name=”password” /><br />
<input type=”submit” />
</form>
A savvy attacker could simply enter the following in the form’s password field:

‘ 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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-15-2010, 12:22 PM   #2 (permalink)
Administrator
Points: 1,415, Level: 21 Points: 1,415, Level: 21 Points: 1,415, Level: 21
Activity: 0% Activity: 0% Activity: 0%
trichnosis's Avatar
Join Date: Feb 2010
Location: Istanbul
Posts: 117
Rep Power: 10
trichnosis has disabled reputation
Default Re: SQL Injection Attacks ?? Script Php

great tutorial about the sql injections and how to prevent them + rep
__________________
...
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-30-2010, 12:13 PM   #3 (permalink)
Member
Points: 515, Level: 10 Points: 515, Level: 10 Points: 515, Level: 10
Activity: 0% Activity: 0% Activity: 0%
chris's Avatar
Join Date: Apr 2010
Location: Somewhere in Europe
Posts: 77
Rep Power: 1
chris is on a distinguished road
Default Re: SQL Injection Attacks ?? Script Php

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!
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-17-2010, 03:17 PM   #4 (permalink)
Member
Points: 163, Level: 3 Points: 163, Level: 3 Points: 163, Level: 3
Activity: 100% Activity: 100% Activity: 100%
Join Date: May 2010
Posts: 32
Rep Power: 0
alexcarlson is on a distinguished road
Default Re: SQL Injection Attacks ?? Script Php

Really a nice tutorial. I enjoyed it.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-28-2010, 10:44 AM   #5 (permalink)
Member
Points: 163, Level: 3 Points: 163, Level: 3 Points: 163, Level: 3
Activity: 100% Activity: 100% Activity: 100%
Join Date: May 2010
Posts: 32
Rep Power: 0
alexcarlson is on a distinguished road
Default Re: SQL Injection Attacks ?? Script Php

Hello,
I do not have much knowledge on SOL. But I think the best work will be to take a help of any expert.
Thanks.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2010, 07:06 PM   #6 (permalink)
Junior Member
Points: 176, Level: 3 Points: 176, Level: 3 Points: 176, Level: 3
Activity: 30% Activity: 30% Activity: 30%
Join Date: Jun 2010
Posts: 4
Rep Power: 0
bratwurst99 is on a distinguished road
Default Re: SQL Injection Attacks ?? Script Php

If you don't have much knowledge, maybe you should Google it :-)
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes


Powered by vBulletin
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.