4
12 – ISSA Journal | November 2012 ISSA DEVELOPING AND CONNECTING CYBERSECURITY LEADERS GLOBALLY I magine that a rogue laptop connects to your corporate WiFi and is able to access the Internet via your corporate proxy server. Let us assume that your WiFi is protected by a pre-shared key, but that this rogue laptop is owned by a former employee. Will you detect this? And will you be able to trace back to the former employee? A foreign competitor hires a tech-savvy criminal to install a trojaned operating system on your edge router. This trojan facilitates access to your corporate network for unauthorized persons by tampering with the authentication control logic. Will you detect the trojaned router? These two examples represent two common classes of foren- sic investigations where forensic evidence needs to be col- lected from network devices. In the first example, network devices contain evidence of the network traffic that flowed through them. In the second example, network devices have been compromised and forensic evidence needs to be lifted from them. Forensic evidence gathered by network devices To operate properly, network devices need to maintain infor- mation about the network traffic they process. Since network devices have limited amounts of memory compared to gen- eral purpose computers, they tend to collect only the bare es- sential information for their processes and this information is discarded rather quickly when it is no longer needed. There is often a significant delay between the time a security incident occurs and the time the forensic investigation starts. And as a switch or router discards obsolete meta data quickly, you will not find forensic evidence if you react too late. But you can improve the success rate of your forensic evi- dence gathering by configuring your switches and routers to collect additional data and persist this data. All professional network devices allow for the logging of events. But the inter- nal event log of network devices is rather small because of the memory constrains. Old events get discarded at a fast rate to make place for new events. Centralized logging Here is an important first opportunity for you to improve the evidence collection phase of your forensic investigations. Install one or more machines as a central log repository and configure all your network devices to forward events to this central log repository. Dimension your central log repository so that it can hold several months worth of events. The syslog standard is often used to centralize events. The second opportunity you have to improve the evidence collection phase of your forensic investigations, is by increas- ing the types of events that are logged, for example DHCP events. Professional network devices classify events by types and by alert level. Not all event types are logged by default, and only events with important alert levels are logged. In- crease the type of events, and lower the alert level for event The goal of this article is to raise awareness about the measures you can take to improve the success of network forensics. By Didier Stevens – ISSA member, Belgian Chapter ©2012 ISSA • www.issa.org • [email protected] • All rights reserved.

Network Device Forensics

Embed Size (px)

Citation preview

Page 1: Network Device Forensics

Network Device Forensics

Network Device

Forensics

12 – ISSA Journal | November 2012

ISSA DEVELOPING AND CONNECTING

CYBERSECURITY LEADERS GLOBALLY

Imagine that a rogue laptop connects to your corporate WiFi and is able to access the Internet via your corporate proxy server. Let us assume that your WiFi is protected

by a pre-shared key, but that this rogue laptop is owned by a former employee. Will you detect this? And will you be able to trace back to the former employee?

A foreign competitor hires a tech-savvy criminal to install a trojaned operating system on your edge router. This trojan facilitates access to your corporate network for unauthorized persons by tampering with the authentication control logic. Will you detect the trojaned router?

These two examples represent two common classes of foren-sic investigations where forensic evidence needs to be col-lected from network devices. In the first example, network devices contain evidence of the network traffic that flowed through them. In the second example, network devices have been compromised and forensic evidence needs to be lifted from them.

Forensic evidence gathered by network devicesTo operate properly, network devices need to maintain infor-mation about the network traffic they process. Since network devices have limited amounts of memory compared to gen-eral purpose computers, they tend to collect only the bare es-sential information for their processes and this information is discarded rather quickly when it is no longer needed.

There is often a significant delay between the time a security incident occurs and the time the forensic investigation starts. And as a switch or router discards obsolete meta data quickly, you will not find forensic evidence if you react too late.

But you can improve the success rate of your forensic evi-dence gathering by configuring your switches and routers to collect additional data and persist this data. All professional network devices allow for the logging of events. But the inter-nal event log of network devices is rather small because of the memory constrains. Old events get discarded at a fast rate to make place for new events.

Centralized logging

Here is an important first opportunity for you to improve the evidence collection phase of your forensic investigations. Install one or more machines as a central log repository and configure all your network devices to forward events to this central log repository. Dimension your central log repository so that it can hold several months worth of events. The syslog standard is often used to centralize events.

The second opportunity you have to improve the evidence collection phase of your forensic investigations, is by increas-ing the types of events that are logged, for example DHCP events. Professional network devices classify events by types and by alert level. Not all event types are logged by default, and only events with important alert levels are logged. In-crease the type of events, and lower the alert level for event

The goal of this article is to raise awareness about the measures you can take to improve the success of network forensics.

By Didier Stevens – ISSA member, Belgian Chapter

©2012 ISSA • www.issa.org • [email protected] • All rights reserved.

Page 2: Network Device Forensics

Trojanized devices

The operating system of your network devices can be tro-janized in two ways: by trojanizing the operating system files (like Cisco’s IOS image files) and booting from them, or by exploiting a vulnerability in the operating system and tro-janizing it in memory.

A release management process for network device image files allows you to know if a network device is running an autho-rized operating system or not. But an unauthorized operating system image is not necessarily a trojanized operating system image. Your success in identifying trojanized operating sys-tem images will depend on your network device vendor. For example, Cisco provides lists with cryptographic hashes of all images they release. If the cryptographic hash of the unau-thorized operating system image matches a hash in this list, you can be sure that it is a legitimate operating system image and that it is not trojanized. Some high-end network devices can operate with digitally signed operating system images. Periodic review of the digital signature of these operating sys-tem images will detect trojanized operating system images.

RAM trojans

But the hardest forensic case to crack is an operating system trojanized in memory. Many professional network devices operate like this: the operating system is stored in a file which is stored on non-volatile, solid-state memory, like flash mem-ory. When the network device is powered on, a very small

logging. Watch out; you will need to strike a balance between resource usage and log level, because increasing the number of log events has an impact on CPU usage and can thus nega-tively impact the performance of your network devices.

Utilize on board security features

Make sure to research security features available in your network devices that can help you indirectly with your fo-rensic investigations. Enable them if necessary. For example, Cisco switches have a DHCP snooping feature. Enabling this feature instructs the switch to build and maintain a table of all successful DHCP transactions it sees passing through its interfaces. This table lists IP addresses, corresponding MAC addresses, and the interfaces serving these clients.

Imagine a contractor connects his laptop to your wired net-work without authorization. You would notice this by moni-toring your DHCP logs for rogue machine names. But this will only give you a machine name and a MAC address. This is often not enough to trace back to the contractor. But with the DHCP snooping binding table, you will be able to corre-late the IP address and MAC address with a switch interface. This will allow you to find the physical location of the Eth-ernet connector used by the contractor. Reviewing physical security evidence like access control logs or CCTV images should be enough to identify the contractor. Or you could just ask your employees working near the network access point who used this connection.

In the case of the former employee using your corporate WiFi infrastructure, you would notice this too by monitoring your DHCP logs for rogue machine names. Additional logs from WiFi access points and wireless LAN controllers should en-able you to pinpoint the access point used by the former em-ployee. But since WiFi access points do not need a physical connection, you will find it harder to identify the culprit.

Forensic artifacts found in network devicesNetwork devices can become compromised because their configuration gets modified or because their operating sys-tem gets trojanized. Finding forensic evidence for these in-cidents can become much harder. A secure, centralized log repository is vital so that perpetrators cannot erase logs to cover their tracks.

To detect unauthorized configuration modifications, a re-lease management and version control process is necessary. The release management process will make sure that only approved modifications are applied to your network de-vices, and the version control process will make sure that these modifications are documented. Periodic review of your network device configurations will allow you to detect un-authorized configuration modifications by comparing them with the configurations kept in the version control system. This review process can be automated.

If your network devices support scripting and you have cus-tom scripts like Cisco IOS Tcl, make sure to include these in your release management and version control process.

Predictions for the New YearLive Event: January 22, 2013

To a degree, changes in legislation and technol-ogy are easy meat to predict in a 12-month time

frame. But what about environmental impacts such as cyberattacks and cyberwarfare trends? Will the

cold wind of social media exploits bring infosec into focus for the ignorant end user? What is likely to be the next big hurricane of “wikileaks-type” ex-posure to rock the industry? Where will the wind of change blow security in the “cloud?” Will the heat

be turned up further on compliance requirements? Will there be a drought of funds making everything

we want to do harder to achieve?

Join us, make notes, and then check back in a year to see how we did!

Upcoming

Click here for more information on our 2013 schedule.

December 2012 | ISSA Journal – 13

Network Device Forensics | Didier Stevens

©2012 ISSA • www.issa.org • [email protected] • All rights reserved.

Page 3: Network Device Forensics

Pay attention to the fact that al-though operating systems tro-janized in RAM are not persistent (i.e., that rebooting the network de-vices removes the trojan), network devices are not often rebooted and the trojan can easily be present for months if not years. And if a trojan runs in RAM with full system ac-cess, there is nothing to prevent it

from modifying the image in flash to achieve persistence.

ConclusionThere are several preventive steps that you can take to facili-tate a forensic investigation of network devices. You can im-prove the logging of your devices and enable extra informa-tion gathering features on your devices. This will help you gather more forensic evidence. Network devices can also be-come compromised. You can find forensic artifacts in flash and in RAM. There are tools to help you analyze these arti-facts.

I hope this article will inspire you to take measures that will facilitate forensic investigations of network devices.

References—Dale Liu, Cisco Router and Switch Forensics, ISBN 978-

1597494182.

—Felix Lindner, The Shellcoder’s Handbook, 2nd Edition Chapter 13: Cisco IOS Exploitation, ISBN 978-0470080238.

—Felix Lindner, “Developments in Cisco IOS Forensics” - Black Hat, http://www.blackhat.com/presentations/bh-usa-08/Lind-ner/BH_US_08_Lindner_Developments_in_IOS_Forensics.pdf.

