OH NOES, a DRUPAL CORE HACK DETECTED!

JP's picture

After working on some 50-odd Drupal projects over the past few years and inheriting a number of (often questionable) others, it occurred to us it'd be a good idea to have a script that detects hacks and/or "modifications" to Drupal core for a given Drupal install. The result is this remedial PHP script (or core agent) that detects your version of Drupal, downloads the appropriate tarball from Drupal.org, runs a diff on /modules, /misc and /includes, and returns you the results.

Here's some sample output:

************************************
* Drupal Core Agent v1.0 *
************************************
No argument specified; running in current directory
Fetching Drupal version 5.10
Drupal version 5.10 downloaded. Extracting..
Drupal core files extracted. Comparing..
+---------------------------------------------------+
Comparing modules ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/aggregator ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/block ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/blog ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/blogapi ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/book ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/color ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/color/images ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/comment ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/contact ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/drupal ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/filter ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/forum ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/help ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/legacy ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/locale ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/menu ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/node ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/path ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/ping ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/poll ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/profile ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/search ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/statistics ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/system ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/taxonomy ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/throttle ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/tracker ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/upload ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/user ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing modules/watchdog ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing misc ..
+---------------------------------------------------+
FILE NOT PRESENT IN 5.10 CORE: misc/.htaccess
DRUPAL CORE HACK DETECTED: misc/collapse.js
+---------------------------------------------------+
Comparing misc/farbtastic ..
+---------------------------------------------------+
DRUPAL CORE HACK DETECTED: misc/jquery.js
DRUPAL CORE HACK DETECTED: misc/tableselect.js
DRUPAL CORE HACK DETECTED: misc/upload.js
+---------------------------------------------------+
Comparing includes ..
+---------------------------------------------------+
DRUPAL CORE HACK DETECTED: includes/common.inc
FILE NOT PRESENT IN 5.10 CORE: includes/common.inc.orig
+---------------------------------------------------+
Comparing themes ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/bluemarine ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/chameleon ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/chameleon/marvin ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/engines ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/engines/phptemplate ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/garland ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/garland/color ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/garland/images ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/garland/minnelli ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/garland/minnelli/color ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing themes/pushbutton ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing profiles ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing profiles/default ..
+---------------------------------------------------+
+---------------------------------------------------+
Comparing scripts ..
+---------------------------------------------------+
Cleaning up ..
Finished.

You can find more information and grab the latest release here:

http://code.google.com/p/coreagent/

NEXT UP: Adding support for contrib modules, and--more immediately--turning it into a Drupal module with hooks for Drush.


UPDATE:

I've added an optional parameter so you can now specify the version of Drupal you want to diff against - this is particularly useful when doing upgrades, since it will allow you to see what files have changed from your previous version.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
Are you a robot? We usually like robots, but not in our comments.
By submitting this form, you accept the Mollom privacy policy.