Jump to content

Please test my site for problems I have missed


Recommended Posts

Hi All,

Can you please test out my site for any issues I may have missed, it is a working site, so please do NOT do anything that may damage it.

 

If anything is found, then please send me the details in a private message to keep it out of the public eye until I fix it, once I fix the issue, it can then be posted here for other people to learn from.

 

http://www.ezyauctionz.co.nz

 

As per rules, link to my profile is here: http://www.ezyauctionz.co.nz/phpfreaks.html

 

Also, if you happen to know the solution to correct any issues found, please tell me too, in case I do not know how to resolve it.

Link to comment
Share on other sites

Failures:

85

Warnings:

0

Passes:

204595

SQL Injection String Test Results

loginusername

Submitted Form State:

 

    * loginpassword: ++

    * loginpasswordtext: ++

    * saveoptions: ++autologin

    * submit: ++ Login

 

Results:

Server Status Code: 302 Moved Temporarily

Tested value: &#49&#39&#32&#79&#82&#32&#39&#49&#39&#61&#39&#49

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116

Server Status Code: 302 Moved Temporarily

Tested value: ' OR username IS NOT NULL OR username = '

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND non_existant_table = '1

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: '; DESC users; --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND USER_NAME() = 'dbo'

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND 1=1

Server Status Code: 302 Moved Temporarily

Tested value: 1 EXEC XP_

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: 1 OR 1=1

This field passed 14603 tests. To see all the passed results, go to Tools->SQL Inject Me->Options and click 'Show passed results in final report' and rerun this test.

loginpassword

Submitted Form State:

 

    * loginusername: ++

    * loginpasswordtext: ++

    * saveoptions: ++autologin

    * submit: ++ Login

 

Results:

Server Status Code: 302 Moved Temporarily

Tested value: &#49&#39&#32&#79&#82&#32&#39&#49&#39&#61&#39&#49

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116

Server Status Code: 302 Moved Temporarily

Tested value: ' OR username IS NOT NULL OR username = '

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND non_existant_table = '1

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: '; DESC users; --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND USER_NAME() = 'dbo'

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND 1=1

Server Status Code: 302 Moved Temporarily

Tested value: 1 EXEC XP_

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: 1 OR 1=1

This field passed 14603 tests. To see all the passed results, go to Tools->SQL Inject Me->Options and click 'Show passed results in final report' and rerun this test.

loginpasswordtext

Submitted Form State:

 

    * loginusername: ++

    * loginpassword: ++

    * saveoptions: ++autologin

    * submit: ++ Login

 

Results:

Server Status Code: 302 Moved Temporarily

Tested value: &#49&#39&#32&#79&#82&#32&#39&#49&#39&#61&#39&#49

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116

Server Status Code: 302 Moved Temporarily

Tested value: ' OR username IS NOT NULL OR username = '

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND non_existant_table = '1

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: '; DESC users; --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND USER_NAME() = 'dbo'

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND 1=1

Server Status Code: 302 Moved Temporarily

Tested value: 1 EXEC XP_

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: 1 OR 1=1

This field passed 14603 tests. To see all the passed results, go to Tools->SQL Inject Me->Options and click 'Show passed results in final report' and rerun this test.

saveoptions

Submitted Form State:

 

    * loginusername: ++

    * loginpassword: ++

    * loginpasswordtext: ++

    * submit: ++ Login

 

Results:

Server Status Code: 302 Moved Temporarily

Tested value: &#49&#39&#32&#79&#82&#32&#39&#49&#39&#61&#39&#49

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116

Server Status Code: 302 Moved Temporarily

Tested value: ' OR username IS NOT NULL OR username = '

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND non_existant_table = '1

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: '; DESC users; --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND USER_NAME() = 'dbo'

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND 1=1

Server Status Code: 302 Moved Temporarily

Tested value: 1 EXEC XP_

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: 1 OR 1=1

This field passed 14603 tests. To see all the passed results, go to Tools->SQL Inject Me->Options and click 'Show passed results in final report' and rerun this test.

submit

Submitted Form State:

 

    * loginusername: ++

    * loginpassword: ++

    * loginpasswordtext: ++

    * saveoptions: ++autologin

 

Results:

Server Status Code: 302 Moved Temporarily

Tested value: &#49&#39&#32&#79&#82&#32&#39&#49&#39&#61&#39&#49

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE

Server Status Code: 302 Moved Temporarily

Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116

Server Status Code: 302 Moved Temporarily

Tested value: ' OR username IS NOT NULL OR username = '

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND non_existant_table = '1

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: '; DESC users; --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND USER_NAME() = 'dbo'

Server Status Code: 302 Moved Temporarily

Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --

