
The operator now wants to SSH into the compromised host directly from the internet. Let’s assume that during an assessment, an operator compromises a host, named PWNED1, that is running a SSH server. GOAL: Connect to a port on a compromised host in the client network from a redirector The following image illustrates using a SSH private key to connect to a SSH server on the host REDIR1 as the rastley user from LINUX1: To start, LINUX1 represents an operator’s Linux workstation and REDIR1 represents an internet accessible host that is part of the offensive operation’s infrastructure. A visual image will be presented after each set of commands to illustrate the network connectivity and to identify which hosts commands should be executed on. On a Linux host, the permissions should be “600” so that the user can read and write the file, but the group and other users are not allowed access.Įach major section of this post will build on the previous section and also break down the commands into numbered parts to in an attempt to increase understanding. If file permissions allow others to read the file, the SSH client will ignore the identity file and display an error. The private key file permissions must be restricted so that only the user, and nobody else, can read the file. Be sure to enter a password when prompted to encrypt the key. The ssh-keygen utility can be used to create a 4096-bit RSA key pair with: >$ ssh-keygen -t rsa -b 4096īy default, this will output a private key named id_rsa and public key file named id_rsa.pub. Because of this, SSH keys should be encrypted with a password that acts as a second factor. Just like a password, if a private key is recovered by an attacker, it can be used to access the server. The generated public key is added to the target host’s SSH authorized_keys file. Users should secure access to their generated private key just like it is a secret. These keys offer strong configurable asymmetric encryption. In addition, SSH allows users to create a public and private key pair that can subsequently be used in place of a password. SSH connections can be established with only a username and password for authentication. It would be a significant failure if offensive operations infrastructure was compromised or even accessible to adversaries. This is especially true if the SSH server is internet accessible. Firewallīecause SSH facilitates remote control of a host, the SSH server should always be configure with firewall rules that whitelist connection from a specific host. The most common SSH client/server is the OpenSSH implementation and is the application used for all references in this post. Most Linux-based servers have a SSH server installed and both Windows and Linux have a built-in SSH client. You can download it as portable application or install it.Whatever you choose, you should start it,and at the initial screens,as host name enter your server’s IP, here it is is a protocol that allows a user to remotely connect to a host and typically provides an interactive shell or command prompt that can further be leveraged to execute commands. In Windows, we can easily set an SSH tunnel by using a well-known SSH client called Putty.Putty can be downloaded from this site: For this tutorial, I choose CentOS 6.9, 圆4 version, but I have also tested it on Ubuntu 14.05 圆4 and it works without any modification. You need to have a VPS server available in the cloud,which you can access via SSH (you need an IP and root user’s password).I use VPS provider DigitalOcean, because of it’s simplicity and multiple available Linux distributions, it’s versions, and different 32/64 versions for some of them. I will show how to set a SOCKS5 connection using a linux server in the cloud and your browsers. It has older version 4 and new version 5, which support some new capabilities, like client authentication,UDP packages and server-side named resolution. It reaches the proxy server, which gets the web page on client’s behalf,and hands it back to him.It is not limited to HTTP traffic only, like Squid proxy server, but can proxy any TCP traffic. And then, there is something called SOCKS protocol which actually makes a tunnel via a proxy server,through which our requests are directed.
