Dec 24, 2012 05:06 AM
(This post was last modified: Dec 24, 2012 10:04 AM by ~[DogiD]~.)
Here is my tutorial how to setup htmlspecialchars() and protect your site to xss vulnerability.
If you didn't know what XSS vulnerability is then i recommend you read this tutorial first, https://hackforums.net/showthread.php?tid=2910051
What you need, before you start read tutorial?
Steps,
Hope this tutorial help you understand how to use htmlspecialchars() function,
Good luck and have fun!
~ DogiD🤝
If you didn't know what XSS vulnerability is then i recommend you read this tutorial first, https://hackforums.net/showthread.php?tid=2910051
What you need, before you start read tutorial?
- Website or other think to run php files (ex. XAMPP)
- Notepad++ or other program to edit php files.
Steps,
- First make 2 php file, "index.php" and "without.php".
Open "index.php" and build simple form page. Like this,
Spoiler (Click to View)
- When "index.php" is ready, open "without.php" file and make it looks like this,
Spoiler (Click to View)
- Now when you type something in "index.php" its send it to "without.php" page. So if i type in textbox script,
Code<script>alert(1)</script>
Then i press send..
Spoiler (Click to View)
- Now we just need add htmlspecialchars() function in "without.php" file,
Spoiler (Click to View)
- Lets try again, what happen if i try send same script,
Spoiler (Click to View)
- Now htmlspecialchars() function change all <, > etc to html code and xss vulnerability is fixed.
Congratulations! 🎉
Hope this tutorial help you understand how to use htmlspecialchars() function,
Good luck and have fun!
~ DogiD🤝


![[Image: vBDPw4l.png]](https://i.imgur.com/vBDPw4l.png)
![[Image: IRRJ3bf.png]](https://i.imgur.com/IRRJ3bf.png)
![[Image: eh4TL.gif]](https://i.imgur.com/eh4TL.gif)
![[Image: H4kDu.png]](https://i.imgur.com/H4kDu.png)