Library
My library

+ Add to library

Profile

Android.Loki.3

Added to the Dr.Web virus database: 2016-02-02

Virus description added:

SHA1:

  • 4af24c9f6815c8b0f5d0b44cc9040cdd7d828d96

It is a Trojan for Android whose examined sample looks as follows:

/data/system/.loki/loki32

The Trojan’s main purpose is to incorporate the liblokih.so library into the system_server process and execute commands using root privileges.

Along with the system, the loki32 process is launched and waits until the system is completely booted up. After that, the malicious application scans the /proc directory, which contains information about processes, state and configuration of the system and the kernel, and searches for a process whose value is set to "system_server" in the /proc/<pid>/cmdline file.

The Trojan then receives relative function addresses necessary for the injection:

libcAddr = getAddressFromMaps(v1, "/system/lib/libc.so");
linkerAddr = getAddressFromMaps(v0, "/system/bin/linker");
mallocAddr = (int)&malloc - libcAddr;
dlopenAddr = (int)&dlopen - linkerAddr;
dlcloseAddr = (int)&dlclose - linkerAddr;
dlsymAddr = (int)&dlsym - linkerAddr;
dlerrorAddr = (int)&dlerror – linkerAddr.

The getAddressFromMaps function parses the /proc/self/maps file, which contains a process memory map, and finds the first line that corresponds to the required library. It may look as follows:

40020000-40065000 r-xp 00000000 1f:00 363        /system/lib/libc.so

It extracts the first number from this line, and the injection procedure is then executed:

inject(ss_pid, "/data/system/.loki/liblokih.so", "load_loki", "");

This function receives the PID value of a process into which the injection will be performed, a path to a library that needs to be downloaded, and a name of a function in this library that needs to be executed. The injection procedure is carried out using the ptrace system call that is mainly implemented by debuggers. Once the process is “killed” with the help of the PTRACE_ATTACH function, the Trojan connects to it and can read and modify the state of its memory and registers. The PTRACE_GETREGS function helps the Trojan receive the registers values. Then, using PTRACE_SETREGS, the malicious program modifies them to perform the necessary function. After that, the process is started once again using PTRACE_CONT.

Moreover, if Android.Loki.3 gets root privileges, it can execute commands received from Android.Loki.1.origin and Android.Loki.2.origin. Thus, Android.Loki.3 is, in fact, a server that launches shell scripts—the Trojan receives a path to a script, which needs to be executed, via a local socket, and Android.Loki.3 launches this script.

News about the Trojan

Curing recommendations


Android

  1. If the mobile device is operating normally, download and install Dr.Web for Android Light. Run a full system scan and follow recommendations to neutralize the detected threats.
  2. If the mobile device has been locked by Android.Locker ransomware (the message on the screen tells you that you have broken some law or demands a set ransom amount; or you will see some other announcement that prevents you from using the handheld normally), do the following:
    • Load your smartphone or tablet in the safe mode (depending on the operating system version and specifications of the particular mobile device involved, this procedure can be performed in various ways; seek clarification from the user guide that was shipped with the device, or contact its manufacturer);
    • Once you have activated safe mode, install the Dr.Web для Android Light onto the infected handheld and run a full scan of the system; follow the steps recommended for neutralizing the threats that have been detected;
    • Switch off your device and turn it on as normal.

Find out more about Dr.Web for Android