0% found this document useful (0 votes)
80 views6 pages

Analyze and Extract Malware from PCAP

The document describes extracting an executable file from a packet capture file. It involves using Wireshark to open the PCAP file, analyze packets, and follow the TCP stream to reconstruct an HTTP request and response containing a downloaded file. Using Wireshark's export feature, the executable file can be retrieved and analyzed locally.

Uploaded by

elijahjoshtecson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views6 pages

Analyze and Extract Malware from PCAP

The document describes extracting an executable file from a packet capture file. It involves using Wireshark to open the PCAP file, analyze packets, and follow the TCP stream to reconstruct an HTTP request and response containing a downloaded file. Using Wireshark's export feature, the executable file can be retrieved and analyzed locally.

Uploaded by

elijahjoshtecson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab - Extract an Executable from a PCAP

Objectives
Part 1: Analyze Pre-Captured Logs and Traffic Captures
Part 2: Extract Downloaded Files from PCAP

Background / Scenario
Looking at logs is very important, but it is also important to understand how network transactions happen at
the packet level.
In this lab, you will analyze the traffic in a previously captured pcap file and extract an executable from the file.

Required Resources
 CyberOps Workstation virtual machine

Instructions

Part 1: Analyze Pre-Captured Logs and Traffic Captures


In Part 2, you will work with the [Link] file. Captured in a previous lab,
[Link] contains the packets related to the download of the Nimda malware. Your version of
the file, if you created it in the previous lab and did not reimport your CyberOps Workstation VM, is stored in
the /home/analyst directory. However, a copy of that file is also stored in the CyberOps Workstation VM,
under the /home/analyst/[Link]/pcaps directory so that you can complete this lab. For
consistency of output, the lab will use the stored version in the pcaps directory.
While tcpdump can be used to analyze captured files, Wireshark’s graphical interface makes the task much
easier. It is also important to note that tcpdump and Wireshark share the same file format for packet
captures; therefore, PCAP files created by one tool can be opened by the other.
a. Change directory to the [Link]/pcaps folder, and get a listing of files using the ls –l command.
[analyst@secOps ~]$ cd [Link]/pcaps
[analyst@secOps pcaps]$ ls -l
total 7460
-rw-r--r-- 1 analyst analyst 3510551 Aug 7 15:25 lab_prep.pcap
-rw-r--r-- 1 analyst analyst 371462 Jun 22 10:47 [Link]
-rw-r--r-- 1 analyst analyst 3750153 May 25 11:10 wannacry_download_pcap.pcap
[analyst@secOps pcaps]$
b. Issue the command below to open the [Link] file in Wireshark.
[analyst@secOps pcaps]$ wireshark [Link] &

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 6 [Link]
Lab - Extract an Executable from a PCAP

c. The [Link] file contains the packet capture related to the malware download performed
in a previous lab. The pcap contains all the packets sent and received while tcpdump was running.
Select the fourth packet in the capture and expand the Hypertext Transfer Protocol to display as shown
below.

d. Packets one through three are the TCP handshake. The fourth packet shows the request for the malware
file. Confirming what was already known, the request was done over HTTP, sent as a GET request.

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 6 [Link]
Lab - Extract an Executable from a PCAP

e. Because HTTP runs over TCP, it is possible to use Wireshark’s Follow TCP Stream feature to rebuild
the TCP transaction. Select the first TCP packet in the capture, a SYN packet. Right-click it and choose
Follow > TCP Stream.

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 6 [Link]
Lab - Extract an Executable from a PCAP

f. Wireshark displays another window containing the details for the entire selected TCP flow.

Questions:

What are all those symbols shown in the Follow TCP Stream window? Are they connection noise? Data?
Explain.
 The contents of the downloaded file are represented by symbols. Wireshark is unable to
represent the binary file because of this. When decoding binary data as text, Wireshark does its
best to make sense of it; the symbols it displays are its best estimate.

There are a few readable words spread among the symbols. Why are they there?
 The executable code contains those strings. These terms typically appear in messages that the
user receives from the application while it is operating. Even though it's more of an art than a
science, a trained analyst can read through these pieces and find important information.

Challenge Question: Despite the [Link] name, this executable is not the famous worm.
For security reasons, this is another executable file that was renamed as [Link]. Using
the word fragments displayed by Wireshark’s Follow TCP Stream window, can you tell what executable
this really is?
 That window can be fully scrolled down to discover that this is the Microsoft Windows [Link]
file.

g. Click Close in the Follow TCP Stream window to return to the Wireshark [Link] file.

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 6 [Link]
Lab - Extract an Executable from a PCAP

Part 2: Extract Downloaded Files from PCAP


Because capture files contain all packets related to traffic, a PCAP of a download can be used to retrieve a
previously downloaded file. Follow the steps below to use Wireshark to retrieve the Nimda malware.
a. In that fourth packet in the [Link] file, notice that the HTTP GET request was generated
from [Link] to [Link]. The Info column also shows this is in fact the GET request for
the file.
b. With the GET request packet selected, navigate to File > Export Objects > HTTP, from Wireshark’s
menu.

c. Wireshark will display all HTTP objects present in the TCP flow that contains the GET request. In this
case, only the [Link] file is present in the capture. It will take a few seconds before the
file is displayed.

Question:

Why is [Link] the only file in the capture?


 Because the capture was initiated just before the download and ended immediately thereafter.
During the duration of the capture, no more traffic was detected.

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 6 [Link]
Lab - Extract an Executable from a PCAP

d. In the HTTP object list window, select the [Link] file and click Save As at the bottom of
the screen.
e. Click the left arrow until you see the Home button. Click Home and then click the analyst folder (not the
analyst tab). Save the file there.
f. Return to your terminal window and ensure the file was saved. Change directory to the /home/analyst
folder and list the files in the folder using the ls -l command.
[analyst@secOps pcaps]$ cd /home/analyst
[analyst@secOps ~]$ ls –l
total 364
drwxr-xr-x 2 analyst analyst 4096 Sep 26 2014 Desktop
drwx------ 3 analyst analyst 4096 May 25 11:16 Downloads
drwxr-xr-x 2 analyst analyst 4096 May 22 08:39 extra
drwxr-xr-x 8 analyst analyst 4096 Jun 22 11:38 [Link]
drwxr-xr-x 2 analyst analyst 4096 Mar 3 15:56 second_drive
-rw-r--r-- 1 analyst analyst 345088 Jun 22 15:12 [Link]
[analyst@secOps ~]$
Question:

Was the file saved?


 Yes

g. The file command gives information on the file type. Use the file command to learn a little more about the
malware, as show below:
[analyst@secOps ~]$ file [Link]
[Link]: PE32+ executable (console) x86-64, for MS Windows
[analyst@secOps ~]$

As seen above, [Link] is indeed a Windows executable file.


Question:

In the malware analysis process, what would be a probable next step for a security analyst?
 Determining the kind of virus and examining its behavior are the objectives. To observe the
malware's activity, it needs be executed in a controlled environment after being transported there.
Virtual machines are frequently used in malware investigation environments, which are
sandboxed to prevent harm to non-test systems. These environments typically come with tools
that make it easier to monitor the malware's execution; frequent monitored features include
resource utilization, network connections, and operating system modifications.

A few online tools for analyzing malware are also available. One such is VirusTotal
([Link]). Malware is uploaded by analysts to VirusTotal, which then runs the malicious
code. Following execution and several further checks, VirusTotal provides the analyst with a
report.

 2017 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 6 [Link]

You might also like