Report Type
Malware Analysis
- Table of Contents
Tell the World
- This was the final task to complete for the PMAT course I took from TCM Security Academy.
- A big thank you to the course creator,
Matt Kiely
(also known asHuskyHacks
), the CEO of TCM SecurityHeath Adams
, and everyone involved in creating this fantastic course. - Course Link: Practical Malware Analysis & Triage
- My name is
Sameer Fakhoury
, and this is my malware analysis report. - I hope you'll enjoy reading it !!
Executive Summary
- MD5 hash:
db349b97c37d22f5ea1d1841e3c89eb4
- SHA256 hash:
24d004a104d4d54034dbcffc2a4b19a11f39008a575aa614ea04703480b1022c
WannaCry.exe
is a type of crypto ransomware, a form of malicious software (malware) used by cybercriminals to extort money, typically in the form of bitcoin. This ransomware works by encrypting important files, rendering them unreadable. The main WannaCry.exe executable have packed multiple other executables, containing commands to change file permissions and ownership. It also attempts to connect to a specific URL when executed. If it successfully connects, it remains inactive; however, if it fails to reach the URL, it proceeds to encrypt your files. Additionally, if the URL connection fails, a second stage of the malware is activated, installing related files and binaries in a hidden folder.
High-Level Technical Summary
- This executable operates in two stages. In the first stage, upon execution, it attempts to connect to a specific URL. If the connection is successful, no further action is taken. However, if it fails to connect, a second stage is triggered, resulting in the installation of an executable and hidden folder, followed by the encryption of files and data.
Malware Composition
IOC | Description |
WannaCry.exe | main executable |
@WanaDecryptor@.exe | Bitcoin Screen Popup |
mssecsvc.exe | Trojan behaviors |
http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com | URL connect destination |
taskhsvc.exe | worm behaviors |
qqilzrsxsgp500 | hidden directory |
Basic Static Analysis
INetSim
is a software suite that simulates common internet services (like HTTP, FTP, DNS) to safely analyze the behavior of malware in a controlled environment.REMnux
is a Linux-based distribution specifically designed for reverse-engineering and analyzing malware, offering a collection of tools for tasks such as static and dynamic analysis, memory forensics, and network monitoring.- Note: we need to turn off
INetSim
before detonating.WannaCry
will not detonate ifINetSim
is running, I’ll explain why later
- changing the name to
Ransomware.wannacry.exe
andrun as administrator
we will get this screen, that observed symptoms of infection from initial detonation - we have
@WanaDecryptor@.exe
that appears on the Desktop, as the same executable that is responsible for theRED
message we have on the screen - The Desktop Background Picture
- we have files that got the
WNCRY
extension - and
cosmo.jpeg
have been corrupted we can’t open it - going back to the clean snapshot for encryption that was made by that ransomware executable and we will begin the analysis if that executable
- checking the hash values of that executable using
md5sum
andsha256sum
,then check for any related information from threat intelligence platforms asVirusTotal
- as we see the executable is a well known ransomware, and it is categorized as trojan and a worm
- A
Trojan
is a type of malware disguised as legitimate software, tricking users into installing it, which then allows unauthorized access or control over the infected system. - A
worm
is a self-replicating malware that spreads across networks without requiring user interaction, exploiting vulnerabilities to propagate and potentially cause widespread damage. - so we need to take that as an important note for later deeper analysis
- checking any suspicious strings using
floss.exe
that are allocated inside that executable, to make some hypotheses and have more general information about that executable floss.exe
: uses advanced static analysis techniques to automatically extract and de-obfuscate all strings from malware binaries.- inspect the results we have inside that
.txt
file - we have
!This program cannot be run in DOS mode.
that was found multiple times - meaning that this executable have other packed executables in it
- Multiple Windows API calls
- we can raise a
hypotheses
that theWindows API
that are under these!This program cannot be run in DOS mode.
are related to the packed executables inside the main executable that we have - we have an executable name
mssecsvc.exe
- The
mssecsvc.exe
file is usually associated with WannaCry malware, but it disguises itself as Microsoft Security Center (2.0) Service, also known aswscsvc
(Windows Security Center Service).[1]
- we have
encoded stings
- we have
PATH
token replacement using%s
and aURL
indicator http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
- we have
icacls
command executed and usedcmd.exe
icacls
is a command-line utility in Windows used to display or modify access control lists (ACLs) for files and directories. It can set file permissions, manage ownership, and configure inheritance.- The command
icacls . /grant Everyone:F /T /C /Q
performs the following actions: .
: Targets the current directory and all its contents./grant Everyone:F
: Grants full control (F
) permissions to theEveryone
group, meaning all users will have complete access to the directory and its contents./T
: Applies the permission changes to all files and subdirectories within the target directory recursively./C
: Continues the operation even if errors occur. This is useful for bypassing any access-denied errors./Q
: Suppresses success messages, making the command run quietly without displaying output for successful operations.- we need to inspect the import address table for the WannaCry executable using
PEstudio
PeStudio
is a Malware analysis tool. It is used for statically analyzing malware samples, checkingindicators
libraries
imports
and more- checking the
indicators
section - we have three executables packed inside that executable, related to the results we saw in
floss.exe
for theDOS
header - identifies the URL pattern same results we saw in
floss.exe
- we have file extensions as
Wiper
that where added to each file after they are encrypted - checking the
library
section - we can identify the used Libraries that are responsible for opening and using a socket with internet usage also
- checking the
imports
section - we have couple
Windows API
that are relatedcryptography
, same as the malware that is encrypting our files and data - we have couple
Windows API
related to internet use and socket opening, we can arias a hypotheses that this executable may connect back to aC2 server
orIP
creating a services
that may be forpersistence
technique
Basic Dynamic Analysis
- turning on
INetSim
and running theRansomware.wannacry.exe
as administrator then check theWireshark
results inside theREMnux
machine we have - after the
TCP handshake
we have a200 OK http
to this weird URLhttp[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
that we saw in thefloss.exe
results andPEstudio
- the
INetSim
respond back as200 OK
to theRansomware.wannacry.exe
but theRansomware.wannacry.exe
didn’t execute as intended for theURL callback
that it is attempting - if we kill the
INetSim
process and made anipconfig /flushdns
inFlareVm
and re-executeRansomware.wannacry.exe
, what will do her that theRansomware.wannacry.exe
will fail to connect back to thehttp[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
then will encrypt our files and data , so we need to haveINetSim
turn off to dentate theRansomware.wannacry.exe
- what we need to do is that we need to capture these files connection that was made by the
Ransomware.wannacry.exe
so we will usetcpview.exe
, and re run theRansomware.wannacry.exe
- using
tcpview.exe
, and re run theRansomware.wannacry.exe
Tcpview.exe
is a Windows utility that provides a detailed overview of all active TCP and UDP network connections on a system, allowing users to monitor and manage these connections in real-time.- we have a whole traffic that is going to multiple IP address, and these IP address aren’t reached by
- also it’s having the
worm behavior
as it’s trying to replicate it self to these IP address throw the network using the port455
forsmb
- another process that spawns is
taskhsvc.exe
- this process is in listening mode on port
9050
and it’s listing to all interfaces on port9050
- checking online blogs related to
taskhsvc.exe
:WCry
installs the Tor network anonymity software on the infected system in theTaskData
folder within the malware’s working directory. The local Tor server is renamed and executed as taskhsvc.exe. Tor establishes a SOCKS5 proxy server on the loopback interface (127.0.0.1
) that listens on TCP port 9050.WCry
connects to this proxy and attempts to contact the configured C2 hidden services[2]
- truing on
procmon
filtering onRansomware.wannacry.exe
Procmon
(Process Monitor) is a powerful Windows tool that provides real-time monitoring of file system, registry, and process/thread activity, helping users diagnose and troubleshoot system issues or analyze the behavior of applications.- running
Ransomware.wannacry.exe
- we have the new executable created called
taskhsvc.exe
- checking the
process tree
- we see that
taskhsvc.exe
is unpacked fromRansomware.wannacry.exe
and run with an argument/i
- checking any related information form
taskhsvc.exe
as checking thePPID
and making a filter on it - multiple
registry keys are accessed
and files where created - we need to check on file creation from
taskhsvc.exe
and making a filter on it - as we se we have a new directory that have been created
- going to the new created directory
Note:
you may see this directory name changes throw the report that’s because it’s a random name generated and it differ every time I re-run theRansomware.wannacry.exe
and go back to the clean snapshot- this is installed as a hidden directory, so
taskhsvc.exe
is a second stage of theRansomware.wannacry.exe
that is installing it self to ahidden directory
qqilzrsxsgp500
with bunch of files and other data resources
Advanced Static Analysis
Cutter
is a free and open-source reverse engineering platform powered byrizin
. It aims at being an advanced and customizable reverse engineering platform while keeping the user experience in mind.
- opening the
Ransomware.wannacry.exe
inCutter
and check the main function with aGraph mode view
- as we see the
esi
register is holding theURL
that we saw earlier ESI
andEDI
→ are used in string instructions as source and destination to save locations- after that we have an API call to
InternetOpenUrlA
that is responsible to parses the URL string, establishes a connection to the server, and prepares to download the data identified by the URL - the contents of
eax
is moved toedi
and thenpushed
to thestack
- the
esi
contents that is the URL is pushed to the stack in order to be used withInternetOpenUrlA
- checking
InternetOpenUrlA
function parameters[3]
- checking the
DE compiler
results - the results of the
InternetOpenUrlA
is loaded back to theeax
, and then loaded to theedi
register, and the returned results of theInternetOpenUrlA
is Boolean as0 or 1
- then the results are loaded to
eax
thenedi
, we have anif
function that checks the results based on theedi
value - checking the
test
instruction - the
test
instruction is making aBitwise AND
on it selfedi,edi
with a returned value toTrue
if they are the equal aszero
then the flag will beone
and jump to the specified location - Explaining test operation as an example:
test
will put a flag in the memory register ( different flags have different results value ) an check if ended result ofeax,eax
=zero
=True
→ idea if the results from the upper API where succeededeax
will equal tozero
and makingBitwise AND
on it selfeax,eax
with a returned value toTrue
- if it reaches to that URL then the executable will clean itself and exit it’s main execution
- but if not it will jump to this function
fcn.00408090
that is responsible of that encryption that we saw
HINTERNET InternetOpenUrlA(
[in] HINTERNET hInternet,
[in] LPCSTR lpszUrl,
[in] LPCSTR lpszHeaders,
[in] DWORD dwHeadersLength,
[in] DWORD dwFlags,
[in] DWORD_PTR dwContext
);
Advanced Dynamic Analysis
x32dbg.exe
is a legitimate executable of a debugging software which, when executed, imports x32bridge
- going to to
x32dbg
to make the program execute even if it get results from thatURL
- we need to run
INetSim
onREMnux
and executeRansomware.wannacry.exe
- then load the
Ransomware.wannacry.exe
inx32dbg
- make a breakpoint on
http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
- going back and hit
F9
to arrive to the breaking point we made - going to the
test
instruction and check the results ofedi
as theINetSim
is running then it will have some values - so here the value of the
ZF
flag is set to zero as the results of theedi
where false having reach out to theURL
, and theJNE
meaning that jump if theZF
flag was zero that means we will continue without going to the intended encryption function - changing the
ZF
flag toone
that means even if theINetSim
was running then we will go to themain encryption function
- executing F8 till we hit the
main encryption function
we will have the ransomware encrypting files and data and running even if theINetSim
was running
Indicators of Compromise
Indicators of Compromise (IOCs)
are signs that a system has been breached, such as unusual network traffic, file hashes, IP addresses, or domain names associated with known malicious activity. They help detect and respond to potential security incidents.
Network Indicators
- connection to
http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
- Whole traffic that is going to multiple IP address, and these IP address aren’t reached by
taskhsvc.exe
process is in listening mode on port9050
and it’s listing to all interfaces on port9050
Host-based Indicators
- When executing the executable we have
@WanaDecryptor@.exe
that appears on the Desktop, as the same executable that is responsible for theRED
message we have on the screen, with files that haveWNCRY
extension - New executable created called
taskhsvc.exe
- Multiple
registry keys are accessed
and files where created - New hidden directory that have been created from
taskhsvc.exe
containing files and binaries
Rules & Signatures
YARA
rules are malware detection patterns that are fully customizable to identify targeted attacks and security threats specific to your environment.
- reuse the
floss.exe
to extract strings that will be used inside the YARA rule
rule wannacry {
meta:
report_info = "last task in PMAT course"
author = "Sameer Fakhoury"
last_update = "2024-08-24"
strings:
$s1 = "CryptAcquireContextA"
$s2 = "CryptGenRandom"
$s3 = "StartServiceA"
$s4 = "CloseServiceHandle"
$s5 = "CreateServiceA"
$s6 = "OpenSCManagerA"
$s7 = "SetServiceStatus"
$s8 = "ChangeServiceConfig2A"
$s9 = "RegisterServiceCtrlHandlerA"
$s10 = "StartServiceCtrlDispatcherA"
$s11 = "OpenServiceA"
$s12 = "ADVAPI32.dll"
$s13 = "WS2_32.dll"
$s14 = "??1_Lockit@std@@QAE@XZ"
$s15 = "??0_Lockit@std@@QAE@XZ"
$dos_mode_string = "!This program cannot be run in DOS mode."
$mssecsvc = "mssecsvc.exe"
$tasksche = "tasksche.exe"
$url = "http://www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com"
condition:
$url or (
(7 of ($s*))
and $dos_mode_string
and $mssecsvc
and $tasksche
)
}
- execute the YARA rule on the ransomware executable