Hosting A Local Website With Domain Name On Kali Linux Over WiFi

In today’s detailed tutorial we will learn how we can host a website from our Kali Linux machine over WiFi and other WiFi users able to see the website and download files directly from our Kali Machine. We also assign a domain name to our localhost website .

In our previous articles we have discussed hosting a website on localhost, same we will do here. First we start our Apache2 service by using following command:

sudo service apache2 start

This command may prompt for our root password, after giving the root password our Apache2 server will start. We can check whether this started or not by entering 127.0.0.1 in our Kali Linux’s browser. 127.0.0.1 is the IP address of our localhost.

image

Other devices connected in the same WiFi router can also visit this page but not with the localhost (127.0.0.1) IP address. In those devices we need the local IP address of our Kali system assigned by our router. To check the IP we type ip addr command (ifconfig is getting old) in our Kali Linux machine’s terminal.

ip addr

image

wlan0 IP address highlighted

In the above screenshot we can see our local IP address in the highlighted field.

Using this IP address we can see this webpage from any device connected with same router.

image

Kali Linux’s localhost on Mobile

Now we change our website as per we need. We will use a sample website for our tutorial example. User may create their own as per requirement.

First we need to edit the index.html file in our /var/www/html directory. To do that we use following command in our terminal:

sudo mousepad /var/www/html/index.html

Default Apache2 page’s HTML code is here. We will change this as per our need.

We have designed our page for an example as we can see in the following screenshot.

image

html codes in /var/ww/html/index.html

After making our webpage in HTML, or PHP we save the file and close it.

Then we visit the webpage from another device (Connected in same WiFi) by just entering the IP address of Kali Linux machine as we can see in the following screenshot.

image

Accessing the same page from Phone

Not only accessing the webpage we can paste any file on our that directory and download those files on any other device connected on the same WiFi network.

For becoming non-root user default (in Kali 2020 update) we usually can’t paste any file on system directories. So we need to open our file manager with root access by using following command:

sudo thunar

Then the file manager opens with root permission and we can copy our files from a directory to another using this file manager window (we can open another tab to use drag & drop). Here we put multimedia files in our /var/www/html directory.

image

File manager on root permission to change system files

Now we can download the files in other device by entering the IP and file name as shown in following screenshot:

image

So we have created our localhost website and it can be accessible from other devices in the same WiFi network. We can download files over WiFi. This is very easy and we have done it in our previous articles.

Now we point a Domain name to this IP address. Then we don’t need to type the boring IP address all the time.

We use ettercap graphical tool to do this, ettercap comes pre-installed with Kali Linux or can be downloaded on any Debian based system (Ubuntu, Parrot) by using following command:

sudo apt-get install ettercap-graphical

Now we go to the ettercap directory in our Kali Linux system. To do that we apply following command in our terminal window:

cd /etc/ettercap

Here we check the files using ls command.

image

We do some changes in the etter.dns file to point our domain name. Let’s open this in a text editor like mousepad or nano by running following command:

sudo mousepad etter.dns

This will open a file like following screenshot:

image

Here we scroll down to Microsoft part as shown in following screenshot:

image

Add a line above the microsoft.com

Then add a line just above the microsoft.com line. The line will be following:

kali.onion A 192.168.43.205

We can see the changes in the following screenshot:

image

We just added one line in this section

Here kali.onion will be our URL pointing to 192.168.43.205 (IP address of our Kali Linux machine) in our case. We can choose any other domain name if we want, but kali.org will not work if our router is connected with the internet, because kali.org is a SSl encrypted site. It’s better to choose a .onion domain extension.

Now we save and close the etter.dns file and open Ettercap graphical by using following:

sudo ettercap -G

Then it will open the Ettercap as shown in the following screenshot:

image

Then we click on the :heavy_check_mark: symbol to start the unified scanning. Here by default the network interface is wlan0 means Wi-Fi network interface.

Then we search for hosts we click on ፧ (3 dot menu) > Hosts > Scan for hosts

It will scan all connected devices on our local network. Now we click on hosts list on the host menu and ettercap will show us connected devices in our same Wi-Fi network. The screenshot is following:

image

Here in the above screenshot we can see our router’s IP (the first one) and all other connected device. It doesn’t included our Kali Linux device ettercap filtered it.

Now we add the router’s IP on the Target 1 and all other IPs in the Target 2 by right clicking on the list.

Then we click on the ፧ (3 dot menu) > Plugins > Manage plugins

image

After this a new window opens like following screenshot:

image

Here we find the plugin named “dns_spoof” and double click on it.

Then we click on the MITM (Man In The Middle) menu and choose ARP poisoning.

image

Then a popup box comes for optional parameters here we :heavy_check_mark: on the Sniff remote connection box and click on OK.

image

Here we click on OK to start MITM attack

Now we have all set. We now can open browser in our other device connected in same Wi-Fi network (in our case Android mobile) and type http://www.kali.onion in the address bar and we will open the page we have made and put in our Kali Linux’s /var/www/html directory.

image

Localhost website with a domain name

So this is how we can point a domain name to our localhost IP using Kali Linux system. This is the core concept of making the dark web. To host own dark web on the internet follow our Creating Own .onion Dark Web on Internet tutorial.

This tutorial has many practical uses. We can make a local website or download files over the WiFi. If we have good website building knowledge then we can even make a chatting website for our home or many other things.

Source: kalilinux

enjoy folks!

3 Likes