Forensic analysis of a Linux web server



Similar documents
CCM 4350 Week 11. Security Architecture and Engineering. Guest Lecturer: Mr Louis Slabbert School of Science and Technology.

Networks and Security Lab. Network Forensics

Automating Linux Malware Analysis Using Limon Sandbox Monnappa K A monnappa22@gmail.com

Nixu SNS Security White Paper May 2007 Version 1.2

Cyber Security In High-Performance Computing Environment Prakashan Korambath Institute for Digital Research and Education, UCLA July 17, 2014

PERDIX: A FRAMEWORK FOR REALTIME BEHAVIORAL EVALUATION OF SECURITY THREATS IN CLOUD COMPUTING ENVIRONMENT

Linux Security Ideas and Tips

Penetration Testing Report Client: Business Solutions June 15 th 2015

Stephen Coty Director, Threat Research

Magento Security Best practices 2015

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY


How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Cybersecurity: An Innovative Approach to Advanced Persistent Threats

Threat Modelling for Web Application Deployment. Ivan Ristic (Thinking Stone)

Codes of Connection for Devices Connected to Newcastle University ICT Network

A perspective to incident response or another set of recommendations for malware authors

Guidance Regarding Skype and Other P2P VoIP Solutions

Nessus Agents. October 2015

How To Monitor Attackers On A Network On A Computer Or Network On An Uniden Computer (For Free) (For A Limited Time) (Czechian) (Cybercrime) (Uk) (Cek) (Kolomot

Building the Next Generation of Computer Security Professionals. Chris Simpson

Linux Server Configuration Guidelines

The current version installed on your server is el6.x86_64 and it's the latest available.

8 steps to protect your Cisco router

Malware Analysis Quiz 6

Where every interaction matters.

Host/Platform Security. Module 11

Traditional Rootkits Lrk4 & KNARK

Securing shared hosting using CageFS

Oracle post exploitation techniques. László Tóth

WEB SITE SECURITY. Jeff Aliber Verizon Digital Media Services

What s Wrong with Information Security Today? You are looking in the wrong places for the wrong things.

Uncovering secret connections among attackers by using network theory and custom honeypots

APT Advanced Persistent Threat Time to rethink?

Emerging Network Security Threats and what they mean for internal auditors. December 11, 2013 John Gagne, CISSP, CISA

ABC LTD EXTERNAL WEBSITE AND INFRASTRUCTURE IT HEALTH CHECK (ITHC) / PENETRATION TEST

Rootkit: Analysis, Detection and Protection

A Case for Managed Security

National Endowment for the Arts Evaluation Report. Table of Contents. Results of Evaluation Areas for Improvement Exit Conference...

Software Vulnerability Assessment

(maybe?)apt1: technical backstage

Network Penetration Testing and Ethical Hacking Scanning/Penetration Testing. SANS Security Sans Mentor: Daryl Fallin

CS 558 Internet Systems and Technologies

Web Application Security

CYBERTRON NETWORK SOLUTIONS

The Dark Side of Trusting Web Searches From Blackhat SEO to System Infection

Threat Events: Software Attacks (cont.)

IptabLes/IptabLex DDoS Bots

Shellshock. Oz Elisyan & Maxim Zavodchik

External Network Penetration Test Report

Storm Worm & Botnet Analysis

Inside the Storm: Protocols and Encryption of the Storm Botnet

1. Why is the customer having the penetration test performed against their environment?

Firewalls and Intrusion Detection

IBM Protocol Analysis Module

Cloud Security:Threats & Mitgations

Worms, Trojan Horses and Root Kits

Breakthrough Cyber Security Strategies. Introducing Honeywell Risk Manager

Hackers: Detection and Prevention

static void insecure (localhost *unix)

Cisco IPS Tuning Overview

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

Uroburos Highly complex espionage software with Russian roots

COURCE TITLE DURATION LPI-202 Advanced Linux Professional Institute 40 H.

Protecting Your Organisation from Targeted Cyber Intrusion

Criteria for web application security check. Version

Linux Operating System Security

EXTRA. Vulnerability scanners are indispensable both VULNERABILITY SCANNER

Improving Web Vulnerability Scanning. Daniel Zulla

Today s Topics. Protect - Detect - Respond A Security-First Strategy. HCCA Compliance Institute April 27, Concepts.

How To Attack A Website With An Asymmetric Attack

Overview of Network Security The need for network security Desirable security properties Common vulnerabilities Security policy designs

Hardened Hosting. Quintin Russ. OWASP New Zealand Chapter th December 2011

A Decision Maker s Guide to Securing an IT Infrastructure

Chapter 8 Security Pt 2

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Penetration Testing with Kali Linux

EMERGING THREATS & STRATEGIES FOR DEFENSE. Stephen Coty Chief Security

Magento Security and Vulnerabilities. Roman Stepanov

Security Threat Kill Chain What log data would you need to identify an APT and perform forensic analysis?

SECURITY TRENDS & VULNERABILITIES REVIEW 2015

6WRUP:DWFK. Policies for Dedicated IIS Web Servers Group. V2.1 policy module to restrict ALL network access

Andreas Dittrich, Philipp Reinecke Testing of Network and System Security. example.

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

Spam and All Things Salty: Spambot v2013

10 Things Every Web Application Firewall Should Provide Share this ebook

Intrusion Detection using the Linux Audit Framework. Stephen Quinney School of Informatics University of Edinburgh

WHY DOES MY SPEED MONITORING GRAPH SHOW -1 IN THE TOOLTIP? 2 HOW CAN I CHANGE MY PREFERENCES FOR UPTIME AND SPEED MONITORING 2

September 20, 2013 Senior IT Examiner Gene Lilienthal

What Do You Mean My Cloud Data Isn t Secure?

Transcription:

Mathieu Deous Julien Reveret Forensic analysis of a Linux web server 1

Agenda Who are we? Performing forensic analysis on a compromised web server What to search, where, how? Logs but also dynamic analysis What about privilege escalation? How has rootkit detection evolved? 2

Who are we? Security guys doing both offensive and defensive stuff Our company is hosting 3000+ sites in a private cloud 3

Agenda Who are we? Performing forensic analysis on a compromised web server What to search, where, how? Logs but also dynamic analysis What about privilege escalation? How has rootkit detection evolved? 4

Performing forensic analysis on a compromised web server Some people think finding out what attackers did on a server is an easy task since their activities are «obviously malicious» : - Sending spam - Scanning /DoSing other servers - Hosting phishing sites But sometimes there can be days, weeks, months between a compromise and illegal activities 5

Performing forensic analysis on a compromised web server You end up trying to find files which don t exist anymore Sometimes access to webshells are sold on underground markets: Tons of different IP addresses Who first dropped the malicious files? How did the attacker(s) compromise the web server? What did the attacker(s) do? 6

Performing forensic analysis on a compromised web server 7

Agenda Who are we? Performing forensic analysis on a compromised web server What to search, where, how? Logs but also dynamic analysis What about privilege escalation? How has rootkit detection evolved? 8

What to search, where, how? Logs Detecting a compromise using logs: - You know what the backoffice URI is, you can check for: - Bruteforce attempts - Login success and sort the IP addresses - You found a malicious file: - Check the logs for it Apply the iterative process Find other IP addresses Potentially find other malicious file or compromise source - On a wordpress blog: upon successful authentication, the user is redirected using a 302 HTTP code, you can easily find if an attacker successfully logged into the wordpress backoffice! «Know your web applications!» 9

What to search, where, how? php-malware-finder Do you know Yara? From https://github.com/plusvic/yara : YARA is a tool aimed at (but not limited to) helping malware researchers to identify and classify malware samples. Thanks to Julien Voisin, we now have a set of yara rules to detect most of the PHP malwares usually found on our customers compromised servers. Get it at http://github.com/nbs-system/phpmalware-finder 10

What to search, where, how? php-malware-finder Example usage: $ php-malware-finder f /var/www/customer/prod/ ObfuscatedPhp /var/www/customer/prod/blog/wp-content/uploads/2015/06/maink.php ObfuscatedPhp /var/www/customer/prod/blog/wp-content/plugins/nrelate-related-content/nrelaterelated.php ObfuscatedPhp /var/www/customer/prod/var/usimpleup/unpacked/unirgy_storelocator.zip/app/code/community/unirgy/s torelocator/helper/protected.php ObfuscatedPhp /var/www/customer/prod/lib/pear/soap/wsdl.php DodgyStrings /var/www/customer/prod/lib/phpseclib/net/ssh1.php ObfuscatedPhp /var/www/customer/prod/lib/zend/session.php DodgyPhp /var/www/customer/prod/lib/zend/ldap/converter.php The maink.php file is a malware, others are false positives ;) 11

What to search, where, how? php-malware-finder Can t you get rid of false positives? Not sure, look at this «legitimate» Magento module: $ less./model/mysql4/enginecategory.php <?php ${"GLO\x42\x41LS"}["w\x73\x74h\x72si"]="\x75\x70\x64\x61\x74e\x51\x75\x65\x72\x79";${"\x47\x4c\x4 f\x42\x41\x4c\x53"}["\x6b\x6e\x77\x64\x62q\x6e"]="\x63\x61\x74a\x6c\x6fg\x43a\x74\x65go\x72y\x45\ x6e\x74\x69t\x79te\x78tt\x61\x62\x6c\x65";${"\x47\x4co\x42\x41\x4cs"}["\x75\x6feh\x70\x6f"]="\x72 \x65s\x75\x6ct";${"\x47lob\x41\x4cs"}["sp\x63g\x72\x65\x76l\x63b\x65"]="\x77\x68\x65\x72e";${"\x4 7\x4c\x4fB\x41\x4cS"}["que\x6ae\x78\x74\x6b\x75"]="\x69\x74\x65m";${"\x47\x4c\x4fB\x41L\x53"}["\x 68h\x63il\x6biq\x74us\x70"]="i\x74e\x6d\x73";${"\x47\x4cO\x42A\x4cS"}["\x70\x65\x65\x6c\x69\x6cy\ x66\x6cdf"]="\x76\x61\x6c\x75es";${"\x47\x4c\x4fb\x41ls"}["hh\x6fz\x6a\x70\x64\x62b\x6b\x62\x75"] ="\x63\x6fl\x75\x6dn\x73";${"\x47\x4c\x4fb\x41\x4c\x53"}["k\x64\x79o\x61\x6cj"]="\x65\x6d\x70\x74 y\x52e\x63\x6f\x72d";${"\x47\x4c\x4f\x42\x41\x4c\x53"}["t\x69\x72\x6at\x6c\x65\x7aon"]="\x72\x6f\ x77";${"\x47\x4c\x4f\x42\x41l\x53"}["\x65\x6f\x70i\x78\x78\x6c\x69"]="i";${"g\x4c\x4f\x42\x41\x4c \x53"}["\x76\x69\x67\x67\x68dq\x67u"]="\x73\x71l";${"\x47\x4c\x4f\x42als"}["e\x6e\x78b\x6cx\x71uo \x71\x72\ 12

What to search, where, how? Offensive tools «To survive the war, you gotta become the war» There are opensource tools to test the security of web applications. Let s stick to our WordPress blog and find tools to exploit vulnerabilities: - WIG: Webapp Information Gatherer - Sucuri wordpress scanner or Vane (wordpress scanner fork) - CMSmap - Arachni 13

Performing forensic analysis on a compromised web server First step is to determine as much as you can about the web application, wig aims at providing information. Tools such as wpscan maybe give you hint about which vulnerability the attacker(s) used: Title: WordPress Slider Revolution Vulnerability Reference: https://wpvulndb.com/vulnerabilities/7540 Reference: http://blog.sucuri.net/2014/09/slider-revolution-plugin-critical-vulnerability-beingexploited.html Reference: http://marketblog.envato.com/general/affected-themes/ Reference: http://osvdb.org/109645 Reference: http://www.exploit-db.com/exploits/34511/ Reference: http://www.exploit-db.com/exploits/35385/ 14

Agenda Who are we? Performing forensic analysis on a compromised web server What to search, where, how? Logs but also dynamic analysis What about privilege escalation? How has rootkit detection evolved? 15

What about privileges escalation? Most illegal activities don t require high privileges : - Hosting a phishing site can be done only with Apache right - Sending spam is possible even for a low privilege account - Simple (d)dos tools But sometimes, the attacker gets root privileges, because: - There was an obvious unpatched local vulnerability on your server - He/She was determined (did someone say APT?) 16

What about privileges escalation? How would you detect such escalation? One answer is: snoopy snoopy is merely a shared library that is used as a wrapper to the execve() function provided by libc as to log every call to syslog (authpriv). system administrators may find snoopy useful in tasks such as light/heavy system monitoring, tracking other administrator's actions as well as getting a good 'feel' of what's going on in the system (for example Apache running cgi scripts)... And don t forget to centralize your logs ;-) 17

