Integrity Check

From Contao Community Documentation

Revision as of 10:22, 2 August 2012 by BugBuster (Talk | contribs)

I'm not a native English speaker. Please correct my mistakes.

Integrity check for some files from Contao (Detection of hacked Contao installations.)


Extension-Overview
Name of the developer Glen Langer (BugBuster)
Developer Website http://www.contao.glen-langer.de
Version of the extension 0.2.0 rc1
Compatibility with Contao Version ab 2.10.0
Link to Extension Repository http://www.contao.org/en/extension-list/view/integrity_check.en.html
Link to Tracker https://github.com/BugBuster1701/integrity_check/issues

In Contao Forum, reports came about changed files, which malicious code was attached.
The problem itself can not be attributed to a vulnerability in Contao, but will be distributed over other ways of the server, eg vulnerable WP plugins, hacked servers, hacked FTP logins, etc.

Forum

Questions about the Bot Detection module will be answered in Forum
Errors and requests can be reported in the Issue Tracker.

Installation

The installation of the module occurs about the extension Repository in back end of Contao.
A manual installation is possible. Download the ZIP file from Extension Repository, unzip and transfer it.
A directory should have been created "/system/modules/integrity_check".
Then call /contao/install.php - Perform Update Database.

Example of an Infection

How now looks like such a hack?
The attachment to the file index.php looked like this (shortened):

#c3284d#
echo(gzinflate(base64_decode("ZZBNisMwDIX.......T7oD")));
#/c3284d#

Function of the module

In the current version 0.2.0, the three most important PHP files are checked for modifications.
This files will be checked:

  • index.php
  • contao/index.php
  • contao/main.php

Time of verification

This test is performed automatically every day. (Contao-Cron)

Detection

The check is identical to the official Contao check tool, that means via MD5 checksums. Checksums are available for comparison for Contao from 2.10.0.

Using

In the backend, you can see the results: System - System Log. Normally, if everything is OK, there appears only one message:

  • Check files for integrity is finished.

If modifications were detected, a message is generated for each file:

  • Integrity status for file index.php is: Corrupt

An information by mail is possible, see the section Mail_to_Admin.

Technical Details

Time of verification

The time of verification you can change in the file localconfig.php, eg Contao 2.11 users can change the test to hourly. In the localconfig.php the following line is appended at the end of the file:

$GLOBALS['TL_CRON']['hourly'][] = array('Integrity_Check', 'checkFiles');

Mail to Admin

It is possible to send a mail to the Admin of the installation. In the localconfig.php the following line is appended at the end of the file:

$GLOBALS['TL_CONFIG']['mod_integrity_check']['send_email_to_admin'] = true;

Debug Modus

Normalerweise gibt das Modul nur eine "fertig" Meldung aus im System-Log. Will man sehen welche Dateien geprüft wurden und somit ob überhaupt, kann der moduleigene Debug Modus eingeschaltet werden. Dazu muss, derzeit noch per Hand, in die localconfig.php eine Zeile am Ende der Datei eingetragen werden:

$GLOBALS['TL_CONFIG']['mod_integrity_check']['debug'] = true;

Schutz gegen Infektion

Nun, ein genereller Schutz ist wohl nicht möglich. Wenn die Infektion z.B. dadurch passierte, dass jemand an die FTP Daten kam, kann er alles was der Eingentümer auch kann.
Es gibt aber eine Möglichkeit, dass der angehangene Code nicht zur Ausführung kommt. Ein Ticket dazu gibt es bereits auf GitHub, hier mal kurz die Info.
Editiert die index.php und geht in die letzte Zeile der Methode run, müsste die Zeile 269 sein. (2.11.5) Schreibt davor einfach ein exit; rein, oder fügt eine Zeile dafür ein. Hier mal ab Zeile 268 als Beispiel:

        }
    }

wird zu:

        }
        exit;
    }

Damit wird die Abarbeitung des Scripte beendet, was auch OK ist, da davor die Seite bereits zum Browser gesendet wurde. Achtung: Nun wird das Integrity Check Tool wie auch das Contao Check Tool eine Veränderung melden.

Views
Personal tools

Contao Community Documentation

In other languages
Navigation
Discover
Understand
Enhance
Miscellaneous
Tools