Persistence on Linux

In this article we will describe some post-exploitation techniques allowing us to maintain our access to a Linux box.

Reverse shell

A reverse shell is neither discrete nor elegant, however it allow for quick backdoor access to the box.

Moreover, it does not require the machine to be visible on Internet, which can be useful if it is behind a NAT or a firewall.

Launch a connection to the attack server from our compromised machine:

This one-liner will try to open a shell to vps.hacker.com:8080 every 10 seconds.

We need a listener on the attacking server:

After some time, the shell is executed !

We can then put the reverse shell one-liner in rc.local or bashrc for cross-reboot persistence.

SSH backdoor

If a SSH service is enabled on the compromised host, a simple solution could be to add our public key to the authorized_keys file . We can then connect directly through SSH.

First, generate a SSH keypair on our attacking server:

After which we copy the public key to the compromised host:

We can log in anytime with:

Add user

Another solution could be to add a user. We can then use this user account to log in through SSH, FTP or any system service using local accounts on the machine.

This adds an “admin” user with password “lemmein”.

Leave a Reply

Your email address will not be published. Required fields are marked *