The company said each criminal gang that used WastedLocker appeared to be rebuilding the source to suit its own ends and thus a targeted build was used against Garmin.
In a detailed technical analysis of the relatively new malware, Kaspersky researcher Fedor Sinitsyn said WastedLocker had a command line interface that allowed it to accept different arguments that controlled the way it operated.
One was a "p" switch that indicated priority and was used to direct the malware to encrypt a specified directory first and then add its name to an exclusion list to prevent it being processed a second time.
The malware also had an "f" switch that could be used to specify encryption of a single directory.
A third argument, specified by the use of "u" told the package to encrypt files on a specified network using the authentication afforded by the credentials provided.
A screenshot of the ransom note generated by WastedLocker. Courtesy Kaspersky
The use of the "r" switch would launch the following sequence of actions:
- Delete ;
- Copy to %WINDIR%\system32\<rand>.exe using a random substring from the list of subkeys of the registry key SYSTEM\CurrentControlSet\Control\;
- Create a service with a name chosen similarly to the method described above. If a service with this name already exists, append the prefix “Ms” (e.g. if the service “Power” already exists, the malware will create a new one with the name “MsPower”). The command line for the new service will be set to “%WINDIR%\system32\<rand>.exe -s”;
- Start this service and wait until it finishes working;
- Delete the service.
- FInally, the "s" switch would start a created service which would result in all files that were locatable being encrypted.
Sinitsyn said one more interesting feature of WastedLocker was the manner in which it bypassed the user account control feature in Windows; this allows someone who has ordinary user privileges to run code that requires admin privileges by clicking agree on a pop-up that the system generates when such an operation was attempted.
The malware noted the privileges it had when it was started and silently tried to elevate its privileges using a known bypass technique:
- Create a new directory in %appdata%; the directory name is chosen at random from the substrings found in the list of subkeys of the registry key SYSTEM\CurrentControlSet\Control\;
- Copy a random EXE or DLL file from the system directory to this new directory;
- Write the trojan’s own body into the alternate NTFS stream “:bin” of this system file;
- Create a new temporary directory and set its mount point to “C:\Windows ” (with a trailing whitespace) using the API function NtFsControlFile with the flag IO_REPARSE_TAG_MOUNT_POINT;
- Create a new subdirectory named “system32” inside the temporary directory. As a result of the previous step, this new subdirectory can be equally successfully addressed as “%temp%\<directory_name>\system32” or “C:\Windows \system32” (note the whitespace);
- Copy the legitimate winsat.exe and winmm.dll into this subdirectory;
- Patch winmm.dll: replace the entry point code with a short fragment of malicious code whose only purpose is to launch the content of the alternate NTFS stream created on step 2; and
- Launch winsat.exe, which will trigger the loading of the patched winmm.dll as a result of DLL hijacking.
Sinitsyn also found that the encryption scheme used by the malware was a combination of the AES and RSA algorithms. "The search mask to choose which files will be encrypted, as well as the list of the ignored paths are set in the configuration of the malware," he noted.
He said tor each processed file, WastedLocker generated a unique 256-bit key and a 128-bit IV which would be used to encrypt the file content using the AES-256 algorithm in CBC mode.
"The implementation of file operations is worthy of note, as it employs file mapping for data access. It must have been an attempt by the criminals to maximise the trojan’s performance and/or avoid detection by security solutions," he theorised. "Each encrypted file will get a new additional extension: .garminwasted."
Sinitsyn discovered that the trojan implemented a way of integrity control as part of its file encryption routine, calculating an MD5 hash of the original content of each processed file, and using this hash to ensure the correctness of the procedure.
Additionally, WastedLocker used a publicly available reference implementation of an RSA algorithm named “rsaref”.