Server Status Code: 302 Moved Temporarily

Tested value: 1 AND 1=1

Server Status Code: 302 Moved Temporarily

Tested value: 1 EXEC XP_

Server Status Code: 302 Moved Temporarily

Tested value: 1'1

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

Server Status Code: 302 Moved Temporarily

Tested value: 1 OR 1=1

Link to comment
Share on other sites

It may be OK, as the login processing script does redirect to a second login page if login fails, as it would when it does not find a correct match, that seems to correspond with the report it generates.

 

Please test whatever you can think of, I want to be sure (as much as is possible) that things are OK sitewide.

Link to comment
Share on other sites

with striptags(), then htmlspecialchars() also nl2br() on certain fields, and int() for variables that are only going to be numbers.

 

I will add trim(), I think it will be a good thing to ensure empty strings are not used.

 

I tried mysql_real_escape_string() but it gave me errors for some reason, it may be because it was before the script opened a connection.

Link to comment
Share on other sites

When I tested it is was when trying to resolve the xss exploit in the chatroom (from the old thread that was started by the guy trying to hack my site), I just inserted mysql_real_escape_string into another page and it seemed to be OK, so I will look into adding that instead of htmlspecialchars.

 

I will look into this further first, in case I can get it working OK (looks like I might), so for now please keep looking for any other problems.

Link to comment
Share on other sites

Recently I was trying to use this code, to replace my original code, which lists EACH variable passed, for GET and POST, only I could not get it to work the way I wanted for some reason, it will work, but not when using array_walk_recursive():

if(get_magic_quotes_gpc()){
//clean XSS/SQL injection
function clean($var){	
	$var = mysql_real_escape_string(trim(strip_tags($var)));
	$var = htmlspecialchars($var,ENT_QUOTES);
	return $var;
}

//array_walk_recursive($_GET,'clean'); // wouldn't work
//array_walk_recursive($_POST,'clean'); // wouldn't work
$_POST[input] = clean($_POST[input]); // temporary for testing - works
}

 

But the array_walk_recursive was not actually working on the POST and GET arrays, calling it for each variable does work though.

Link to comment
Share on other sites

I have modified the original version, to make it a bit safer (not as tidy mind), now it checks mysql_real_escape_string to see if it is available before it tries to use it (it requires a db connection to be present first) also it always falls back, instead of not doing anything if get_magic_quotes_gpc is turned off.

 

function clean($var){
$var = trim(strip_tags($var)); // remove extra spaces, and strip tags

if(!get_magic_quotes_gpc()){ // check if get_magic_quotes_gpc is on, if not add slashes, (if on it is already slashed)
	$var = addslashes($var);
}

if (!mysql_real_escape_string($var)){ // check if mysql_real_escape_string is available
	// returns FALSE if not possible
}
else{ // mysql_real_escape_string available
	$var = stripslashes($var); // strip slashes before doing mysql_real_escape_string
	$var = mysql_real_escape_string($var);
}
$var = htmlspecialchars($var,ENT_QUOTES);
return $var;
}

//array_walk_recursive($_GET,'clean'); // all GET items
//array_walk_recursive($_POST,'clean'); // all POST items
$_POST[item] = clean($_POST[item]); // single item

 

 

Link to comment
Share on other sites

that leaks injection majorly try:

 

<?php
if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value)
    {
        $value = is_array($value) ?
                    array_map('stripslashes_deep', $value) :
                    stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
if (get_magic_quotes_gpc()) {
function clean_post_var($var){
      $var=mysql_real_escape_string(trim(strip_tags($var)));
      $var=htmlspecialchars($var,ENT_QUOTES);
      return $var; //PHP 4 Version
                 return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
}

$_POST = array_map('clean_post_var', $_POST);
    $_GET = array_map('clean_post_var', $_GET);
    $_COOKIE = array_map('clean_post_var', $_COOKIE);
    $_REQUEST = array_map('clean_post_var', $_REQUEST);
}
?>

?>

 

Note: also be sure to call stripslashes_deep() & clean_post_var() on all variables just incase array_map,array_walk  array_walk_recursive fail. worked for me ;)

Link to comment
Share on other sites

Thanks for the code, I will have to study it to work out how it works.

 

One point though, if get_magic_quotes_gpc is not turned on, then none of the code will run, which is the reason I modified the original, especially important for future compatibility as get_magic_quotes_gpc is turned off by default in php5 and removed from php6.

 

I am trying to use code that will not require me to have to revisit it later to rewrite it when functions are known to be depreciated in later versions of php.

Link to comment
Share on other sites

unfortunately PHP functions get deprecated whether or not we want them to as a good coder you have to keep up with PHP software updates learn new functions and how to apply them.  ;)

 

 

also i am modifying code to work if  get_magic_quotes_gpc() are off ;)

 

Using it in PHP5 with magic quotes gpc off or on:

<?php
if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value)
    {
        $value = is_array($value) ?
                    array_map('stripslashes_deep', $value) :
                    stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
} elseif(!get_magic_quotes_gpc()){
function stripslashes_deep($value)
    {
        $value = is_array($value) ?
                    array_map('stripslashes_deep', $value) :
                    stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);

    }
if (get_magic_quotes_gpc()) {
function clean_post_var($var){
      $var=mysql_real_escape_string(trim(strip_tags($var)));
      $var=htmlspecialchars($var,ENT_QUOTES);
     
return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
}

$_POST = array_map('clean_post_var', $_POST);
    $_GET = array_map('clean_post_var', $_GET);
    $_COOKIE = array_map('clean_post_var', $_COOKIE);
    $_REQUEST = array_map('clean_post_var', $_REQUEST);
} elseif(!get_magic_quotes_gpc()){
function clean_post_var($var){
      $var=mysql_real_escape_string(trim(strip_tags($var)));
      $var=htmlspecialchars($var,ENT_QUOTES);
     
return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
}

$_POST = array_map('clean_post_var', $_POST);
    $_GET = array_map('clean_post_var', $_GET);
    $_COOKIE = array_map('clean_post_var', $_COOKIE);
    $_REQUEST = array_map('clean_post_var', $_REQUEST);



}

?>

 

Note: also be sure to call stripslashes_deep() & clean_post_var() on all variables just incase array_map,array_walk  array_walk_recursive fail. worked for me ;)

 

Link to comment
Share on other sites

I think you could reduce some repetitions in your new code, like so:

 

<?php


function stripslashes_deep($value){
     $value = is_array($value) ?
          array_map('stripslashes_deep', $value) :
          stripslashes($value);

     return $value;
}

$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);



if (get_magic_quotes_gpc()) {
    function clean_post_var($var){
         $var=mysql_real_escape_string(trim(strip_tags($var)));
         $var=htmlspecialchars($var,ENT_QUOTES);
     
         return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version               
    }
} elseif(!get_magic_quotes_gpc()){
     function clean_post_var($var){
          $var=mysql_real_escape_string(trim(strip_tags($var)));
          $var=htmlspecialchars($var,ENT_QUOTES);
     
          return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
    }
}


$_POST = array_map('clean_post_var', $_POST);
$_GET = array_map('clean_post_var', $_GET);
$_COOKIE = array_map('clean_post_var', $_COOKIE);
$_REQUEST = array_map('clean_post_var', $_REQUEST);

?>

 

Link to comment
Share on other sites

Or maybe even this way:

<?php


function stripslashes_deep($value){
     $value = is_array($value) ?
          array_map('stripslashes_deep', $value) :
          stripslashes($value);

     return $value;
}

$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);



function clean_post_var($var){
if (get_magic_quotes_gpc()) {
	$var=mysql_real_escape_string(trim(strip_tags($var)));
	$var=htmlspecialchars($var,ENT_QUOTES);
     
	return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version               
}
elseif(!get_magic_quotes_gpc()){
	$var=mysql_real_escape_string(trim(strip_tags($var)));
	$var=htmlspecialchars($var,ENT_QUOTES);
     
	return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
}
}


$_POST = array_map('clean_post_var', $_POST);
$_GET = array_map('clean_post_var', $_GET);
$_COOKIE = array_map('clean_post_var', $_COOKIE);
$_REQUEST = array_map('clean_post_var', $_REQUEST);

?>

 

 

Link to comment
Share on other sites

I think this may be slightly better, as it will check for nested arrays:

<?php


function stripslashes_deep($value){
     $value = is_array($value) ?
          array_map('stripslashes_deep', $value) :
          stripslashes($value);

     return $value;
}

$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);



function clean_post_var($var){
        if (is_array($var)){
                $var = array_map('clean_post_var', $var);
        }

if (get_magic_quotes_gpc()) {
	$var=mysql_real_escape_string(trim(strip_tags($var)));
	$var=htmlspecialchars($var,ENT_QUOTES);
     
	return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version               
}
elseif(!get_magic_quotes_gpc()){
	$var=mysql_real_escape_string(trim(strip_tags($var)));
	$var=htmlspecialchars($var,ENT_QUOTES);
     
	return filter_var($var,FILTER_SANITIZE_STRING);//PHP5 Version
               
}
}


$_POST = array_map('clean_post_var', $_POST);
$_GET = array_map('clean_post_var', $_GET);
$_COOKIE = array_map('clean_post_var', $_COOKIE);
$_REQUEST = array_map('clean_post_var', $_REQUEST);

?>

 

 

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.