Our website is under attack by some hackers , it seems that we have an XSS hole in the login page , i run a software to scan the CMS and it found some holes and they included the solution , but i’m not a developer so i can’t understand what they mean , So if someone could check the code and the report and can modify it please .
here is the report and below is the code of the login page .
This vulnerability affects /admin/adminlogin/login.php.
Discovered by: Scripting (XSS.script).
1- Attack details
URL encoded POST input pword was set to '"()&%1
URL encoded POST input pword was set to
'"()&%1
URL encoded POST input uname was set to '"()&%1
The impact of this vulnerability
Malicious users may inject JavaScript, VBScript, ActiveX, HTML or Flash into a vulnerable application to fool a user in order to gather data from them. An attacker can steal the session cookie and take over the account, impersonating the user. It is also possible to modify the content of the page presented to the user.
How to fix this vulnerability
Your script should filter metacharacters from user input.
What can I do to protect myself as a vendor?"
This is a simple answer. Never trust user input and always filter metacharacters. This will eliminate the majority of XSS attacks. Converting < and > to < and > is also suggested when it comes to script output. Remember XSS holes can be damaging and costly to your business if abused. Often attackers will disclose these holes to the public, which can erode customer and public confidence in the security and privacy of your organization’s site. Filtering < and > alone will not solve all cross site scripting attacks and it is suggested you also attempt to filter out ( and ) by translating them to ( and ), and also # and & by translating them to # (#) and & (&).
CODE:
<?php require_once('../../Connections/rawecconn.php'); ?> <?php require_once('../../include/lang.php'); ?> <?php session_start(); ?> <? if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) { //echo "try login"; mysql_select_db($database_rawecconn, $rawecconn); $uname = $_POST['uname']; $pword = $_POST['pword']; $query_LoginRec = "SELECT * FROM tbl_user where username='$uname' and password='$pword'"; //echo $query_LoginRec; $LoginRec = mysql_query($query_LoginRec, $rawecconn) or die(mysql_error()); $row_LoginRec = mysql_fetch_assoc($LoginRec); $totalRows_LoginRec = mysql_num_rows($LoginRec); if($totalRows_LoginRec > 0) { //echo "OK"; $ADMIN_CPanel_WFusername = $row_LoginRec['username']; $_SESSION['ADMIN_CPanel_WFusername'] = $ADMIN_CPanel_WFusername; session_register("ADMIN_CPanel_WFusername"); //echo $row_LoginRec['username']; } else { //echo "NOTOK"; $fontcolor=rand(0,9); //echo $fontcolor; $a[0]="#FF0000"; $a[1]="#0000FF"; $a[2]="#993366"; $a[3]="#CC00CC"; $a[4]="#FF6666"; $a[5]="#9966FF"; $a[6]="#9933FF"; $a[7]="#9999FF"; $a[8]="#FF0000"; $a[9]="#33CCFF"; $error_msg="|
|
|||||||||||||
Here is the code: