https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md KoiLoader-Malware-Analysis/Reports/KoiLoader-EN.md at main · Yavuzhanzgen/KoiLoader-Malware-Analysis By Yavuzhanzgen Archived: 2026-09-26 02:01:35 UTC Legal Disclaimer This repository is intended solely for malware analysis, reverse engineering research, and educational purposes. All malware samples were analyzed in an isolated laboratory environment. KoiLoader Technical Analysis Report Static Analysis • Dynamic Analysis • Reverse Engineering • YARA • MITRE ATT&CK Page 1 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md M A LWA R E K O I L O A D E R TYPE R E M O T E A C C E S S T R O J A N P L AT F O R M W I N D O W S L A N G U A G E C + + A N A LY S I S S T A T I C + D Y N A M I C YA R A R U L E M I T R E A T T & C K I O C E X T R A C T E D REPORT C O M P L E T E D L I C E N S E M I T chase_27_oct_25.zip Analysis Name chase_27_oct_25 MD5 3154CD0289AEE452E3C5E2DC1B0A6EEF SHA256 b0aa17c8f1c66aeb0af5dc6c9c9d2bb0d591c07a133347e2a5a8fafa48f80410 File Type ZIP Static Analysis Figure 2. ZIP File Size The analyzed ZIP file has a size of 930 Bytes . Figure 3. Shortcut File Contained in the ZIP File When examining the contents of the ZIP file, it can be seen that it contains a shortcut file named chase_27_oct_25 . chase_27_oct_25.lnk Analysis Name chase_27_oct_25 MD5 6726185b70b5adf05e8a1a1df82ebf30 SHA256 64dd55e1c2373deed25c2776f553c632e58c45e56a0e4639dfd54ee97eab9c19 File Type LNK Static Analysis Page 2 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 4. Shortcut File Target Path When the target section under the shortcut header of the chase_27_oct_25.lnk file is examined, it can be seen that the target field contains a command intended to access a remote URL via PowerShell and download its contents. Page 3 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 5. Applying the Strings Operation The strings operation was performed on the chase_27_oct_25.lnk file, and the resulting output was saved to the çıktı.txt file. Examination of this output shows that the shortcut file contains a PowerShell command, a remote connection address, and various strings related to the execution of the file. Figure 6. PowerShell Command Found in the Target Section The PowerShell command downloads payloads from two different remote URLs using curl.exe and wget . The downloaded data is copied into JavaScript files named 4vnwl2c60ma7fn.js and m1ytw2joj.js using esentutl.exe . It then establishes persistence by creating a scheduled task named m1ytw2joj with schtasks . The task is configured to run every 1 minute and executes the C:\ProgramData\4vnwl2c60ma7fn.js file through wscript.exe with the m1ytw2joj argument. Page 4 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 7. JScript-Based Loader Code Found in MeretricesS15.php The code contained in MeretricesS15.php is a JScript -based loader that runs under Windows Script Host. The code creates Scripting.FileSystemObject and WScript.Shell objects, determines whether the system is using a 32-bit or 64-bit architecture, and selects the appropriate powershell.exe path. It also attempts to copy itself to the %ProgramData% directory under a different name using the MachineGuid value and checks whether it has been executed previously by using a file named 7zNCZJSF6NEE under %TEMP% . When the execution conditions are met, the JScript starts PowerShell in hidden mode and remotely downloads the ferousmm.php and resizedif.ps1 resources, executing them directly in memory through IEX. Figure 8. Manipulating the AMSI State Using .NET Reflection It dynamically identifies the System.Management.Automation.AmsiUtils class within the .NET assembly used by PowerShell through reflection . It then scans the fields and targets the amsiInitFailed field using the *am*ed wildcard. Since the previously performed -match operation returns True, the value of the relevant static field is changed to True through the SetValue() call. This manipulates the AMSI initialization state within the current PowerShell process, with the aim of disabling AMSI checks. Page 5 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 9. Testing AMSI Blocking A comparative test was performed on two different PowerShell processes to verify the AMSI blocking mechanism. In the first PowerShell process, a normal payload was executed without any AMSI modification to observe the behavior of AMSI protection. In the second process, a static field associated with AMSI was modified to attempt to disable the AMSI check only within the current process, after which the payload was executed. This allowed the difference between the two processes to be compared and the effect of AMSI protection to be evaluated. Figure 10. Files Located on the Server When accessing the https[:]//theoremaoliveoil[.]com/wp-content/uploads/2019/04 address within the relevant code, the files used for the malicious operation are found. resizedif.ps1 Analysis Name resizedif MD5 5c38d12158bfeeb9b9002e41463306b3 SHA256 24a5f8a5d6e8068b3fd39e237fa58085b773df193fc5ef71529de0eb248c480e File Type PowerShell Static Analysis Figure 11. PowerShell File Size Page 6 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md The newly analyzed PowerShell code has a file size of 7.20 KB . Figure 12. PowerShell File Contents The pieletJF.exe file hosted on the remote server is downloaded using Invoke-WebRequest and stored directly in memory in the $contentbuf variable without being written to disk. The GDT function then uses .NET's runtime code- generation capabilities to create the necessary structure for processing the downloaded content in memory and calling system functions. This allows the file to be processed in memory without being written to disk and enables system calls to be performed in subsequent stages. Figure 13. GPA Function When examining the GPA function, it can be seen that the Microsoft.Win32.UnsafeNativeMethods class is used to dynamically resolve the addresses of native API functions located within Windows modules. The function first identifies the loaded System.dll assembly and obtains the GetModuleHandle and GetProcAddress methods through reflection . It then resolves the provided module name using GetModuleHandle and obtains the handle of the corresponding module. Figure 14. Shellcode At this stage, where the GPA and GDT functions are actively used, the shellcode contained in the $sc variable is copied into memory using VirtualAlloc and Marshal.Copy . While GPA dynamically resolves the addresses of the required Page 7 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Windows API functions, GDT creates the necessary structure for calling these functions. The downloaded PE file is also kept in memory within $contentbuf , and CreateThread is used to execute the shellcode. Figure 15. Shellcode Analysis The Func200 shellcode manually parses the PE Export Directory, calculates the names of exported APIs using a custom hash algorithm, and compares the resulting hash value with param_2 . When a match is found, it uses the AddressOfNames , AddressOfNameOrdinals , and AddressOfFunctions tables to resolve the memory address of the corresponding API and returns the address. This mechanism enables runtime API resolution based on API hashing without using GetProcAddress . Figure 16. RWX Memory Allocation FUN_00000000 uses VirtualAlloc to allocate an RWX memory region for the PE and reconstructs the PE image in memory using SizeOfHeaders and the section information. It then resolves API addresses through the Import Directory and populates the IAT, while applying Base Relocation entries to perform the necessary address adjustments. Finally, it uses the ImageBaseAddress and AddressOfEntryPoint information to execute the PE's entry point. pieletJF.exe Analysis Name pieletJF MD5 484a42c7fea99e95c66a0f3365a51595 SHA256 d3e4dfd4d8b165b33574d231be9b1d3c31d243cb145c79987a5f2f59554f4b77 Page 8 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md File Type PE32/EXE Static Analysis Figure 17. Malware File Information The analyzed malware is a 32-bit Portable Executable file. The file size is 272 KB . Figure 18. Compiler and Platform Information of the PE32 File operating systems. Figure 19. File Entropy The malware is in PE32 format and was compiled as a 32-bit (I386) GUI application for Windows Vista and later When examining the section structure of the PE32 file, relatively high entropy values are observed in the .text and .reloc sections, while lower values are observed in the other sections. Approximately 55% of the file appears to be unpacked. Page 9 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 20. Encrypted Payload Data Stored in the Resource When the RCDATA block contained within the malware is examined, it can be seen that it contains a payload encrypted with XOR . Figure 21. XOR Key Data Stored in the Resource The second resource data located under RCDATA contains the XOR key used to decrypt the encrypted data. Dynamic Analysis Figure 22. Main Block of the Malware When examining the WinMain block, it can be seen that the malware performs two different API behavior checks before transitioning to its main execution flow. In the first check, the LPtoDP API is called with invalid parameters, and the expected behavior is for the call to fail and GetLastError() to return 87 ( ERROR_INVALID_PARAMETER ). If the expected error behavior does not occur, the process is terminated using the ExitProcess API. In the second check, the BuildCommDCBAndTimeoutsA API is called with a meaningless serial port configuration string. If the API unexpectedly succeeds, the process is terminated using GetCurrentProcess and TerminateProcess . Rather than directly detecting a debugger, these checks can be considered API behavior-based anti-analysis checks designed to verify how the execution environment responds to API calls. Page 10 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 23. Malware Function Containing Junk Code When examining the sub_CE3680 function, it can be seen that numerous meaningless variables, strings consisting of random characters, and high numerical values are used. The operations performed within the function are delegated to numerous sub-functions, creating a complex structure that does not directly reveal its actual functionality. In particular, the use of numerous constants and conversion operations together with the random character strings processed through sub_CE3D00 indicates a junk code/obfuscation mechanism designed to make the code more difficult to analyze. Figure 24. Retrieving Resource Contents At the beginning of the sub_CE1710 function, the sub_CE1110 function is called with two different parameters to retrieve two separate data blocks. The first call uses the value 30656 , while the second uses 7810 , with the sizes of the retrieved data assigned to the Size and v9 variables, respectively. The function then checks whether the retrieved data addresses are NULL and whether the data sizes are non-zero. If all checks succeed, the retrieved data blocks are used for processing in the subsequent stage. This structure indicates that the malware dynamically extracts the content to be executed from its resources. Page 11 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 25. Decrypting Resource Data and Copying It into Memory It can be observed that instead of calling APIs from kernel32.dll directly by their names, the malware uses a hash-based API resolution mechanism. As a result of the analysis performed with Python, the values 90706215 , 162771221 , and 229283509 were determined to correspond to the FindResourceW , LoadResource , and SizeofResource APIs, respectively. In the continuation of the function, the handle of the current PE image is obtained using GetModuleHandleW(NULL) , and the Resource entry specified by the a1 parameter is searched using FindResourceW . If the Resource is found, its contents are loaded into memory using LoadResource , and the size of the contents is determined using SizeofResource . A new memory region of the Resource size is then allocated using malloc , and the Resource contents are copied into this region using memmove . Figure 26. Malware API Hashing and Dynamic API Resolution Mechanism The sub_CE1060 function analyzes the PE Export Table structure of the module address provided as a parameter. First, the Export Directory is obtained using fields from the PE header, providing access to the names, addresses, and ordinal information of exported functions. The exported API names are then passed to the sub_CE1000 function, where their hash values are calculated and compared with the hash provided as the second parameter. The sub_CE1000 function processes the characters of API names to generate a custom hash value. For each character, the current hash value is shifted left by 16 bits and combined with the character value. The upper nibble of the resulting value is then checked, and an XOR operation is applied in case of an overflow. This process continues until the terminating character of the API name is reached. When the hash values match, sub_CE1060 calculates the address of the corresponding API from the export table and returns it to the calling function. This allows the malware to resolve the required Windows APIs at runtime without directly using their names. As a result of the analysis, the hash values used were determined to correspond to the following APIs: Hash API 90706215 FindResourceW 162771221 LoadResource 229283509 SizeofResource This method is an API hashing / dynamic API resolution technique that prevents API names from being directly visible during static analysis, making it more difficult to identify the Windows APIs used by the malware. Page 12 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 27. Extracting Resource Data at 4-Byte Intervals When examining the operation performed on the data retrieved from the Resource within the sub_CE1710 function, it can be seen that the data size is divided by 4 using the Size >>= 2 expression, and the first byte of each 4-byte block is selected using the Block[i] = v3[4 * i] operation. For example, the values 63 , 75 , EF , and 06 are obtained from the 63 00 00 00 , 75 00 00 00 , EF 00 00 00 , and 06 00 00 00 blocks contained in payload.bin , respectively. During the analysis, these values obtained after removing the 00 bytes were transferred to an intermediate file named par2.bin . The resulting data is then passed to the sub_CE16C0 function and subjected to decryption using a 31-byte XOR key. Figure 28. XOR-Based Data Decryption When examining the sub_CE16C0 function, it can be seen that the data retrieved from the Resource is decrypted using a repeating-key XOR method. The function XORs each data byte with the corresponding byte of the key and, when the end of the key is reached, starts again from the beginning of the key using the % a4 operation. During the analysis, the value of a4 was determined to be 31, indicating that the XOR key used has a length of 31 bytes. Thus, the decryption process is performed according to the following logic: Decoded[i] = Encoded[i] XOR Key[i % 31] Therefore, the data is decrypted at the byte level by repeatedly applying the 31-byte XOR key. Figure 29. Memory Allocation Using VirtualAlloc Page 13 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md It can be observed that the malware prepares the data decrypted with XOR in the previous stage for execution by manually loading it into memory as a PE file. The function allocates a memory region using VirtualAlloc based on the SizeOfImage value from the PE header and copies the PE header and section contents into this region. The PE's import table is then analyzed, the required DLLs are loaded into memory using LoadLibraryA , and the required API addresses are resolved using GetProcAddress . The resolved addresses are written to the corresponding import tables, preparing the necessary import structure for the PE to execute in memory. Figure 30. Writing the Malicious Payload to the Allocated Memory Region The function then uses VirtualProtect to reconfigure the memory regions with access permissions matching the PE section characteristics. Some sections are also removed from memory using VirtualFree . In the final stage, any initialization functions defined within the PE are called, if present, and the function returns the entry address of the PE placed in memory. Figure 31. Dropping the Malicious Payload from Memory The malware was written to the system from the relevant memory address allocated within the malware. AbyssCore.exe Analysis Name AbyssCore MD5 274C77F7D4349223525BB8918F304024 Page 14 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md SHA256 8c2c3416255ebf0fec47395f32d582f6d283e8bffa1c73078dc0f3b194ce8ce0 File Type PE32/EXE Figure 32. Malware Information The malware was identified as being in 32-bit Portable Executable (PE) format, with a file size of approximately 41 KB. Figure 33. DLL Files Used by the Malware When examining the malware's import table, it can be seen that it uses various Windows DLLs, including WININET.dll , SHLWAPI.dll , urlmon.dll , ntdll.dll , WS2_32.dll , NETAPI32.dll , KERNEL32.dll , USER32.dll , ADVAPI32.dll , SHELL32.dll , ole32.dll , and OLEAUT32.dll . Figure 34. Malware PE Information Page 15 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md As a result of the analysis, it was observed that the malware is in PE32 format and compiled for a 32-bit Windows environment. It was determined that the file was compiled using Microsoft Visual C/C++, with Microsoft Visual C/C++ 19.36.34120 as the compiler and Visual Studio 2022 v17.6 as the development environment. It was also observed that the binary was developed in C++. Figure 35. Entropy Status The malware's entropy value was observed to be at 6.33411 . In addition, the analysis tool indicates that the file is 79% unpacked. Figure 36. Strings Found Within the Malware When examining the Strings content, various traces related to persistence and disabling security mechanisms on the system can be observed. In particular, strings referencing the Sr.js file located under C:\ProgramData\ and the use of Windows Script Host ( wscript.exe ) are noteworthy. Dynamic Analysis Figure 37. System Language Check During the initial stage of execution, the malware uses the GetUserDefaultLangID() API to determine the system's default user language. The obtained LANGID value is compared against languages used in the former Soviet Union region. The specific selection of these languages indicates that the malware implements regional control (geofencing) to prevent execution on systems located in former Soviet Union countries. If the system language matches one of the countries in this list, the malware terminates its subsequent execution. Page 16 of 40 LANGID 1049 1067 2092 1068 1059 1087 1064 1090 2115 1091 1058 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Language / Region Russian — Russia Armenian — Armenia Azerbaijani — Cyrillic / Azerbaijan Azerbaijani — Latin / Azerbaijan Belarusian — Belarus Kazakh — Kazakhstan Tajik — Tajikistan Turkmen — Turkmenistan Uzbek — Cyrillic / Uzbekistan Uzbek — Latin / Uzbekistan Ukrainian — Ukraine Figure 38. Virtual Machine Graphics Card Check The malware uses the EnumDisplayDevicesW API to obtain information about the display device of the system on which it is running and compares the obtained information against predefined graphics card information. If a match is detected with specific GPU information, the malware determines that the system is running in a virtualized environment and terminates itself. The graphics adapters checked by the malware are as follows: Parallels Display Adapter Hyper – V Figure 39. Virtual Machine Graphics Card Check The ExpandEnvironmentStringsW API is used to check whether the VirtualBox components VBoxService.exe and VBoxTray.exe are present in the System32 directory. Page 17 of 40 VMware SVGA 3D Red Hat https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 40. File Check Using the PathCombineW API During the ongoing process, the SHGetFolderPathW and PathCombineW APIs are used to determine user directories, and the presence of the following files on the system is checked: Recently.docx Opened.docx These.docx Are.docx Files.docx In addition, the Resource.txt and OpenVPN.txt files are read using the CreateFileW and ReadFile APIs, and their contents are checked to determine whether they match the BAIT string. If both files are found to contain the BAIT string, the malware identifies the environment in which it is running as an analysis environment and consequently exhibits behavior designed to evade analysis. Figure 41. File Check Using the PathCombineW API In the relevant function of the malware, PathCombineW is used to construct the path of a file named new songs.txt . The GetFileAttributesW API is then used to check whether the file exists, and if it does, the file is opened using the CreateFileW API. Next, the file size is obtained using GetFileSize , memory is allocated using HeapAlloc to store the file contents, and the contents are read using ReadFile . If the size of the read file is 55 bytes, its contents are compared at the byte level against the following hardcoded text: Jennifer Lopez & Pitbull - On The Floor Beyonce - Halo Figure 42. Jaxx Wallet Query The malware uses the ExpandEnvironmentStringsW API to construct the %AppData%\Jaxx\Local Storage\wallet.dat path. It then uses the GetFileAttributesW and GetFileAttributesExW APIs to determine whether the Jaxx wallet file is Page 18 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md present on the system and to check its file attributes. If the file is not found or the expected conditions are not met, the malware proceeds to the next environmental checks. Figure 43. Environment Check Based on Username and Computer Name The malware fingerprints the environment by comparing the username and computer name obtained through the GetUserNameW and GetComputerNameW APIs against a list of known values. Among the usernames and computer names being checked are values such as Joe Cage , STRAZNJICA.GRUBUTT , Paul Jones , PJones , Harry Johnson , WDAGUtilityAccount , and sal.rosenburg . In addition, it checks whether the username contains the d5.vc/g string, the combination of the Bruno username and DESKTOP-ET51AJO computer name, as well as known computer names such as WILLCARTER-PC , FORTI-PC , and SFTOR- PC . Figure 44. System Memory and Environment Checks The malware collects information about the execution environment by checking the total amount of physical RAM using the GlobalMemoryStatusEx API. When the Anna username and ANNA-PC computer name combination is detected, an additional RAM threshold is applied. The malware then uses the GetSystemMetrics API to check whether the screen resolution is 1280×720 . It also evaluates whether the amount of system RAM is below a specific threshold and whether the current user is Admin . If the user is Admin , the malware additionally checks whether the computer name is 8 characters long in an attempt to obtain further environmental fingerprints. Page 19 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 45. File-Based Environment Check Performed by the Malware The malware enumerates files in the user directory using the FindFirstFileW and FindNextFileW APIs to identify files with .doc , .docx , .xls , and .xlsx extensions that meet specific length criteria. It also tracks the number of files whose nFileSizeLow value is 15 bytes. The resulting v59 value, which stores the number of files matching the specified criteria, is then compared against 20 . Figure 46. `powershell.exe`-Based Environment Check Performed by the Malware The malware enumerates the files in the relevant directory using the FindNextFileW API and checks the total number of files. If the number of files is 20 or fewer, an additional environmental check is performed. At this stage, the GetModuleFileNameW API is used to obtain the full path of the malware's own executable file. The StrStrIW API is then used to check whether the powershell.exe string is present within the obtained path. Figure 47. Disk Scanning and GUID Generation Page 20 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Various pieces of information related to the system identity and execution environment are collected during the malware's initialization routine. The MachineGuid value is read from the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography registry key, while the Volume Serial Number of the C:\ drive is retrieved using GetVolumeInformationW to generate a deterministic GUID . The generated GUID is used as the mutex name through CreateMutexW , preventing multiple instances of the same malware from running simultaneously. If the mutex already exists, ERROR_ALREADY_EXISTS (183) is checked. Subsequently, WSAStartup is initialized for network communication, CryptAcquireContextA for cryptographic operations, and CoInitializeEx for the COM infrastructure. Finally, the %temp%\%paths% path is constructed and a temporary file is opened using CreateFileW . Figure 48. Preparing the Cryptographic Environment Using the CryptAcquireContextA API The CryptAcquireContextA API is used to provide the required cryptographic environment for performing encryption and decryption operations using the RSA and AES algorithms. Figure 49. Creation of `{guid}.js` Under ProgramData The malware creates a file with a {GUID}.js extension using the machine's GUID information and registers it with Windows Task Scheduler to execute the operations contained within the file through Windows Script Host. Figure 50. Firefox Default Browser in Running Tasks The Firefox Default Browser executed through Windows Script Host is displayed in taskschd.msc . Page 21 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 51. Remote Script Execution by the Malware Through the .NET Compiler and PowerShell The malware obtains the paths to the csc.exe compiler versions v4.0.30319 and v2.0.50727 within the .NET Framework using the ExpandEnvironmentStringsW API. It then uses the GetFileAttributesW API to determine whether these files are present on the system and selects the PowerShell script to be used accordingly. If the v2.0.50727 version of csc.exe is present, sd2.ps1 is selected; if only the v4.0.30319 version is available, sd4.ps1 is selected. During the subsequent process, a PowerShell command is constructed using wnsprintfW and executed through %ComSpec% via the ShellExecuteW API. The generated command downloads the specified PowerShell script from https[:]//theoremaoliveoil[.]com/wp-content/uploads/2019/04/ using IWR -UseBasicParsing and directly executes the downloaded content using IEX . Figure 52. C2 Server Configuration The malware communicates with http[:]//2[.]58[.]15[.]233/maneuverable[.]php using the InternetOpenW API and uses Mozilla/5.0 (Windows NT 6.2; WOW64; Trident/7.0; rv:11.0) like Gecko as its User-Agent. It then configures the connection options using the InternetSetOptionW API and sends an HTTP request through the HttpSendRequestW API containing the Content-Type: application/octet-stream and Content-Encoding: binary headers. Page 22 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 53. C2 IP Redirection During the analysis, it was observed that the actual C2 server to which the sample was configured was inactive. Therefore, in order to analyze the malware's C2 communication, the network traffic was redirected to a local server within the controlled analysis environment. The redirection was performed at the Windows network layer using WinDivert. Figure 54. Initial Data Sent to the Server The malware uses HTTP POST requests for C2 communication. After execution, the malware first sends a check-in request to the C2 server, transmitting basic information about the infected system. The body of the initial HTTP POST request contains the following information: GUID: A unique identifier associated with the victim system. Campaign / Build ID: A unique value identifying the malware campaign or the generated build. X25519 Public Key: A public key generated by the bot at runtime and used for encrypted communication. Page 23 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md The initial C2 request is identified by the 101 opcode value located at the beginning of the message body. Figure 55. Retrieving the System Name and Username The malware uses Windows API functions to collect basic identification information about the infected system. The machine name and user information on the system are obtained through the following API calls: GetComputerNameW API: Used to retrieve the computer name (hostname) of the running system. GetUserNameW API: Used to retrieve the name of the active user account. This information is used by the malware for system identification, victim profiling, or generating unique device information during C2 communication. Figure 56. Runtime Key Generation The analyzed code segment shows that a 22-byte (176-bit) key is generated for use in C2 communication. Figure 57. Decryption of Data Sent by the Server Following the initial registration request, the malware sends a second check-in request to the C2 server. This communication type is identified by the 111 opcode value located at the beginning of the POST data. This request contains the following information: GUID: The unique identifier generated for the infected system. 16 Byte Key Part: Additional key material used in the encryption process. Encrypted Data: The encrypted form of the information collected about the victim system. Page 24 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 58. Command Polling After successfully establishing a connection with the C2 server, the malware enters a continuously running command polling loop. At this stage, the malware periodically sends requests to the C2 server to check for new commands. In the analyzed sample, this communication type is identified by the 102 opcode value contained in the body of the HTTP POST request. Figure 59. Malware Command Components After execution, the malware communicates with the C2 server and waits for remotely issued commands. Responses received from the C2 server are processed through a specific parsing mechanism. The malware interprets the first field of the incoming C2 message as a numeric opcode value and redirects execution to the corresponding case block based on this value. A switch-case -based command dispatch mechanism is used within this structure. The command format sent by the C2 server is generally structured as follows: |||... Opcode Keyword Function Command execution. The malware executes the received command through cmd.exe /c . The 103 g resulting output is captured and sent back to the C2 server. PowerShell command execution. The received Base64-encoded command is executed using 104 h the powershell.exe -enc parameter. Page 25 of 40 Opcode 105 i 106 j 108 l 110 n 112 p https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Keyword Function Performs a system restart. It attempts to enable the SeShutdownPrivilege privilege for this purpose. Removes JavaScript-based file remnants created by the malware and then terminates the process. Performs socket-based communication or starts a helper thread. It establishes a network connection using parameters provided by the C2 server. Custom command handler. Performs an additional operation using parameters provided by the C2 server. Manages a module or object located in memory and performs the corresponding resource cleanup operation. Figure 60. Execution of the `g` and `h` Commands When the 103 and 104 commands are received, the malware converts the parameter received from the C2 server into a command-line format, preparing it to execute an external process on Windows. For the 103 command, the received parameter is combined with %ComSpec% ( cmd.exe ) and the /c parameter to form a command to be executed. For the 104 command, the received parameter is treated as a Base64-encoded PowerShell command and prepared for execution using PowerShell's -enc parameter. Therefore: 103 command: The malware executes the command provided by the C2 server through cmd.exe /c . 104 command: The malware executes the Base64-encoded PowerShell command provided by the C2 server through powershell.exe -enc . Figure 61. System Restart Operation Windows system. When the 105 command is received, the malware uses the InitiateSystemShutdownExW API to trigger a restart of the Page 26 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 62. `j` Command Executing the JavaScript File When the j command is received, the malware constructs the path of a JavaScript file in the r.js format under the %ProgramData% directory. It then calls the sub_406C80 function to perform the relevant operation and checks the created JavaScript file through the sub_4096E0 function. If the return value of sub_4096E0 is non-zero, the file is deleted using the DeleteFileW API, and the process is finally terminated by calling ExitProcess(0) . Figure 63. TCP Connection and Thread Creation Mechanism When the l command is received, the malware initiates a new TCP connection using the IP address and port information obtained from the C2 server. After establishing the connection, it begins receiving 2-byte data from the server. As data is received, it creates a new structure in memory and places the constant data from byte_E01B04 , the second parameter received with the command, and the corresponding port information into this structure. It then passes this structure as a parameter to the StartAddress function and creates a separate thread. This process is repeated for every 2- byte data block received until the C2 connection is terminated. Figure 64. Payload Loading and Execution Mechanism When the n command is received, the malware uses the parameters obtained from the C2 server to construct a new C2 request and XOR-decrypts the response returned by the server using a 16-byte key. After the response is decrypted, the data is passed to different subroutines depending on the command type. In particular, when the relevant operation is of type 3 , the malware analyzes the decrypted data as a PE file, locates the Start exported function within the PE, and directly calls this function. Page 27 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 65. Module Removal and Resource Cleanup When the p command is received, the malware uses the parameter provided by the C2 server to locate a previously loaded or memory-resident module/object through the sub_E06AE0 function. It then resolves and calls the Release function from the module's export table, followed by cleaning up the resources associated with the relevant module/object using sub_E06B40 . sd2.ps1 Analysis Name sd2 MD5 687bc60bfa33ed48ff91d332f4758214 SHA256 19e78005ed71ce1f10d4cc456e95d184d872faf2618045fc733f010464c00e8a File Type PowerShell Static Analysis Figure 66. Sd2.ps1 File Size Information Upon examining the Sd2 file, its file size was observed to be 466.91 KB . Page 28 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 67. New Payload and XOR Decryption Structure The PowerShell downloader reads the victim-specific MachineGuid value from the HKLM:\SOFTWARE\Microsoft\Cryptography registry key and sends it to the C2 server. The data obtained by parsing the server response is passed as parameters to the .exe file during payload execution. The payload is loaded into memory as a .NET Assembly without being written to disk and is executed through its entry point. Page 29 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 68. Obtaining the XOR Key Due to the C2 server being inactive, it was not possible to directly obtain the XOR key. Therefore, the first 22 bytes of a clean PE/EXE file with a length of 22 bytes were used as reference data and XORed with the first 22 bytes of the malware. The resulting XOR output was used to derive the XOR key used by the malware. Figure 69. Payload Decryption Using the obtained XOR key, a sequential (repeating-key) XOR operation was applied to the encrypted data. In this method, each byte of the data was XORed with the corresponding byte of the XOR key, and when the end of the key was reached, the operation continued from the first byte of the key until the entire data was processed. The first two bytes of the resulting data were then checked to determine whether they matched the MZ signature, confirming that the data belonged to a valid PE file. The successfully decrypted data was saved as DecodeEdildi.exe . apple40.exe Analysis Name apple40 MD5 687bc60bfa33ed48ff91d332f4758214 SHA256 19e78005ed71ce1f10d4cc456e95d184d872faf2618045fc733f010464c00e8a File Type PE32/.NET Static Analysis Page 30 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 70. Apple40 File Information Upon examining the file properties of the analyzed apple40.exe malware, it was observed that the file is in Portable Executable (PE32) .NET Assembly format and has a total size of 76.00 KB. The PE metadata also shows that the InternalName and OriginalFilename fields are both defined as apple40.exe . Figure 71. Apple40 File Information The analyzed malware was developed using the MSIL/C# language and runs on .NET Framework v4.0 (CLR v4.0.30319). The file was also observed to have been obfuscated using Obfuscar (1.0). Dynamic Analysis The analyzed .NET sample is the .NET version of the 32-bit KoiLoader malware. Page 31 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 72. Values Returned by the Server Upon examining a sandbox record of the malware's previous communication, the parameters used in the HTTP request sent to the C2 server were identified. Figure 73. Parameters Provided as an Example To bypass the arg.length < 2 check, the values returned by the C2 server were provided as the required arguments before executing the malware. This ensured that the minimum number of arguments expected by the application was met, allowing the relevant check to be passed. Figure 74. Mutex Creation The code creates a Mutex to ensure that only a single instance of the malware runs. If the Mutex already exists, it indicates that another instance of the program is running, and the function terminates by returning true . Page 32 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 75. System Language Check The malware checks the system's installed user interface language through CultureInfo.InstalledUICulture.TwoLetterISOLanguageName within the value returned by Class6.smethod_305() relevant language/region check has been satisfied. Language Code az am by kz kg md . The resulting two-letter ISO language code is searched for . If a match is found, the function returns true , indicating that the Language / Region Azerbaijan Armenia Belarus Kazakhstan Kyrgyzstan Moldova ru Russia tj Tajikistan tm Turkmenistan uz Uzbekistan ua Ukraine Figure 76. Checking the пароли.txt File In the relevant code block of the malware, the user's Desktop directory is obtained using Environment.GetFolderPath(Environment.SpecialFolder.Desktop) . The target file path is then constructed using Path.Combine() with the пароли.txt filename decrypted by the Class6.smethod_306() method. During the analysis, the full path was observed as C:\Users\<>\Desktop\пароли.txt . The File.Exists() API was then used to check whether the file was present on the system. During dynamic analysis, the File.Exists value was observed as false , indicating that the file was not present in the Desktop directory of the analysis environment. The code also shows that the user's Documents and AppData\Roaming directories are obtained through the folderPath2 and folderPath3 variables. Page 33 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 77. File Existence Check The 5 different filenames obtained from the methods between Class6.smethod_307() and Class6.smethod_311() are collected into an array. During dynamic analysis, these files were observed to be Recently.docx , Opened.docx , These.docx , Are.docx , and Files.docx , respectively. The full path of each file is then constructed using Path.Combine() based on the C:\Users\<>\Documents directory obtained through Environment.SpecialFolder.Personal , and the File.Exists() API is used to check whether the files are present. The number of existing files is tracked using the num variable, and when all 5 files are found ( num == array.Length ), the function returns true . This structure indicates that the malware checks whether specific files are present on the user's system and performs conditional behavior based on the result. Figure 78. File Existence Check The malware checks whether files named resources.txt , openvpn.txt , and new songs.txt exist in the specified directory. If the files are present, their contents are read and compared against a predefined hardcoded value. If the files contain the expected content, the check is considered successful and true is returned. Figure 79. Jaxx Wallet Check The malware checks whether the wallet.dat file associated with the Jaxx wallet exists on the system. If the file is present, its size is examined, and if the file size is exactly 55 bytes, the check is considered successful and true is returned. Page 34 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 80. RAM Amount Check The malware queries the system's physical memory (RAM) amount through WMI. The retrieved memory value is converted to MB and then checked. If the total amount of RAM is less than 3050 MB, the check is considered successful and true is returned. Figure 81. Environment Check Based on Office Files The malware scans the files in the specified directory and checks for files with the .doc , .docx , .xls , and .xlsx extensions. Matching the file extension alone is not sufficient. The portion of the filename excluding the extension must be 15 characters long, and the file size must be exactly 15 bytes. Files meeting these conditions are counted, and if the total count is greater than 20, the check is considered successful and true is returned. Figure 82. X25519 Scalar Clamping The method_1() function creates a copy of the 32-byte value provided as a parameter and performs the X25519 scalar clamping operation on this copy. As part of the clamping operation: byte[0] &= 0xF8 clears the lowest 3 bits of the first byte. byte[31] &= 0x7F clears the highest bit of the last byte. byte[31] |= 0x40 sets the 6th bit of the last byte to 1 . These bitwise operations are fully consistent with the X25519 decodeScalar25519() operation defined in RFC 7748. As a result, the fact that method_1() applies the X25519 scalar clamping rules to the provided 32-byte value constitutes strong technical evidence that the malware uses an X25519-based encryption/key agreement mechanism. Page 35 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 83. C2 Data Processing Overview The Class2.smethod_50() function prepares the data to be sent to the C2 server. First, the data stored in memoryStream_0 is compressed using GZip, and then it is processed using repeating-key XOR with the byte_1 key through the Class2.smethod_2() function. The core operation within smethod_2() is: array2[i] = byte_0[i] ^ byte_1[i % byte_1.Length] Although the function initially fills the output buffer with random data, these values are subsequently completely overwritten by the XOR result. The remaining loops do not perform any additional data transformation. The prepared HTTP POST body generally follows the format: [32-byte field] + [1-byte separator] + [XOR-encrypted data] The response received from the C2 server is also decrypted using the same XOR function and the byte_1 key. Since XOR is reversible, the same function can be used for both data encoding and decoding. Figure 84. Data Transmission and Decryption The data prepared using the key stored in byte_1 is first decrypted using XOR by the server and then decompressed using GZip, after which the resulting command is parsed. During the analysis, the decrypted command was observed in the following format: |GETCFG||AHDGSH Here, GUID represents the unique identifier assigned to the respective client. Page 36 of 40 https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Figure 85. String Deobfuscation and File Check List The file and directory names used within the code are not stored directly as strings. Instead, they are stored in Class6.byte_0 . Functions such as smethod_356() – smethod_359() decode this data in UTF-8 using the relevant offset and length values to obtain the actual string values. The decoded strings are cached in the Class6.string_0 array to prevent them from being decoded again during subsequent use. These strings are then combined with different directory paths within Class2.Struct3 objects to construct the targets used for file or directory checks. The Enum3.const_0 and Enum3.const_1 values determine the type of the corresponding check. Figure 86. String Data Decoding First, the string values within the sample need to be made readable. In the analyzed .NET sample, the strings are not stored directly in plaintext. Instead, they are encoded within the Class6.byte_0 array and decoded through the smethod_0(index, offset, length) function. During the decoding process, the following transformation is applied to each byte: decoded = bytearray() for i, b in enumerate(byte_0): decoded.append((b ^ i ^ 170) & 0xff) As a result of this operation, the string table stored in Class6.byte_0 becomes readable. The relevant strings are then extracted using the index , offset , and length values passed to the smethod_0() calls. The extracted strings provide information about file extensions, application directories, Registry keys, C2 communication constants, and targeted data types. Targeted Browsers Browser Keyword Google Cookies , Login Data , Web Data , History , Chrome Bookmarks Microsoft Microsoft\Edge , Cookies , Login Data , Web Edge Data , History , Bookmarks Brave BraveSoftware , Cookies , Login Data , Local Browser Storage , Extensions Page 37 of 40 Targeted Data Cookies, saved login credentials, web data, browsing history, and bookmarks Cookies, saved login credentials, web data, browsing history, and bookmarks Cookies, login credentials, local storage, and browser extension data https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Browser Keyword Targeted Data Mozilla cookies.sqlite , places.sqlite , Cookies, browsing history, form history, and Firefox formhistory.sqlite , key4.db key data Targeted Applications Application Keyword Targeted Data Telegram Telegram\ , tdata Telegram user and session data discord\Local Storage , Discord\key , discord\Local Discord Local Storage, key, and session data State Slack Slack\Cookies , Slack\key , Local State Cookies, key, and session data Skype Skype For Desktop\Cookies , Network\Cookies Cookies and session data Sticky StickyNotes.snt , StickyNotes\LocalState User notes and local application data Notes WinAuth WinAuth\winauth.xml Authentication data Steam ssfn* , config.vdf , loginusers.vdf , Steam\config\ Steam session and account data OpenVPN OpenVPN\config , *.ovpn , OpenVPN\creds.txt VPN configurations and credentials FTP server and connection FileZilla recentservers.xml , sitemanager.xml , FTP\FileZilla\ information HostName , PortNumber , UserName , Password , WinSCP winscp.txt SSH %USERPROFILE%\.ssh , SSH Ledger Live Ledger Live\app.json Trezor @trezor , Wallets\trezor.txt Specter Specter , Wallets\specter.txt Targeted Cryptocurrency Wallets Cryptocurrency Keyword Wallet Server connection information SSH configuration and keys Application and wallet configuration data Trezor wallet information Specter wallet information Targeted Data Ethereum Ethereum\keystore , Wallets\Ethereum Ethereum wallet data Electrum Electrum\wallets , Wallets\Electrum Bitcoin wallet data Electrum-LTC Electrum-LTC\wallets , Wallets\Electrum-LTC Litecoin wallet data Electron Cash wallet Electron Cash ElectronCash\wallets , Wallets\ElectronCash data Monero Monero\wallets , Wallets\Monero Monero wallet data Jaxx Jaxx\Local Storage , Wallets\Jaxx\Local Storage Jaxx wallet data Guarda Guarda\Local Storage , Wallets\Guarda\Local Storage Guarda wallet data MyMonero MyMonero , Wallets\MyMonero MyMonero wallet data WalletWasabi\Client\Wallets , Wasabi Wasabi wallet data Wallets\Wasabi\Client\Wallets Atomic atomic\Local Storage , Wallets\atomic\Local Storage Atomic wallet data Blockstream Green Blockstream\Green\wallets , Wallets\BlockstreamGreen Wallet data Sparrow Sparrow\wallets , Wallets\Sparrow Wallet data BitPay .bitpay\app\Local Storage , Wallets\BitPay\Local Storage BitPay wallet data Page 38 of 40 Cryptocurrency Wallet Exodus Bither Neon Daedalus Information Type MachineGuid CPU GPU RAM Screen Resolution Operating System https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Keyword Exodus\exodus.wallet , Exodus\exodus.conf.json Bither\address.db , Wallets\Bither\address.db Neon\storage\userWallet.json , Wallets\Neon\storage\userWallet.json Daedalus Mainnet\wallets , Wallets\Daedalus Targeted System and Configuration Information Keyword / API SOFTWARE\Microsoft\Cryptography , MachineGuid Win32_Processor , select Name from Win32_Processor Win32_VideoController , select Name from Win32_VideoController Win32_OperatingSystem , TotalVisibleMemorySize Resolution: {0}x{1} Windows NT\CurrentVersion , ProductName Targeted Data Wallet and configuration data Bither wallet data Neon wallet data Cardano wallet data Targeted Data Unique system identifier Processor model Graphics card model Total physical memory Screen resolution Windows version System System lang: Language Time Zone System TimeZone: Antivirus SecurityCenter2 , AntiVirusProduct Installed Uninstall , DisplayVersion Programs Running win32_process , ProcessId , CommandLine , Processes ParentProcessId System language System time zone Installed/detected antivirus product Installed software and versions Running processes and command lines MITRE ATT&CK Reconnaissance Execution Command and Scripting — Interpreter: PowerShell (T1059.001) Command and Scripting Interpreter: — Windows Command Shell (T1059.003) — Command and Scripting Interpreter: Persistence Scheduled Task/Job: Scheduled — Task (T1053.005) — — — — Page 39 of 40 Privilege Defense Evasion Escalation Obfuscated Files or Information (T1027) Dynamic API Resolution (T1027.007) Embedded Payloads (T1027.009) Credential Com Discovery Collection Access & C App Credentials System Data from Lay from Web Information Local Prot Browsers Discovery System Web (T1555.003) (T1082) (T1005) Prot (T1 File and Credentials Enc Directory from Files — Cha Discovery (T1552.001) (T1 (T1083) — Process — Non Discovery App (T1057) Lay Reconnaissance Execution JavaScript/JScript (T1059.007) — — — — — — https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Privilege Persistence Escalation — — Defense Evasion Access Encrypted/Encoded — File (T1027.013) Deobfuscate/Decode Files or Information — (T1140) — — — — — — — — Reflective Code — — — Loading (T1620) Virtualization/Sandbox — — Evasion: System — Checks (T1497.001) Impair Defenses: — — Disable or Modify — Tools (T1562.001) Indicator Removal: — — File Deletion — (T1070.004) Source: https://github.com/Yavuzhanzgen/KoiLoader-Malware-Analysis/blob/main/Reports/KoiLoader-EN.md Page 40 of 40 Credential Com Discovery Collection & C Prot (T1 Security Ingr Software — Tran Discovery (T11 (T1518.001) Software Discovery — — (T1518) Query Registry — — (T1012) System Owner/User — — Discovery (T1033) System Language — — Discovery (T1614.001) — — —