0x0.ps1
#398
- Author
- winny
- Created
- Oct. 14, 2021, 1:13 a.m.
- Expires
- Never
- Size
- 1009 bytes
- Hits
- 335
- Syntax
- PowerShell
- Private
- ✗ No
# Upload a file to https://0x0.st/
#
# Powershell 6+ script. Does not work with standard windows powershell
# because it's too old to be good for anything :(.
# Load the HTTP Assembly
Add-Type -AssemblyName System.Net.Http
# Get the file's contents as an array of bytes.
$array = Get-Content $Args[0] -Raw -AsByteStream
$multiContent = New-Object System.Net.Http.MultipartFormDataContent
# Create the multipart content from the byte array.
$byteArrayContent = [System.Net.Http.ByteArrayContent]::new($array)
# Add the byte array content as form field "file" with name "file".
# Turns out 0x0 *needs* the filename (3rd) parameter.
$multiContent.Add($byteArrayContent, "file", "file")
# -Body automatically gets converted to a multipart body the cmdlet sets the
# content-type accordingly.
$response = Invoke-Webrequest `
-Uri 'https://0x0.st/' `
-Method POST `
-Body $multiContent
# Remove the newline the webservice adds to the response.
Write-Host ($response.Content -replace "`n", "")