cms hacking tricks - derbycon 4 - 2014

67
CMS Hacking Tricks Owning Content Management Systems Greg Foss | OSCP, GPEN, GWAPT, GCIH, CEH Senior Security Research Engineer | LogRhythm Labs

Upload: greg-foss

Post on 05-Dec-2014

517 views

Category:

Technology


2 download

DESCRIPTION

Drupal, WordPress, and Joomla are very popular Content Management Systems (CMS) that have been widely adopted by government agencies, major businesses, social networks, and more — underscoring why understanding how these systems work and properly securing these applications is of the utmost importance. This talk focuses on the penetration tester’s perspective of CMS’ and dives into streamlining the assessment and remediation of commonly observed application and configuration flaws by way of custom exploit code and security checklists- all of which are open-source and can be downloaded and implemented following the presentation.

TRANSCRIPT

Page 1: CMS Hacking Tricks - DerbyCon 4 - 2014

CMS Hacking Tricks!Owning Content Management Systems

!!

Greg Foss | OSCP, GPEN, GWAPT, GCIH, CEH!Senior Security Research Engineer | LogRhythm Labs

Page 2: CMS Hacking Tricks - DerbyCon 4 - 2014

Just a Few Content Management Systems

Page 3: CMS Hacking Tricks - DerbyCon 4 - 2014

Security?

Page 4: CMS Hacking Tricks - DerbyCon 4 - 2014

Image: http://www.emerce.nl/content/uploads/2012/10/Monkey-Barcode-Scanner-88205.jpg

Page 5: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal - https://site.com/CHANGELOG.txt

Page 6: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal - https://site.com/CHANGELOG.txt

Page 7: CMS Hacking Tricks - DerbyCon 4 - 2014

Joomla - https://site.com/htaccess.txt

Page 8: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress - https://site.com/readme.html

Page 9: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress - https://site.com/readme.html

Page 10: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress - https://site.com/readme.html

Page 11: CMS Hacking Tricks - DerbyCon 4 - 2014

Joomla - Targeted Scanning

http://sourceforge.net/projects/joomscan/

Page 12: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress - Targeted Scanning

http://wpscan.org

Page 13: CMS Hacking Tricks - DerbyCon 4 - 2014

Intelligent Fingerprinting

• https://code.google.com/p/cms-explorer/

#  perl  cms-­‐explorer.pl  -­‐-­‐url  http://some.cms.org    -­‐-­‐type  [CMS]  -­‐-­‐osvdb    !

• http://blindelephant.sourceforge.net/

#  python  BlindElephant.py  http://some.cms.org  [CMS]

Page 14: CMS Hacking Tricks - DerbyCon 4 - 2014

Image: http://is1103.com/2013/10-October/source.png

Page 15: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 16: CMS Hacking Tricks - DerbyCon 4 - 2014

http://blog.conviso.com.br/2013/06/github-hacking-for-fun-and-sensitive.html

Page 17: CMS Hacking Tricks - DerbyCon 4 - 2014

Scrape Internal GitHub

Page 18: CMS Hacking Tricks - DerbyCon 4 - 2014

Joomla [docroot]/configuration.php

Page 19: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress [docroot]/wp-config.php

Page 20: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal [docroot]/sites/default/settings.php

MySQL Creds…

Drupal Hash Salt…

Page 21: CMS Hacking Tricks - DerbyCon 4 - 2014

Remediation…

Page 22: CMS Hacking Tricks - DerbyCon 4 - 2014

Gaining Admin Access to Drupal

Already have server access? !Drush available? !Create a one-time link to log in as an admin… !$ cd [drupal directory] $ drush uli

Page 23: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 24: CMS Hacking Tricks - DerbyCon 4 - 2014

Joomla Password Reset Abuse

Page 25: CMS Hacking Tricks - DerbyCon 4 - 2014

WordPress Password Reset Abuse

Page 26: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal Password Reset Abuse

Page 27: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal Password Reset Abuse

Page 28: CMS Hacking Tricks - DerbyCon 4 - 2014

User Enumeration is EZ

Page 29: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 30: CMS Hacking Tricks - DerbyCon 4 - 2014

Image: http://security-is-just-an-illusion.blogspot.com/2013/11/wordlistpaswordlist-for-dictionary.html

Page 31: CMS Hacking Tricks - DerbyCon 4 - 2014

Single Account…

Page 32: CMS Hacking Tricks - DerbyCon 4 - 2014

All the Accounts!

Page 33: CMS Hacking Tricks - DerbyCon 4 - 2014

Joomla & WordPress• Brute Forcing w/ Burp works against WordPress

too!

• Will not work against Joomla…

• Joomla integrates a unique form token per login request, which is actually verified by the server (unlike Drupal’s form token) :-P

• Brute forcing can be scripted but will be slow…

Page 34: CMS Hacking Tricks - DerbyCon 4 - 2014

Uh OhNew Security Controls in Drupal 7…

Even better in Drupal 8!

Page 35: CMS Hacking Tricks - DerbyCon 4 - 2014

Change it up…

Page 36: CMS Hacking Tricks - DerbyCon 4 - 2014

Just Be Careful…

Page 37: CMS Hacking Tricks - DerbyCon 4 - 2014

‘Mitigation’

Page 38: CMS Hacking Tricks - DerbyCon 4 - 2014

Configure Appropriately

Page 39: CMS Hacking Tricks - DerbyCon 4 - 2014

Session Handling

Image: http://blog.codinghorror.com/content/images/uploads/2012/02/6a0120a85dcdae970b016301e98de2970d-800wi.png

Page 40: CMS Hacking Tricks - DerbyCon 4 - 2014

Missing Updates• Drupal

!

!

• WordPress

!

• Joomla

Page 41: CMS Hacking Tricks - DerbyCon 4 - 2014

Update Notifications• Drupal!

• http://lists.drupal.org/mailman/listinfo/security-news

• https://drupal.org/security/rss.xml

• Joomla!

• http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions

• https://watchful.li/features/

• WordPress!

• https://wordpress.org/plugins/wp-updates-notifier/

• http://codex.wordpress.org/Mailing_Lists#Announcements

Page 42: CMS Hacking Tricks - DerbyCon 4 - 2014

Application Logging

• CMS logs should be captured and stored outside of the database to ensure log integrity.

!

• SIEM – Security Information Event Management

Page 43: CMS Hacking Tricks - DerbyCon 4 - 2014

• Watchdog – Drupal’s built in logging, captures data within the ‘Watchdog’ database table.

• Syslog – Export Drupal’s logs to the Linux syslog. Creates a flat file that is easy to monitor.

Drupal Application Logging

Page 44: CMS Hacking Tricks - DerbyCon 4 - 2014

• Nothing built in… Need to use a plugin which stores security logs to a database table

• https://wordpress.org/plugins/wp-security-audit-log/

WordPress Application Logging

Page 45: CMS Hacking Tricks - DerbyCon 4 - 2014

• Must be configured manually within Joomla’s configuration and is not enabled by default.

!

• Flat file logging can be set up using JLog!

!

• http://developer.joomla.org/manual/ch02s05s03.html

Joomla Application Logging

Page 46: CMS Hacking Tricks - DerbyCon 4 - 2014

Authorization

• What are users allowed to do within comment fields? !

• New filtered HTML tags?

• Full HTML Enabled?

Image: http://musformation.com/pics/trust-but-verify.jpg

Page 47: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 48: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 49: CMS Hacking Tricks - DerbyCon 4 - 2014

Unrestricted File Uploads

Page 50: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 51: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal File Upload Vuln Fixed?• Uploading and executing PHP code has been ‘fixed’

in recent versions of Drupal as of November 2013

• https://drupal.org/SA-CORE-2013-003

• Code execution prevention

• (Files directory .htaccess for Apache - Drupal 6 and 7)

• Not exactly… <evil> :-) </evil>

• Drupal 8 Fix? - https://www.drupal.org/node/1587270

Page 52: CMS Hacking Tricks - DerbyCon 4 - 2014

Insecure WordPress Plugins• TimThumb - Popular and common plugin!

• v 2.8.13 WebShot Remote Code Execution

• http://www.exploit-db.com/exploits/33851/

Page 53: CMS Hacking Tricks - DerbyCon 4 - 2014

Insecure Joomla Extensions• Quite a few… Most interesting is a SQLi in Core

• We’ll Look into this later…

Page 54: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal Development Modules

• Modules that assist with active development

• Remove prior to Test / Staging

• Never leave installed on Production applications

• Picking on…

• Devel — https://drupal.org/project/devel

• Masquerade – https://www.drupal.org/project/masquerade

Page 55: CMS Hacking Tricks - DerbyCon 4 - 2014

Drupal - Masquerade• Allows you to change accounts to any other user

Page 56: CMS Hacking Tricks - DerbyCon 4 - 2014

Devel• Module used for development

• Should never be installed on production, ever…

• Allows users to view debugging information, including full database details of application content.

• Also allows for PHP code execution!

Page 57: CMS Hacking Tricks - DerbyCon 4 - 2014

Password Hash Disclosure

Page 58: CMS Hacking Tricks - DerbyCon 4 - 2014

Automated Hash Extraction

Page 59: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 60: CMS Hacking Tricks - DerbyCon 4 - 2014

Cracking Drupal Hashes• Drupal 7!

#  john  d.hash  –wordlist=“rockyou.txt”  –salt=“TPcVtqQcs37Q69hDTViwiFiHqUV41tyAd3LnnjmNrbA”  –format=“drupal7”  

• Drupal 6!

#  john  d.hash  –wordlist=“rockyou.txt”  

        OR  

#  hashcat  -­‐m  -­‐0  -­‐a  0  -­‐o  d.txt  d.hash  rock.dict

Page 61: CMS Hacking Tricks - DerbyCon 4 - 2014
Page 62: CMS Hacking Tricks - DerbyCon 4 - 2014

Cracking WordPress & Joomla Hashes

• WordPress!

  #  hashcat  -­‐m  400  -­‐a  0  -­‐o  wp.txt  wp.hash  rock.dict  

• Joomla!

  #  hashcat  -­‐m  11  -­‐a  0  -­‐o  j.txt  j.hash  rock.dict

Page 63: CMS Hacking Tricks - DerbyCon 4 - 2014

PHP Code Execution

Page 64: CMS Hacking Tricks - DerbyCon 4 - 2014

I <3 Shells

Page 65: CMS Hacking Tricks - DerbyCon 4 - 2014

< DEMO >

Page 66: CMS Hacking Tricks - DerbyCon 4 - 2014

Closing Thoughts…• Do your research to better understand your organizational

architecture, servers, applications, log data, etc.

• Pen Test your applications, don’t just scan…

• Update early and often!

• Embed security with development from the beginning.

• Download scripts to augment the penetration testing process of Drupal applications:

• https://github.com/gfoss/attacking-drupal/

Page 67: CMS Hacking Tricks - DerbyCon 4 - 2014

Thank You!

Questions?!

https://github.com/gfoss/attacking-drupal/ !

Greg Foss | OSCP, GPEN, GWAPT, GCIH, CEHSenior Security Research Engineer

greg.foss[at]LogRhythm.com @heinzarelli