Backdoor Linux Commands
Hide a Network Connection
The trick is to hijack netstat
and use grep to filter out our connection. This example filters any connection on port 31337 or ip 1.2.3.4. The same should be done for ss
(a netstat alternative).
Method 1 - Hiding a connection with bash-function in ~/.bashrc
Cut & paste this to add the line to ~/.bashrc
Or cut & paste this for an obfuscated entry to ~/.bashrc:
The obfuscated entry to ~/.bashrc will look like this:
Method 2 - Hiding a connection with a binary in $PATH
Create a fake netstat binary in /usr/local/sbin. On a default Debian (and most Linux) the PATH variables (echo $PATH
) lists /usr/local/sbin before /usr/bin. This means that our hijacking binary /usr/local/sbin/netstat will be executed instead of /usr/bin/netstat.
(thank you iamaskid)
Hide a process as user
Continuing from "Hiding a connection" the same technique can be used to hide a process. This example hides the nmap process and also takes care that our grep
does not show up in the process list by renaming it to GREP:
Hide from cat
ANSI escape characters or a simple (carriage return) can be used to hide from cat
and others.
Hide the last command (example: id
) in ~/.bashrc
:
Note: We use echo -e
to convert \\033
to the ANSI escape character (hex 0x1b).
Adding a (carriage return) goes a long way to hide your ssh key from cat
:
Last updated