Suspicious Threat

Description

Our SSH server is showing strange library linking errors, and critical folders seem to be missing despite their confirmed existence. Investigate the anomalies in the library loading process and filesystem. Look for hidden manipulations that could indicate a userland rootkit.

Creds: root:hackthebox

Solution

 ssh root@94.237.61.58 -p 34802
root@94.237.61.58 password: hackthebox
root@ng-932570-forensicssuspiciousthreatmp-u0ybi-7fcf567d47-vwbdt:~# id
uid=0(root) gid=0(root) groups=0(root)

To identify linking errors we can use ldconfig:

root@ng-932570-forensicssuspiciousthreatmp-u0ybi-7fcf567d47-vwbdt:~# ldconfig -v
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
(from /etc/ld.so.conf.d/x86_64-linux-gnu.conf:4 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3)
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
(from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3)
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
(from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3)
/sbin/ldconfig.real: Path `/usr/lib' given more than once
(from <builtin>:0 and <builtin>:0)
/usr/local/lib: (from /etc/ld.so.conf.d/libc.conf:2)
/lib/x86_64-linux-gnu: (from /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3)
        libgirepository-1.0.so.1 -> libgirepository-1.0.so.1.0.0
        libdevmapper.so.1.02.1 -> libdevmapper.so.1.02.1

x86_64-linux-gnu appears more then once, find it:

Easiest way I found to detect malicious library was to compare them to existing, like my files.

libc.hook.so.6 stands out from others.

Turns out library files have a naming convention: https://stackoverflow.com/a/21462448arrow-up-right

The file naming was also an indicator?

Malware analysis libc.hook.so.6 Malicious activityarrow-up-right

Suspicious_Threat.png

Program is looking for pr3l04d_ directory, but fopen is looking for lp.so.preload

Suspicious_Threat-1.png

The search is unsuccessful

/etc/ld.so.preloadarrow-up-right is a way to elevate privileges by hijacking LD_PRELOAD env variable. By moving the file the directories/files are created:

circle-check

Last updated