How to access Website using command-line from the Terminal

GUI is not often possible, and you are not expected to rely on GUI/Gnome based tools for testing and exploitation practices. Suppose you have gained a shell on some machine and want to download an exploit, then the web browser is not available.

Penetration Testing Process often involves dealing with a variety of tools. These tools may be Command-Line based, GUI Based, readily available, and sometimes the pen tester may have to automate a set of commands.

Introduction

GUI is not often possible, and you are not expected to rely on GUI/Gnome based tools for testing and exploitation practices. Suppose you have gained a shell on some machine and want to download an exploit, then the web browser is not available. In this tutorial, we are going to take a look at different tools which are useful while browsing the website using command-line from the terminal.

Netcat

Netcat is a Swiss army knife for hackers, and It gives you a range of options to make your way through the exploitation phase.

Following is the way to access a webpage using GET method with netcat.
$ nc www.google.com 80
GET / HTTP/1.1
Host:www.google.com

Access with Netcat using the GET method

To access any contents like video, you can enter the following;

$ nc www.example.com 80
GET /VIDEO HTTP/1.1
Host:www.example.com

You can change the ways to POST, OPTIONS, CONNECT as per your requirements. With HTTP/1.1, the connection doesn’t close after one request. To close the connection, enter;

$ Connection:close

Closing Connection

Alternatively, you can also use the following while accessing the webpage;

$ nc www.google.com 80
GET / HTTP/1.1
Host:www.google.com
Connection: close

The above commands will close the connection automatically after the page has been fetched from the webserver.

Wget

wget is another commonly used tool to access the webpage. You can use it to download anything placed on a particular web server.

$ wget http://192.168.43.177

Accessing with wget

Curl

Curl is another powerful tool that is used to access the webpages in the command line environment. Enter the following command;

$ curl http://wwww.192.168.43.177/path_to_file/file.html

Accessing with curl
Accessing with curl

W3M

w3m is a CLI based web browser. It lets you view the page source and access the webpage as if you were accessing it in any GUI browser.

You can install it by the following command;

$ sudo apt install w3m

To access a webpage enter;

$ w3m www.google.com

Accessing with w3m
Accessing with w3m

Lynx

Another useful command-line tool is lynx. You can install it by entering;

$ sudo apt install lynx
To access a webpage, enter;

$ lynx www.google.com

Accessing with lynx
Accessing with lynx

Browsh

Another handy text-based browser is browsh. It is still under construction. You can use by initiating the ssh connection by;

$ ssh brow.sh

Then you can press CTRL+lto focus on the URL bar. Enter your query, and the Browsh will use Google as a search engine to search and output you the results on the command line.

Here’s an output of weather query using the Browsh.

Accessing with Browsh
Accessing with Browsh

Custom HTTP Request

You can also craft your custom HTTP request by entering the following command;

printf "GET /\r\nHost: google.com\r\n\r\n" | netcat google.com 80

The HTTPs request will look like the following;
printf "GET /\r\nHost: google.com\r\n\r\n" | socat - OPENSSL:google.com 443

Custom HTTP request
Custom HTTP request

Conclusion

We have a variety of tools available to access the webpages from the terminal. The terminal also gives us the ability to customize the requests hence giving us enhanced capabilities. A pen tester must have some of these tools in the pocket during exploitation.

Zohaib Yousaf
My name is Zohaib Yousaf. I'm an Ethical Hacker & a Pen Tester. Python scripting and Bash automation is my hobby. My research work is in Anonymity. I have co-worked in development of few anonymity solutions which implemented different Cryptographic Algorithms.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,521FansLike
364FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to setup FTP Server on CentOS

You are allowed to use any one of the FTP servers as you like. However, in this tutorial, we will be installing and using vsftpd, short for Very Secure FTP Daemon. It is a fast, stable, and secure FTP server that will help you transfer files to and from a remote system in a jiffy.

CentOS Vs. Ubuntu Server : Everything You Need to Know

Choosing the perfect Linux distribution to set up your server can be confusing since Linux provides a limitless number of options. The main reason behind these many distributions is because Linux is an opensource platform. Anybody with the required skills can contribute to the development or build and release their distribution. Currently, there are more than 600 Linux Desktop and Server distributions in the market.

Top 10 Reasons to use Xfce as your Desktop Environment

There are many choices for desktop environments for Linux based operating systems. Mainly, you can install any DE of your choice on most of the Linux based distributions, even if they are not offered as a package officially. In our recent articles, we discussed the best of KDE and Cinnamon. In this article, we wish to present to you the top reasons why you should consider Xfce as your desktop environment.

The 10 Best Linux Network Monitoring Tools

Having total control over your network is essential to prevent programs from overusing your network resources and slowing down the overall performance. This is why you should install a network monitoring tool on your system, giving you a visual overview of everything that's happening on your network. Networking Tools are like swiss-knife for the system administrators for troubleshooting system issues.

How to install CouchPotato on Ubuntu

Downloading movies and copying them over to your home server can get frustrating, especially if you are doing it daily! What if you have an option to download videos automatically, quickly, and above all with excellent quality. CouchPotato allows you to download movies easily once they are available and released automatically.

Top 20 Rsync Examples in Linux

The Rsync (remote sync) command is a Linux/Unix utility used to synchronize and copy files and directories either locally or remotely. Most Linux geeks use Rsync to mirror, backup or migrate data across folders, across disks and networks. One notable feature with the Rsync command is that it uses the "delta transfer algorithm."

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

CentOS Vs. Ubuntu Server : Everything You Need to Know

Choosing the perfect Linux distribution to set up your server can be confusing since Linux provides a limitless number of options. The main reason behind these many distributions is because Linux is an opensource platform. Anybody with the required skills can contribute to the development or build and release their distribution. Currently, there are more than 600 Linux Desktop and Server distributions in the market.

6 Best Linux Distros for Laptops

Whether buying a Linux pre-installed laptop or selecting a Linux distro for your existing laptop, there are many things to consider. Let's take you through some of the best Linux distros that are optimized for Laptops in this 2019 edition of the article. Read on.

5 ways to check if a Port is open on a remote Linux PC

There is an ample number of ways to check for any open ports on a remote Linux PC. Knowing open ports on a Linux machine helps system administrators to connect to the remote PC for troubleshooting system and cloud server issues.

Top 20 must-have apps for your Ubuntu PC

OK, this one is going to be a long one, so grab a cup of coffee and scroll through the best apps that we think are must-have for your Ubuntu PC. We have hand-picked each one of these considering the most common categories that suit an average Linux user.