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

24,536FansLike
172FollowersFollow

LATEST ARTICLES

Application Launchers for Ubuntu
Ubuntu is one of the most used Linux distributions worldwide. It is also the reason why it has the maximum number of available programs for itself. Today we are going to talk about one category of those programs, the application launchers.
screen capturing apps for linux
Do you want to make a video tutorial for YouTube or show-off your epic victory royale to your friends? Look no further — as we have compiled the 10 Best Screen Capturing Software for Linux. Whether you need to record your desktop screen or take a simple screenshot, FOSSLinux has got your back.
best video players for linux
Most Linux-based systems come with a built-in video player, but let's be honest, it most definitely won't be able to satisfy all of your requirements, due to the fact that default software is mostly made for basic purposes. In this article, we will review the 5 Best Video Players for Linux and thoroughly discuss their features as well as their pros and cons.
best music players for linux
For sure, there will be Linux users out there who cannot live without music. If you're one of those people, you would know how important it is to have a good music player installed on your computer system. In this article, we present to you the 5 Best Music Players for Linux, which will hopefully be able to satisfy each of our readers' needs.
best linux distros programmers
Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.