c61213on.github.io

How to protect XSS_GET from bWAPP (easy level)

Member group

Oh WOW!!!

bWAPP XSS_GET

Kahoot

Test Vulnerability XSS

Input

Kahoot

Oh!!!

Alert

Kahoot

Scan with RIPS

Focus Cross-Site Scipting Topic

Kahoot

Get Help RIPS

Kahoot

let’s fix it

Original Code

<?php

if(isset($_GET["firstname"]) && isset($_GET["lastname"]))
{   

   * $firstname = $_GET["firstname"];
   * $lastname = $_GET["lastname"];
    

    if($firstname == "" or $lastname == "")
    {

        echo "<font color=\"red\">Please enter both fields...</font>";       

    }

    else            
    { 

        echo "Welcome " . xss($firstname) . " " . xss($lastname);   

    }

}

?>

Secure Coding

 <?php

if(isset($_GET["firstname"]) && isset($_GET["lastname"]))
{   

    //$firstname = $_GET["firstname"];
    //$lastname = $_GET["lastname"];
    
  * $firstname = htmlspecialchars($_GET["firstname"]);
  * $lastname = htmlspecialchars($_GET["lastname"]);

    if($firstname == "" or $lastname == "")
    {

        echo "<font color=\"red\">Please enter both fields...</font>";       

    }

    else            
    { 

        echo "Welcome " . xss($firstname) . " " . xss($lastname);   

    }

}

?>

fix is correct

Complete

Kahoot

Force will be with you

Complete

Kahoot