Skip to content

Preparing environment for file transfer

Just listing of tricks and/or scripts that can assist on getting the environment ready for receiving external files

Python HTTP Server

Python have a built-in simple server that is useful to transfer files to a machine. The downside is the server is not prepared to receive files as it does not support POST method.

A lot of users in github have implemented workarounds with modifications to original python module. One of them implemented in Python3 is the following code by TJNull on his OSCP repository.

HTTP Server with upload

Webdav

If you want to use curl -T features for example (Uploading a file via PUT, web-dav like). Need to setup a webserver capable to understand this requests. Nginx is typically present on pentest distros and it is easy enough to configure this functionality.

  • First of all, add to your /etc/nginx/sites-available/<site> your desired configuration. Example:

1
2
3
4
5
6
7
8
9
server {
    listen 8081 default_server;
    server_name upload.srv;
    location / {
        root /var/www/upload;
        dav_methods PUT;
        dav_access    user:rw group:rw all:rw; # Modify according your desired privileges 
    }
}
* Next one is doing a symlink to sites-enabled

1
2
3
4
╰─❯ ln -s /etc/nginx/sites-available/upload /etc/nginx/sites-enabled/upload

╰─❯ ls ../sites-enabled -l                                      
lrwxrwxrwx root root 33 B  Sun Feb 21 16:41:30 2021  upload ⇒ /etc/nginx/sites-available/upload
  • Set permissions to the nginx user (typically www-data ) on the target folder
1
chown www-data:www-data /var/www/upload
  • And finally, start the service and test