In this blog, I will explain how to access network connections on Tryhackme/HTB/etc…. machines.Having an internet connection will make it a lot easier when we are trying to pwn machines or playing attack/defense challenges although it could be slow but works.
I am performing it on my machine which is free to play on TryHackMe Link: EnPass
The machine is up.
We have to install a proxy server on our local machine. I will be going to use Squid Proxy.
I am using arch on wsl2.
For arch: sudo pacman -Sy squid For ubuntu: sudo apt install squid -y
Then enable the squid service and start it.
sudo systemctl enable squid sudo systemctl start squid or sudo service squid start
Let’s check locally if it is working or not.
As you see the connection is made via squid proxy. On normal, it would have been looked like this ( without Via: header)..
So far we are good with the setup. Now let’s first gain root access to the remote machine.
Right now I am on the remote machine as a root user.
The squid proxy runs on port 3128. We have to first forward our traffic to the remote machine via ssh.
Basically, it’s a remote port forwarding where all the traffic/connections are passed from the SSH server to
the remote server via an SSH client.
In a simple term, we are giving access to the people who can’t whereas in the local port forward, we access the resources that we cannot.
We have successfully port forwarded.
ssh -R 3128:<your-ip>:3128 -i id_rsa root@<machine-ip> ss -ltnp | grep 3128
Let’s confirm with the help of curl.
curl -x http://127.0.0.1:3128 http://www.google.com/ -I
We are good with it
We have successfully made the network connection work.
What if we want to download packages? apt cmdline won’t download or update anything without an internet connection. Just a few steps and it will start working.
Add the following line into the /etc/profile. This will make the proxy environment enable for all users globally.
We don’t have to now mention the “-x” flag.
apt will also work now. you can see Nmap is not installed first. Let’s try installing Nmap.
Yea, we are now successfully getting an internet connection.
If you can’t install any packages ( apt ) then you can try adding following line into a file “/etc/apt/apt.conf”.
Create it if you can’t find it.
Thank you for reading. :)
Have a good day/night.