Last active
December 20, 2015 06:39
-
-
Save antonydenyer/6087279 to your computer and use it in GitHub Desktop.
Abusing Octopus Deploy with OctoChef Deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[parameter(Mandatory = $true)] | |
$packageName | |
) | |
$currentDirectory=$pwd | |
function CreateTempDir | |
{ | |
$tmpDir = [System.IO.Path]::GetTempPath() | |
$tmpDir = [System.IO.Path]::Combine($tmpDir, [System.IO.Path]::GetRandomFileName()) | |
[System.IO.Directory]::CreateDirectory($tmpDir) | Out-Null | |
$tmpDir | |
} | |
$tmpDir = CreateTempDir | |
$temp_file = [System.IO.Path]::Combine($tmpDir,"install.zip") | |
write-host $packageName | |
$nugetFeed = 'http://teamcity/guestAuth/app/nuget/v1/FeedService.svc/' | |
$url = $nugetFeed + 'Packages()?$filter=tolower(Id)%20eq%20''' + $packageName + '''&$orderby=Id' | |
write-host "Querying teamcity with $url" | |
$response = (Invoke-RestMethod -uri $url) | |
$url = $response[$response.Count - 1].content.src | |
write-host "Downloading package from $url to $tmpDir" | |
$client = new-object System.Net.WebClient | |
$client.DownloadFile($url, $temp_file) | |
(new-object -com shell.application).namespace($tmpDir).CopyHere((new-object -com shell.application).namespace($temp_file).Items(),16) | |
cd $tmpDir | |
.\tools\Deploy.ps1 | |
cd $currentDirectory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment