Marco's SQL Injection - LFI protection

sql injecton, local file inclusion protectionMany attacks are occurring because of sites' extensions vulnerable to SQL injection or LFI (local file inclusion); this simple plugin increases the level of protection, intercepting the most common types of attack on the site..

Security of your site is not an option, and protect it is an activity that will save you a considerable amount of problems.

 

Versione Italiana: Protezione del sito da SQL injection e local file inclusion
Questo articolo, con le istruzioni in lingua italiana, è disponibile al link sopra indicato.

 

This extension is also published on http://extensions.joomla.org , if you like, it vote it or write a review, thank you.

sql injecton, local file inclusion protection

SQL Injection and Local file Inclusion Protection

This plugin adds a simple but, in most cases, fondamental protection against SQL injection and LFI (local files inclusion) attacks by checking data sent to Joomla and intercept a lot of common exploits, saving your site from hackers.

  • Filters requests in POST, GET, REQUEST. and blocks SQL injection / LFI attempts
  • Notifies you by e-mail when a alert is generated
  • Protect also from unKnown 3rd Party extensions vulnerability.
  • White list for safe components (at your risk ;) )

Enable mail report and prepare yourself to be scared!


Anyway remember that security it is a 'forma mentis', not a plugin!

Standard Set up

  • Works on Front End only:
    ignore request (auto disable plugin) when sent to /administrator
    Be sure all works fine before enable on back end too! especially if you enable IP blocking, or you will not able to access yuor site.
  • NameSpaces inspected:
    Select which superglobal arrays to inspect, options are:
    • Get
    • Get, Post
    • Request
    • Get, Post, Request
  • Ignored Extension
    comma separed list of ignored components (es: com_content, com_dumper , com_weblinks)

Important,pay attention, please!
PHP parses requests and populates the superglobal arrays by copying values into each array. So $_GET['varName'] and $_REQUEST['varName'] are not reference to the same object!
Changing $_GET to sanitize the query string is not enough if the program reads $_REQUEST.

Notification

  • Send Email Alert on injection/inclusion
    if 'Yes' send a mail alert on attack/malformed url
  • Mail to notify attack
    mail to which send alert, if blank is set to 'mailfrom'

Advanced Set up

  • Raise Error on Fault
    if 'YES' stops Joomla! and return an error (set generic error, don't give hints to an attacker), if 'No' cleans up the request and passes it to Joomla!
  • Http Error Code
    HTTP error code to return (40x, 50x)
  • Http Error Message
    a message for error page

Local File Inclusion parameters

  • LFI check only on canonical
    if 'Yes' checks LFI only on model, view, controller, template parameters
  • Max number of consecutive '../'
    how many consecutive '../' can be present in the url

IP Blocking

(from version 1.1)

  • Enable temporary IP block
    Enable/Disable IP Banning
  • Seconds to hold ip banned
    How many seconds hold ip block enabled
  • Max hacks attempt
    Max hacks attempt before ip block starts

Caution: Make sure the 'Debug ' Joomla! be disabled before you enable the IP blocking (only for pre 1.4 versions).

  • make sure theJoomla! 'Debug' is disabled
  • enable IP blocking
  • reactivate the 'Debug' (if you need it, of course)

The 'Debug' Joomla! catches database errors and prevents the plugin to create the table for storing ips.
There is no need to disable debug with version 1.4+ .

DON'T TRY ANY ATTACK after enabling 'IP blocking' and backend's protection! If you do so, you will not able to access your site for the time set in 'Seconds to hold ip banned'.

 

An useful addition

Not all hacks pass through the framework of joomla: the jce editor docet!
So you can add this code to your .htaccess file, paste it just after "RewriteEngine On" :

RewriteCond %{REQUEST_URI}  ^/images/  [NC,OR]
RewriteCond %{REQUEST_URI}  ^/media/  [NC,OR]
RewriteCond %{REQUEST_URI}  ^/logs/  [NC,OR]
RewriteCond %{REQUEST_URI}  ^/tmp/
RewriteRule .*\.(phps?|sh|pl|cgi|py)$ - [F]

This code will block all attempts to run scripts outside the joomla control. May be you have to add other paths depending on components installed.
 

 

Recovery of improper installation

This plugin is working on many hundred sites, but it was not tested with all the most common extensions. Please, check that most important functions of your website are running correctly.

Tested (almost) with:

.ckForms
.virtuemart
.joomfish
.PhocaDownload
.PhocaGallery
.RokDownloads
.AcyMailing
.ccnews
.AlphaRegistration
.
Chrono Contact
.SOBI2

and others.

It's never happened , but better cautious than sorry: if something goes wrong you can easily restore the site by following the instructions below.

Manually disable the plugin

Joomla 1.5!
Use phpmyadmin (or whatelse sql editor you use), select the #__plugins (#__ is usually jos_) table.
Select the record with name equal to "System - Marco's SQL Injection - LFI Interceptor": I suppose it's the last one. Edit this record and set the "published" field to "0". now plugin is disabled.

Joomla 2.5! , Joomla 3.x!
Use phpmyadmin (or whatelse sql editor you use), select the #__extensions (#_ it is a random string. see other tables prefix) table.
Select the record with name equal to "System - Marco's SQL Injection - LFI Interceptor": I suppose it's the last one. Edit this record and set the "enabled" field to "0". now plugin is disabled.

JDatabaseMySQL::query: 1146 - Table 'xxx.yyy_mi_iptable' doesn't exist

Debug was enabled when you activated IP-Blocking;

Disable plugin
see above

Disable Debug
access, via ftp, configuration.php and set

  • J1.5:
    var $debug = '0';
  • J2.5, J3.x:
    public $debug = '0';

reload the page.

Create table manually

Use phpmyadmin (or whatelse sql editor you use), select the sql tab and insert.

CREATE TABLE `#__mi_iptable` (
`ip` VARCHAR(40) NOT NULL COMMENT 'ip to char',
`firsthacktime` DATETIME NOT NULL ,
`lasthacktime` DATETIME NOT NULL ,
`hackcount` INT NOT NULL DEFAULT '1',
`autodelete` TINYINT NOT NULL DEFAULT '1',
PRIMARY KEY ( `ip` )
);
 

"#_" is the table prefix. from J2.5 it is a random string. see other tables.

Blank page after install

Typically you tried to install on PHP4, J1.5 only. no way disable the plugin and upgrade joomla.

 

 

HISTORY

Version 1.6 (14th Nov 2015)

  • better pattern matching
  • IP v6 support
  • various code improvements
  • array inspection
  • unified j2.5 / 3.x version
  • translation support

 

Version 1.4 (Apr 28th, 2014)

  • minor code fixes (not security related)
  • default table type set by DB engine
  • table creation by sql install file

Version Apr 5th, 2013

  • .php 5.3 strict
  • minor code improvements

Version 1.2 (Mar 26th, 2013)

  • Joomla! 3.0 coding style
  • try - catch table checking
  • InnoDB table support

Version 1.1.1 (Mar 23rd, 2013)

  • Joomla! 3.0 compatibility
  • it works fine, nothing else to do ;)

Version 1.1 (Mar 10th, 2011)

  • added auto banning ip (ip blocking)
  • RegEx improvements to intercept more SQL attacks

Version 1.0 (Jan 5th, 2011)

  • Joomla! v1.6 compatibility
  • send mail also when error is raised
  • minor code optimization
  • no bug fix, so you do not need to upgrade

Version .98a (Jun 1st, 2010) Thanks to Jeff

  • fixed backtics matching
  • fixed union all matching
  • fixed ....// exploit
  • added more info to report mail

 

 

Download Marco's SQL Injection - LFI Interceptor Plugin for Joomla!

Please, keep in mind, I repeat: this plugin intercepts a lot of common exploits, not ALL!! this should be intended as an help, this is not "THE SOLUTION".

Joomla! 2.5 & Joomla! 3.x

 

 


 Previous versions (compatibility versions)

(works also on Joomla! 1.6 & Joomla! 1.7, Doesn't work on Joomla! 3.0)

Commenti   

+1 #121 Eugen 2022-02-15 08:24
Hello,
Could you please advice.

Joomla! 3.10.1
PHP Version 7.2.34

Getting this warning:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemMarcos interceptor has a deprecated constructor in /.../.../.../.. ./plugins/syste m/marcosinterce ptor/marcosinte rceptor.php on line 15

Thanks!
Citazione
+1 #120 Thomas Tschechne 2019-12-28 11:08
Great extension!!! Thank you very much and Grretings from Hamburg
Citazione
+3 #119 R3D 2018-08-15 14:41
@Damiel Change the constructor: open
plugins/system/marcosinterceptor/marcosinterceptor.php
and change line 15 from
function plgSystemMarcos interceptor( &$subject, $config ){
to
function __construct( &$subject, $config ){

Regards
Richard
Citazione
+5 #118 Daniel 2017-07-09 14:48
Hello guys, it's been 1 year since I posted here about this issue and I never had any support. Did you abandon the project?
I was wondering if there will be more updates of this amazing extension or if someone could find a fix to this problem. I'm running php 7 and if I try to install Marco's SQL Injection, I get this error:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemMarcos interceptor has a deprecated constructor in ***/plugins/sys tem/marcosinter ceptor/marcosin terceptor.php on line 13

Thanks in advance for any help you can give me!!
Citazione
+3 #117 alex 2017-05-26 20:05
PHP 7.0.17 && JOOMLA 3.7.2 ERROR,
PLEASE FIX IT AND SEND ME NEW VERSION
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemMarcos interceptor has a deprecated constructor in ////.ru/public_ html/plugins/sy stem/marcosinte rceptor/marcosi nterceptor.php on line 15,
Citazione
0 #116 bhavesh 2017-05-11 05:52
sequeryti purpose
Citazione
0 #115 bigblue 2017-05-08 13:52
Hi Marco,

I'm using v1.6 on Joomla 3.6 which works great. Is it ok to update to Joomla 3.7 - will the plugin work ok ?

Thx
Citazione
0 #114 Franco 2017-03-20 11:48
Hi Marco,

Glad that I've found your plugin, thanks! To have some extra protection I want to set the mysql user privilages DROP and DELETE to NO.

When I set the user privilages to DROP=NO and DELETE=NO I get at front and back end an 1142 error: IP Protection not enabled!

I think this is a error message from your plugin?

When I set Drop=NO and DELETE=YES all works fine works, but then hackers still can use the DELETE query. Is this a bug or....??

Thanks in advance for your answer.

Franco
Citazione
+1 #113 pintobuck 2016-11-10 15:24
Marco's Interceptor is a wonderful extension that alerted me to dozens of real hacker attempts. Thank you.

However, the interceptor also alerted me to my web hosting service's proxy server, and sent me a warning email including the proxy server's ip address. That triggered the hosting service's hacked site warning, and they downed my site until the situation was cleared up. So, is it possible for you to add a white list feature to the Interceptor?
Citazione
+2 #112 Daniel 2016-07-31 17:31
Citazione Daniel:
Hello Marco, I was wondering if there will be more updates of this amazing extension. I'm using php y now and I'm getting this error too:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemMarcosinterceptor has a deprecated constructor in ***/plugins/system/marcosinterceptor/marcosinterceptor.php on line 13

Thanks in advance!!


I meant *php 7*
Citazione

Aggiungi commento

Please note: URL in text are not linked and user's site address is only for internal use and is not published.

Comments are human checked. All spam will be removed, so don't waste your time and, especially, mine!

Codice di sicurezza
Aggiorna