r3m1ck official site

The ordinary boy who like to programming java,programming python,developer a desktop application,mobile application,web designer

What is Cross Site Scripting or XSS?

Posted by admin On July - 2 - 2011 Views: 8,505

Cross-Site scripting is one of the best know attack. Any web application that displays input is at risk. In this Web 2.0 time this attack can be easy to do.
:woot:
I think the name “cross site” is confusing. It’s easy to hear that and think it involves code on one website attacking code on another website. That’s not what it is. Not to mention its unfortunate “true” acronym.

It simply means: executing abritrary JavaScript code on the page.

This could be JavaScript that is inserted into the URL or through form submissions. If either of those ways of accepting information doesn’t “clean” the information it is getting before outputting it again on the page, then arbitrary JavaScript can run on that page and that’s an XSS vulnerability.

If JavaScript can run on the page, then it can access cookies.

If it can access cookies, then it can access active sessions.

If it can access active sessions, it can log in as you to websites you are logged in to, at least long enough to change passwords or other havoc.

Symantec has said that 80% of internet vulnerabilities are due to XSS.

XSS is different from, but similar in spirit to SQL injection. SQL injection is where SQL commands are not cleaned from inputs and thus able to do malicious things to a database. Using HTTPS cannot help with either XSS or SQL injection. HTTPS only protects data in transit over networks.
:redface:
I’m not a security expert, I’m just helping spread the word: let’s scrub those inputs people!


Sponsored links



here some tips & tricks to securing your website from Cross-Site scripting or XSS vulnerability

  • Function for stripping out malicious bits
  • <?php
    function cleanInput($input) {
     
      $search = array(
        '@<script[^>]*?>.*?</script>@si',   // Strip out javascript
        '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
        '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
        '@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments
      );
     
        $output = preg_replace($search, '', $input);
        return $output;
      }
    ?>
  • Sanitization function
  • <?php
    function sanitize($input) {
        if (is_array($input)) {
            foreach($input as $var=>$val) {
                $output[$var] = sanitize($val);
            }
        }
        else {
            if (get_magic_quotes_gpc()) {
                $input = stripslashes($input);
            }
            $input  = cleanInput($input);
            $output = mysql_real_escape_string($input);
        }
        return $output;
    }
    ?>

    USAGE

    <?php
      $bad_string = "Hi! <script src='http://www.evilsite.com/bad_script.js'></script> It's a good day!";
      $good_string = sanitize($bad_string);
      // $good_string returns "Hi! It\'s a good day!"
     
      // Also use for getting POST/GET variables
      $_POST = sanitize($_POST);
      $_GET  = sanitize($_GET);
    ?>
  • Using htaccess
  • View Code HTACCESS
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
    RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    RewriteRule ^(.*)$ 404.php [F,L]
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
     
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteRule .* - [F]

    there are some tips and trick how to securing your website from Cross-Site scripting or XSS vulnerability
    8)

    Tags: ,

    Facebook Comments

    Leave a Reply

     

    Ultimate Bachelor Loft In A Remodeled Warehouse

    This ultimate bachelor loft is located in Vancouver, Canada. It’s designed by Kelly Reynolds Interiors for a guy who loves entertain. The loft is part of 1921 Warehouse and has a one bedroom and two bathrooms. Some warehouse’s elements like exposed original bricks, an unfinished Read the Rest…

    List of New York Car Insurance

    Have a current automobile insurance is extremely useful. This is because the population of car ownership increased, especially in new york. So do not deny vulnerable in a car accident in New York. To anticipate that we can register our cars to an insurer. The Read the Rest…

    Modern Girl Bedroom Design Inspiration

    The interior of this teen bedroom is decorated by former Domino market editor Tori Mellott. It’s designed for contest JCPenney that was running along with Teen Vogue magazine. The colors and the style of the room are things that are really great. It features beautiful Read the Rest…

    Cara mendapatkan IP Public / Publik

    Sekedar berbagi tentang IP Publik. Sebelumnya saya pernah menulis cara membuat server Hosting sendiri dengan EHCP. Serber ini memerlukan IP Publik. Ada juga teman saya yang bertanya Bagaimana cara mendapatkan IP Publik? Apa itu IP Publik, IP Public adalah IP yang bisa diakses langsung oleh Read the Rest…

    Hackers plan 9/11 attacks

    ToolBox – September 9th, 2011 Print this article Team Poison will hit US government agencies on the anniversary By Dave Neal Post in theinquirer HACKERS Team Poison have promised to support activists looking to protest against the US government on 11 September with attacks against Read the Rest…

    Fans Box

    • Donate Me :)

    • Web Statistics