How to Transfer Files from Kali Linux virtual machine to Windows host machine Using Apache Server

Introduction

Transferring files from a Linux virtual machine to a Windows system can be a challenging task, especially for those who are not familiar with the process. The differences in operating systems, network configurations, and File Transfer Protocols (FTP) often result in a challenging experience. Many users are stuck, dealing with permissions issues, connectivity problems, or not knowing which tools to use. Whether you're a novice or an experienced user, this method will help to guide you through the process of file transfers between Linux and Windows.

This guide explains how to transfer files from Kali Linux virtual machine to a Windows host machine using Apache server, which comes preinstalled in Kali Linux.

Prerequisite

Before proceeding with the file transfer process, ensure the following prerequisites are met:

  • Kali Linux Machine: You should have root privileges or access to sudo.

  • Apache Web Server

    Apache web server must be installed on the Kali Linux machine. If not already installed, you can install it using the following commands:

sudo apt-get update
sudo apt-get install apache2
  • Network Configuration: The Kali Linux machine and the Windows PC must be on the same network.

Steps to transfer files

Step 1: Create or Select a File you want to Transfer

Create a new file or select an existing file. For example, to create a sample myfile.txt file use the command below:

echo "This is the file to be sent" > myfile.txt

The above command adds This is the file to be sent text to the myfile.txt file.

Step 2: Copy the file to /var/www/html/ directory

sudo cp myfile.txt /var/www/html/

-Note:

The directory/var/www/html/is used because it is the default document root directory for the Apache web server on many Linux distributions, including Kali Linux. When you place files in this directory, Apache serves these files to clients who request them via a web browser or other HTTP clients.

Step 3: Enter the Directory

cd /var/www/html/

Step 4: Create a new folder and copy the file to it

sudo mkdir sentfolder
sudo cp myfile.txt sentfolder

A folder sentfolder is created using the mkdir command.

Step 5: Start the Apache2 Service

sudo systemctl start apache2

Step 6: Check your Kali Linux IP Address

To find the IP address of your Kali Linux machine, use:

ifconfig

When you run the command to check your IP address, the output should look like this;

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:fe0d:2c1  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:0d:2c:01  txqueuelen 1000  (Ethernet)
        RX packets 12211  bytes 19327194 (18.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8456  bytes 748162 (730.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 12  bytes 720 (720.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 720 (720.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

-Note:

Look for theinetline under the relevant network interface names such aseth0,wlan0,enp3s0, amongst others and find the IP address assigned to that interface. In the above output the network inteface name iseth0.

Step 7: Open the Location in Your Windows Browser

On your Windows PC, open a web browser and navigate to:

http://192.168.1.10/sentfolder/

Replace 192.168.1.10 with the IP address of your Kali Linux machine.

Step 8: Click the File to Download

Click on the file myfile.txt to download it.

Step 9: Stop the Apache2 Service

After the file has been downloaded, stop the Apache web server:

sudo systemctl stop apache2

Conclusion

You have transferred file from Kali Linux virtual machine to your Windows host machine using the Apache server.

As long as both your Kali Linux machine and your Windows PC are on the same local network, the internet is not required for this method of file transfer. This setup is ideal for secure and fast file transfers within a local network environment.

For more information on Apache server visit Apache server documentation

2
Subscribe to my newsletter

Read articles from Mukoro Ogheneteguonor Michelle directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mukoro  Ogheneteguonor Michelle
Mukoro Ogheneteguonor Michelle