Report Type
Malware Analysis
- Table of Contents
- Tell the World
- Executive Summary
- High-Level Technical Summary
- Malware Composition
- Basic Static Analysis
- Basic Dynamic Analysis
- Advanced Static Analysis
- Advanced Dynamic Analysis
- Indicators of Compromise
- Network Indicators
- Host-based Indicators
- Rules & Signatures
- Appendices
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.exeis 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
INetSimis a software suite that simulates common internet services (like HTTP, FTP, DNS) to safely analyze the behavior of malware in a controlled environment.REMnuxis 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
INetSimbefore detonating.WannaCrywill not detonate ifINetSimis running, I’ll explain why later
- changing the name to
Ransomware.wannacry.exeandrun as administratorwe will get this screen, that observed symptoms of infection from initial detonation - we have
@WanaDecryptor@.exethat appears on the Desktop, as the same executable that is responsible for theREDmessage we have on the screen - The Desktop Background Picture
- we have files that got the
WNCRYextension - and
cosmo.jpeghave 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
md5sumandsha256sum,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
Trojanis 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
wormis 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.exethat 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
.txtfile - 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
hypothesesthat theWindows APIthat 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.exefile 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
PATHtoken replacement using%sand aURLindicator http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com- we have
icaclscommand executed and usedcmd.exe icaclsis 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 /Qperforms the following actions: .: Targets the current directory and all its contents./grant Everyone:F: Grants full control (F) permissions to theEveryonegroup, 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 PeStudiois a Malware analysis tool. It is used for statically analyzing malware samples, checkingindicatorslibrariesimportsand more- checking the
indicatorssection - we have three executables packed inside that executable, related to the results we saw in
floss.exefor theDOSheader - identifies the URL pattern same results we saw in
floss.exe - we have file extensions as
Wiperthat where added to each file after they are encrypted - checking the
librarysection - we can identify the used Libraries that are responsible for opening and using a socket with internet usage also
- checking the
importssection - we have couple
Windows APIthat are relatedcryptography, same as the malware that is encrypting our files and data - we have couple
Windows APIrelated to internet use and socket opening, we can arias a hypotheses that this executable may connect back to aC2 serverorIP creating a servicesthat may be forpersistencetechnique
Basic Dynamic Analysis
- turning on
INetSimand running theRansomware.wannacry.exeas administrator then check theWiresharkresults inside theREMnuxmachine we have - after the
TCP handshakewe have a200 OK httpto this weird URLhttp[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.comthat we saw in thefloss.exeresults andPEstudio - the
INetSimrespond back as200 OKto theRansomware.wannacry.exebut theRansomware.wannacry.exedidn’t execute as intended for theURL callbackthat it is attempting - if we kill the
INetSimprocess and made anipconfig /flushdnsinFlareVmand re-executeRansomware.wannacry.exe, what will do her that theRansomware.wannacry.exewill fail to connect back to thehttp[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.comthen will encrypt our files and data , so we need to haveINetSimturn 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.exeso we will usetcpview.exe, and re run theRansomware.wannacry.exe - using
tcpview.exe, and re run theRansomware.wannacry.exe Tcpview.exeis 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 behavioras it’s trying to replicate it self to these IP address throw the network using the port455forsmb - another process that spawns is
taskhsvc.exe - this process is in listening mode on port
9050and it’s listing to all interfaces on port9050 - checking online blogs related to
taskhsvc.exe:WCryinstalls the Tor network anonymity software on the infected system in theTaskDatafolder 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.WCryconnects to this proxy and attempts to contact the configured C2 hidden services[2] - truing on
procmonfiltering 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.exeis unpacked fromRansomware.wannacry.exeand run with an argument/i - checking any related information form
taskhsvc.exeas checking thePPIDand making a filter on it - multiple
registry keys are accessedand files where created - we need to check on file creation from
taskhsvc.exeand 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.exeand go back to the clean snapshot- this is installed as a hidden directory, so
taskhsvc.exeis a second stage of theRansomware.wannacry.exethat is installing it self to ahidden directoryqqilzrsxsgp500with bunch of files and other data resources
Advanced Static Analysis
Cutteris 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.exeinCutterand check the main function with aGraph mode view - as we see the
esiregister is holding theURLthat we saw earlier ESIandEDI→ are used in string instructions as source and destination to save locations- after that we have an API call to
InternetOpenUrlAthat 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
eaxis moved toediand thenpushedto thestack - the
esicontents that is the URL is pushed to the stack in order to be used withInternetOpenUrlA - checking
InternetOpenUrlAfunction parameters[3] - checking the
DE compilerresults - the results of the
InternetOpenUrlAis loaded back to theeax, and then loaded to theediregister, and the returned results of theInternetOpenUrlAis Boolean as0 or 1 - then the results are loaded to
eaxthenedi, we have aniffunction that checks the results based on theedivalue - checking the
testinstruction - the
testinstruction is making aBitwise ANDon it selfedi,ediwith a returned value toTrueif they are the equal aszerothen the flag will beoneand jump to the specified location - Explaining test operation as an example:
testwill 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 succeededeaxwill equal tozeroand makingBitwise ANDon it selfeax,eaxwith 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.00408090that 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.exeis a legitimate executable of a debugging software which, when executed, imports x32bridge
- going to to
x32dbgto make the program execute even if it get results from thatURL - we need to run
INetSimonREMnuxand executeRansomware.wannacry.exe - then load the
Ransomware.wannacry.exeinx32dbg - make a breakpoint on
http[:]//www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com - going back and hit
F9to arrive to the breaking point we made - going to the
testinstruction and check the results ofedias theINetSimis running then it will have some values - so here the value of the
ZFflag is set to zero as the results of theediwhere false having reach out to theURL, and theJNEmeaning that jump if theZFflag was zero that means we will continue without going to the intended encryption function - changing the
ZFflag toonethat means even if theINetSimwas running then we will go to themain encryption function - executing F8 till we hit the
main encryption functionwe will have the ransomware encrypting files and data and running even if theINetSimwas 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.exeprocess is in listening mode on port9050and it’s listing to all interfaces on port9050
Host-based Indicators
- When executing the executable we have
@WanaDecryptor@.exethat appears on the Desktop, as the same executable that is responsible for theREDmessage we have on the screen, with files that haveWNCRYextension - New executable created called
taskhsvc.exe - Multiple
registry keys are accessedand files where created - New hidden directory that have been created from
taskhsvc.execontaining files and binaries
Rules & Signatures
YARArules are malware detection patterns that are fully customizable to identify targeted attacks and security threats specific to your environment.
- reuse the
floss.exeto 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
Appendices
[1]: https://windowsreport.com/mssecsvc-exe/#:~:text=The mssecsvc.exe file is,PC as soon as possible[2]:
Secureworks WCry (WannaCry) Ransomware Analysis[3]:QuinnRadich InternetOpenUrlA function (wininet.h) - Win32 apps