Created
November 9, 2020 13:28
-
-
Save brmzkw/b08ce9b617bcf1296daf54be3123f3b3 to your computer and use it in GitHub Desktop.
Reverse shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Infra: | |
- laptop | |
- server | |
- container where commands can be executed | |
Steps: | |
- install and run ssh on the container | |
apt-get update && apt-get install -y ssh | |
mkdir /run/sshd | |
/usr/sbin/sshd | |
- create an account on server | |
adduser reverse | |
su reverse | |
ssh-keygen | |
cp /home/reverse/.ssh/id_rsa.pub /home/reverse/.ssh/authorized_keys | |
chown 644 /home/reverse/.ssh/authorized_keys | |
- the container needs to be configured to connect to the server | |
copy /home/reverse/.ssh/id_rsa to the container at /root/.ssh/id_rsa | |
chmod 600 /root/.ssh/id_rsa | |
ssh -o StrictHostKeyChecking=no -tt -i ~/.ssh/id_rsa -R 9999:localhost:22 reverse@<server ip> | |
- configure contaienr to accept your key | |
copy your laptop ~/.ssh/id_rsa.pub and add it to container /root/.ssh/authorized_keys | |
- connect to the container | |
ssh <server_ip> -A | |
ssh -p 9999 root@localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment