redcanaryco / invoke-atomicredteam

Invoke-AtomicRedTeam is a PowerShell module to execute tests as defined in the [atomics folder](https://github.com/redcanaryco/atomic-red-team/tree/master/atomics) of Red Canary's Atomic Red Team project.
MIT License
805 stars 190 forks source link

Update Install-AtomicsFolder to support powershell 7.2+ #130

Closed mbaran5 closed 1 year ago

mbaran5 commented 1 year ago

Powershell 7.2 and newer has deprecated WebClient (along with WebRequest, HttpWebRequest, and ServicePoint). This PR replaces the ExtendedWebClient object with HttpClient and uses the .Timeout option to specify the same 3 minute timeout as previously defined in the custom ExtendedWebClient class.

Errors as shown on various Linux distributions using pwsh 7.2 or 7.3

VERBOSE: Installing Atomics Folder
Add-Type:
Line |
 166 |      Add-Type -TypeDefinition $Source -Language CSharp
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | (14,5): error SYSLIB0014: 'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.'
    public ExtendedWebClient() {
    ^
Installation of AtomicRedTeam Failed.
Cannot add type. Compilation errors occurred.

I have tested this against pwsh 7.3 on Ubuntu 22.04 and have had no issues completing the installation of the atomics folder now.

mbaran5 commented 1 year ago

Closing PR as "-NoPayloads" isn't functional.

nicklangsysdig commented 1 year ago

F