Fixing the Plaincart Hack

by David Harris // March 16  

Plaincart SQL Security Injection Vulnarability.

The Plaincart is a php shopping cart tutorial designed in 2006 and is a great resource for people wanting to learn how to build their first shopping cart system. This tutorial has one main security vulnerability that is very easy to hack. It actually does not even take a hacker to be able to compromise a Plaincart install because the method to discover the user and password info is openly distributed on many websites. The method is as easy as appending the below attributes after the root directory of your Plaincart install.

http://[target]/[script]/index.php?c=16&p=-3+UNION+SELECT+user_name,user_password,3,4,5+from+tbl_user—


There is a fix for the Plaincart SQL Injection Vulnarabilty hack all you have to do is  follow the steps below

Books Worth Reading:
Sponsored
Book 1799Book 1862Book 1844Book 1871Book 1867Book 1848

1. Open your index.php

2. Find line 10 and select:

$pdId   = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;

Books Worth Reading:
Sponsored
Book 1799Book 1862Book 1844Book 1871Book 1867Book 1848

3. Replace line 10 with:

function valid_pdId($get)
{
$x = isset($_GET[$get])&&$_GET[$get]!='1' ? $_GET[$get] : '';
if ( !ctype_digit($x) ) {
$x = ' ';
}
return $x;
}
$pdId = valid_pdId('p');

 

Books Worth Reading:
Sponsored
Book 1799Book 1862Book 1844Book 1871Book 1867Book 1848

Though there are many great paid ecommerce solutions out there that we would recommend you use instead of Plaincart, this quick fix should remedy the sql injection hack if you find your hands tied!

 

About the Author

David Harris is a content writer at Adazing with 20 years of experience navigating the ever-evolving worlds of publishing and technology. Equal parts editor, tech enthusiast, and caffeine connoisseur, he’s spent decades turning big ideas into polished prose. As a former Technical Writer for a cloud-based publishing software company and a Ghostwriter of over 60 books, David’s expertise spans technical precision and creative storytelling. At Adazing, he brings a knack for clarity and a love of the written word to every project—while still searching for the keyboard shortcut that refills his coffee.

mba ads=36