Cheat sheet of downloading or sharing files from linux to windows (windows to linux)

Md. Mahim Bin Firoj
4 min readDec 21, 2024

--

We often face difficulty while sending or sharing files from linux machine to windows machine. Say you have compromised a windows box from your kali. Now for several reason you may need to share files between these systems. Also the main pain is, sometimes the direct copy from windows host machine to vm is just not work.

Virtual box (Here windows is host machine and kali is as vm inside virtual box, network is nat configured):

If you want to share files from host machine to kali vm (vice-versa) then follow in this way….

Create a Shared folder in your windows host machine.

Click on the Settings of the CEH kali vm

Now click on “Shared Folders”.

Click on right most indicated Add icon.
Click Other from the drop down.
Locate the Shared folder.
Check the both checkbox.
Click Ok now.

You should see sf_Shared underneath your File System in kali. Here I am logging as root in my kali vm.

In the windows host machine I have kept a test file. You can see that in my kali vm the file is visible.

The sf_Shared folder is placed under /media folder in kali. So you can sift through there using command line.

VMware:

In vmware case, I have checked that simply dragging the file from your host machine and paste to your windows vm works just fine. But still showing you the process.

Right click on your vm and click on Settings. Then click on Options.

Click Next
Locate the folder from your host machine
Click Finish

This works fine.

Now let’s say your kali vm and windows host machine is in the same private network and you want to share file and download it via web browser. Apache web server is already installed on the kali vm. You just need to provide two commands below.

systemctl start apache2 
systemctl enable apache2

Now copy the “test file.rtf” file from sf_Shared folder to the /var/www/html/ directory. Restart the apache server again.

cp /media/sf_Shared/test\ file.rtf var/www/html/

systemctl restart apache2

Now from the windows machine: (Changed network config from nat to bridge)

File will be downloaded. If not because of permission related issue, then follow below SS. You need to give permission on that file.

There is another way:

python -m SimpleHTTPServer 80 (By default it serves on port 8000, but you can also specify a port number at the end.)

or

python3 -m http.server (In new kali version)

If you have windows desktop access, simply browse to http://YOUR-KALI-IP:8000 and use the browser to download the file by right click on the file and click on save as or just click on the file to download.

Now if you don’t have GUI access, then?

You need to download the file via command line from windows machine.

Invoke-WebRequest -Uri 'http://192.168.201.218:8000/test%20file.rtf' -OutFile 'H:\test_file.rtf'

or

Invoke-WebRequest -Uri 'http://192.168.201.218/test%20file.rtf' -OutFile 'H:\test_file.rtf'

or

(New-Object System.Net.WebClient).DownloadFile('http://192.168.201.218:8000/test%20file.rtf','H:\test_file.rtf')

or

(New-Object System.Net.WebClient).DownloadFile('http://192.168.201.218/test%20file.rtf','H:\test_file.rtf')

From the normal command prompt you can also call powershell this way:

From command prompt:

powershell -c "(New-Object System.Net.WebClient).DownloadFile('http://192.168.201.218:8000/test%20file.rtf','H:\test_file.rtf')"

powershell -c "Invoke-WebRequest -Uri 'http://192.168.201.218:8000/test%20file.rtf' -OutFile 'H:\test_file.rtf'"

Another way is Bits:

In powershell:

Start-BitsTransfer -Source 'http://192.168.201.218:8000/test%20file.rtf' -Destination 'H:\test_file.rtf'

From command prompt:

powershell -c "Start-BitsTransfer -Source 'http://192.168.201.218:8000/test%20file.rtf' -Destination 'H:\test_file.rtf'"

More to come…..

Thanks. I hope you like this write up. Please subscribe below and share it with your network.

LinkedIn:

https://www.linkedin.com/in/md-mahimbin-firoj-7b8a5a113/

YouTube:

https://www.youtube.com/@mahimfiroj1802/videos

--

--

No responses yet