—Felix Lindner, “Router Exploitation” - Black Hat, http://www.blackhat.com/presentations/bh-usa-09/LINDNER/BHUSA09-Lindner-RouterExploit-SLIDES.pdf.

—Sebastian ‘topo’ Muñiz, Killing the myth of Cisco IOS rootkits: DIK (Da Ios rootKit), http://www.coresecurity.com/files/at-tachments/Killing_the_myth_of_Cisco_IOS_rootkits.pdf.

—Andrew Vladimirov, Konstantin Gavrilenko, Andrei Mikhailovsky, Hacking Exposed Cisco Networks, ISBN 978-0072259179.

About the AuthorDidier Stevens (Microsoft MVP Consumer Security, CISSP, GSSP-C, MCSD .NET, MCSE/Security, MCITP Windows Server 2008, RHCT, CCNP Security, OSWP) is a member of the Belgian ISSA chapter and an IT Security Consultant currently work-ing at a large Belgian financial corporation. Didier started his own company in 2012 to provide IT security training services (http://DidierStevensLabs.com). You can find his open source security tools on his IT se-curity related blog at http://blog.DidierStevens.com. He may be contacted at [email protected].

program stored in ROM will load the operating system from flash into RAM, where it is executed by the CPU. With an op-erating system trojanized in memory, the image file in flash is intact, but the modifications are made in RAM, where the image file is loaded to be executed. One way to make these modifications in RAM is by targeting the network device with an exploit for a vulnerability.1 This exploit contains code to modify the operating system in RAM and trojanize it, for example by adding a backdoor functionality.

To investigate such compromise, you need to be able to access and analyze RAM. Cisco IOS has features to access RAM: their routers and switches have a command that allows you to write the content of RAM to a core dump file. This solves the “access” phase of your forensic investigation, but not the “analysis” phase. The structure of the file containing the core dump is not documented. Only Cisco knows the complete details and you will need their cooperation if you need a full analysis. The Cisco Technical Assistance Center (TAC) will sometimes ask clients to provide them with a core dump to help with the analysis of their support cases. But since the RAM core contains everything that was in RAM, it contains a lot of forensic evidence.

But you are not completely dependent on Cisco’s TAC for core dump analysis. There are two open source tools that can partially analyze core dumps. The first tool is Cisco Incident Response (CIR) from Recurity Labs GmbH,2 an open source tool that attempts to detect trojanized core dumps by detect-ing memory and process anomalies. CIR has been successful in detecting proof-of-concept trojanized IOS images present-ed at the Black Hat Security conference.3

The second tool is the Network Appliance Forensic Toolkit (NAFT)4 released by me. It is able to analyze the basic struc-ture of memory and processes, but it is not yet able to au-tomatically detect memory and process anomalies. NAFT is a set of Python programs, and it can run on many operat-ing systems. You instruct your IOS device to produce a core dump and transfer it to a tftp server, and then you can ana-lyze this dump with NAFT. For example, command naft-icd.py processes r870-core will dump all processes it finds in core dump r870-core (figure 1).

1 Felix Lindner, “Burning the bridge: Cisco IOS exploits,” http://www.phrack.com/issues.html?issue=60&id=.7.

2 http://cir.recurity.com/.

3 http://blog.recurity-labs.com/archives/2008/05/27/on_ios_rootkits/index.html.

4 http://blog.didierstevens.com/programs/network-appliance-forensic-toolkit/.

BLACK HAT | BRIEFINGS | MARCH 12-13, 2013

BLACK HAT | TRAININGS | MARCH 14-15, 2013

WWW.BLACKHAT.COM

Black Hat Europe 2013 - The premiere conference on information security - returns to Amsterdam on March 12-15, 2013. This year

we will feature two days of hands on training courses followed by two days of Briefings comprised of over 50 presentations covering

the most relevent topics in security today.

Figure 1 — Core dump

1 Cwe 80049B5C 0 3 0 5552/6000 0 Chunk Manager

2 Csp 80371B90 8 341 23 2640/3000 0 Load Meter

3 Mwe 8118AB24 4 1725 2 5300/6000 0 Spanning Tree

4 Lst 80046D90 14780 841 17574 5484/6000 0 Check heaps

5 Cwe 8004F930 0 1 0 5672/6000 0 Pool Manager

6 Mst 808278AC 0 2 0 5596/6000 0 Timers

14 – ISSA Journal | December 2012

Network Device Forensics | Didier Stevens

©2012 ISSA • www.issa.org • [email protected] • All rights reserved.

Page 4: Network Device Forensics

BLACK HAT | BRIEFINGS | MARCH 12-13, 2013

BLACK HAT | TRAININGS | MARCH 14-15, 2013

WWW.BLACKHAT.COM

Black Hat Europe 2013 - The premiere conference on information security - returns to Amsterdam on March 12-15, 2013. This year

we will feature two days of hands on training courses followed by two days of Briefings comprised of over 50 presentations covering

the most relevent topics in security today.