What about privileges escalation? How would you prevent it from happening? By hardening your system: - Use a Grsec patched kernel (that s what we do) - Contain applications using AppArmor - Regularly assess your system - Unix-privesc-check - Lynis 18

What about privileges escalation? [+] Debian Tests ------------------------------------ - Checking for system binaries that are required by Debian Tests... - Checking /bin... [ FOUND ] - Checking /usr/local/sbin... [ FOUND ] - Authentication: - PAM (Pluggable Authentication Modules): - libpam-tmpdir [ Not Installed ] - File System Checks: - DM-Crypt, Cryptsetup & Cryptmount: - Checking / on /dev/sda1 [ NOT ENCRYPTED ] - Software: - apt-listbugs [ Not Installed ] - apt-listchanges [ Installed and enabled for apt ] 19

What about privileges escalation? You can look at your system activity too! Using what? Strace on processes? Please, we re in 2015 ;) Sysdig can be really helpful and it has many modules: $ sysdig c topprocs_net $ sysdig c topconns And last but not least: $ sysdig c spy_users 20

What about privileges escalation? $ sysdig -c topprocs_net Bytes Process ------------------------------ 788.63M /usr/sbin/httpd 69.69M /usr/local/bin/selks 5.27M sshd 2.38M wget 20.81KB httpd 9.94KB httpd 6.40KB bash $ sysdig -c topconns Bytes Proto Connection ------------------------------ 3133.7M udp 10.0.0.3:14929->5.43.24.212:80 4.91M tcp 192.168.135.30:29421->10.0.0.3:22 21

Agenda Who are we? Performing forensic analysis on a compromised web server What to search, where, how? Logs but also dynamic analysis What about privilege escalation? How has rootkit detection evolved? 22

How has rootkit detection evolved? Spotting a rootkit on a compromised server using only live analysis is no easy task (thanks Captain Obvious!) Sysdig to the rescue: Able to intercept communications between userland and kernel-land Csysdig : curses tool, helpful for visualization As the author says: «think of it as all your favorite tools in one» Also, @unixist coded camb, a new idea of LKM rootkit detection 23

How has rootkit detection evolved? 24

How has rootkit detection evolved? There are other means to detect changes, in particular LKM rootkits. They can hide from lsmod, but they re still present. One way @unixist found is to hash the Linux kernel.text segment: $ sudo insmod camb.ko $ cat /sys/kernel/camb/text_segment_hash 86b8e609d011122f449839105255a481357e493d later on the same server $ cat /sys/kernel/camb/text_segment_hash A13608340e76ca69c459ef8244fafc8798f1370d I think we caught something ;) 25

Conclusions 26

Conclusions Detecting userland malwares is easy (most of the times) but can take time Privileges escalation aren t so common, at least from our point of view ;) Remember, bad guys can be stupid too and sometimes forget to cover their tracks! Look for specific User Agents, specific IP addresses (did somebody say Tor exit nodes?) Are the malware files obfuscated? Really? I mean, did you replace eval by print? Brace yourselves, APT is coming. 27

Any questions? 28