ImperialDev
Enthusiast
Hello,
First of all Sorry about my BAD ENGLISH but I try to explain Clean.
Im Not VERY Pro at This Article But I know something about this and wanted to share.
We have two common Hacking Methods for hacking websites,
This Vulnerability apear when programer use GET or POST method.
Example:
And url will be www.site.com/index.php?id=5
Now, How To Fix!
If our postid or articleid or anything is a Number we can use Intval Function Like this:
Else If our postid or articleid or anything is a Number Or a String We can use mysql_real_escape_string Function like this:
Step 2) XSS (Cross Site Scripting) Vulnerability
This Vulnerability based on some HTML, CSS, JavaScript Scripting, For example this script has XSS Vulnerability:
Now, How To Fix!
For patch this Vulnerability we can use htmlentities and htmlspecialchars Functions Like This:
Hope To Enjoy,
ImperialDev
First of all Sorry about my BAD ENGLISH but I try to explain Clean.
Im Not VERY Pro at This Article But I know something about this and wanted to share.
We have two common Hacking Methods for hacking websites,
- SQL Injection
- XSS (Cross Site Scripting)
This Vulnerability apear when programer use GET or POST method.
Example:
PHP:
<?php
$postid = $_GET['id'];
$result = mysqli_query($con,"SELECT * FROM `post` WHERE `id`=$postid");
?>
Now, How To Fix!
If our postid or articleid or anything is a Number we can use Intval Function Like this:
PHP:
<?php
$postid = intval($_GET['id']);
$result = mysqli_query($con,"SELECT * FROM `post` WHERE `id`=$postid");
?>
Else If our postid or articleid or anything is a Number Or a String We can use mysql_real_escape_string Function like this:
PHP:
<?php
$postid = mysql_real_escape_string($_GET['id']);
$result = mysqli_query($con,"SELECT * FROM `post` WHERE `id`=$postid");
?>
Step 2) XSS (Cross Site Scripting) Vulnerability
This Vulnerability based on some HTML, CSS, JavaScript Scripting, For example this script has XSS Vulnerability:
PHP:
<?php
$text = $_GET['search'];
echo $text
?>
Now, How To Fix!
For patch this Vulnerability we can use htmlentities and htmlspecialchars Functions Like This:
PHP:
<?php
$text = htmlspecialchars($_GET['search']);
echo $text
?>
OR
<?php
$text = htmlentities($_GET['search']);
echo $text
?>
Hope To Enjoy,
ImperialDev
Last edited: