logo_SVG-01
✕
  • Platform
    • Rewterz XDR
    • Rewterz Defense
    • Rewterz Threat Intelligence
    • Managed Security Services
    • Managed Penetration Testing
  • Services
    • Assess
      • Compromise Assessment
      • Advanced Persistent Threats Assessment
      • Penetration Testing
      • Secure Architecture Design & Review
      • Red Team Assessment
      • Purple Team Assessment
      • Social Engineering
      • Source Code Review
    • Transform
      • SOC Consultancy
      • SOC Maturity Assessment
      • SOC Model Evaluation
      • SOC Gap Analysis
      • SIEM Gap Analysis
      • SIEM Optimization
      • SOC Content Pack
    • Train
      • Simulated Cyber Attack Exercise
      • Tabletop Exercise
      • Security Awareness and Training
    • Respond
      • Incident Analysis
      • Incident Response
  • Solutions
  • Resources
    • Blogs
    • Press Releases
    • Threat Insights
      • Threat Intelligence Reports
      • Threat Advisories
      • Monthly Threat Insights
  • Why Rewterz?
    • About Us
    • Careers
    • Contact
logo_SVG-01
  • Platform
    xdrLogo
    center_new
    Read More about XDR

    Platform

    • Rewterz XDR
    • Rewterz Defense
    • Rewterz Threat Intelligence
    How I Bypassed AMSI Statically Using WinDbg

    Managed Security Services

    • Managed Security Monitoring
    • Remote SOC
    • Onsite SOC
    • Hybrid SOC

    Managed Penetration Testing

    Rewterz penetration testing services help organizations determine if a cyber attacker can gain access to their critical assets while giving them detailed insights of the overall business impact of a cyber attack.

  • Services

    Assess

    • Compromise Assessment
    • APT Assessment
    • Penetration Testing
    • Architecture Design & Review
    • Red Team Assessment
    • Purple Team Assessment
    • Social Engineering
    • Source Code Review

    Transform

    • SOC Consultancy
    • SOC Maturity Assessment
    • SOC Model Evaluation
    • SOC Gap Analysis
    • SIEM Gap Analysis
    • SIEM Optimization
    • SOC Content Pack

    Train

    • Simulated Cyber Attack Exercise
    • Tabletop Exercise
    • Security Awareness and Training

    Respond

    • Incident Analysis
    • Incident Response
  • Solutions
  • Resources

    Resources

    • Blog
    • Press Releases
    March 6, 2023
    Rewterz
    March 6, 2023
    Rewterz Threat Advisory – CVE-2023-27290 – IBM Observability with Instana missing Vulnerability
    Severity High Analysis Summary CVE-2023-27290 Docker based datastores for IBM Instana (IBM Observability with Instana 239-0 through 239-2, 241-0 through 241-2, and 243-0) do not currently […]
    March 5, 2023
    Rewterz
    March 5, 2023
    Rewterz Threat Alert – SmokeLoader Malware – Active IOCs
    Severity Medium Analysis Summary Smoke Loader – a malicious bot application – can be used to load additional malware. Smoke Loader has been spotted in the […]
    March 5, 2023
    Rewterz
    March 5, 2023
    Rewterz Threat Alert – Cobalt Strike Malware – Active IOCs
    Severity Medium Analysis Summary Cobalt Strike first appeared in 2012 in response to alleged flaws in the Metasploit Framework, an existing red team (penetration testing) tool. […]

    Threat Insights

    16
    pdf-file (1)
    Annual Threat Intelligence Report 2022
    • Threat Advisories
    • Monthly Threat Insights
    • Threat Intelligence Reports
  • Why Rewterz?

    About Us

    Before Rewterz got its start, the market was in dire need of a specialized and dedicated information security company. It was nearly impossible for businesses to find a trustworthy provider that could truly cover all of their bases. We wanted to meet this need, giving companies across the globe a chance to get ahead while knowing that their data is in good hands.

    Read More

    play_btn_Smallplay_btn_hover_Small
    leadership

    Our Leadership

    Our leadership team brings together years of knowledge and experience in cybersecurity to drive our company's mission and vision. Our team is passionate about delivering high-quality products and services, leading by example and assisting our clients in securing their organization’s environment.
    help

    CSR

    At Rewterz, we believe that businesses have a responsibility to impact positively and contribute to the well-being of our communities as well as the planet. That's why we are committed to operating in a socially responsible and sustainable way.

    Connect with Us

    • Contact
    • Careers
Get in Touch
logo_SVG-01
  • Platform
    xdrLogo
    center_new
    Read More about XDR

    Platform

    • Rewterz XDR
    • Rewterz Defense
    • Rewterz Threat Intelligence
    How I Bypassed AMSI Statically Using WinDbg

    Managed Security Services

    • Managed Security Monitoring
    • Remote SOC
    • Onsite SOC
    • Hybrid SOC

    Managed Penetration Testing

    Rewterz penetration testing services help organizations determine if a cyber attacker can gain access to their critical assets while giving them detailed insights of the overall business impact of a cyber attack.

  • Services

    Assess

    • Compromise Assessment
    • APT Assessment
    • Penetration Testing
    • Architecture Design & Review
    • Red Team Assessment
    • Purple Team Assessment
    • Social Engineering
    • Source Code Review

    Transform

    • SOC Consultancy
    • SOC Maturity Assessment
    • SOC Model Evaluation
    • SOC Gap Analysis
    • SIEM Gap Analysis
    • SIEM Optimization
    • SOC Content Pack

    Train

    • Simulated Cyber Attack Exercise
    • Tabletop Exercise
    • Security Awareness and Training

    Respond

    • Incident Analysis
    • Incident Response
  • Solutions
  • Resources

    Resources

    • Blog
    • Press Releases
    March 6, 2023
    Rewterz
    March 6, 2023
    Rewterz Threat Advisory – CVE-2023-27290 – IBM Observability with Instana missing Vulnerability
    Severity High Analysis Summary CVE-2023-27290 Docker based datastores for IBM Instana (IBM Observability with Instana 239-0 through 239-2, 241-0 through 241-2, and 243-0) do not currently […]
    March 5, 2023
    Rewterz
    March 5, 2023
    Rewterz Threat Alert – SmokeLoader Malware – Active IOCs
    Severity Medium Analysis Summary Smoke Loader – a malicious bot application – can be used to load additional malware. Smoke Loader has been spotted in the […]
    March 5, 2023
    Rewterz
    March 5, 2023
    Rewterz Threat Alert – Cobalt Strike Malware – Active IOCs
    Severity Medium Analysis Summary Cobalt Strike first appeared in 2012 in response to alleged flaws in the Metasploit Framework, an existing red team (penetration testing) tool. […]

    Threat Insights

    16
    pdf-file (1)
    Annual Threat Intelligence Report 2022
    • Threat Advisories
    • Monthly Threat Insights
    • Threat Intelligence Reports
  • Why Rewterz?

    About Us

    Before Rewterz got its start, the market was in dire need of a specialized and dedicated information security company. It was nearly impossible for businesses to find a trustworthy provider that could truly cover all of their bases. We wanted to meet this need, giving companies across the globe a chance to get ahead while knowing that their data is in good hands.

    Read More

    play_btn_Smallplay_btn_hover_Small
    leadership

    Our Leadership

    Our leadership team brings together years of knowledge and experience in cybersecurity to drive our company's mission and vision. Our team is passionate about delivering high-quality products and services, leading by example and assisting our clients in securing their organization’s environment.
    help

    CSR

    At Rewterz, we believe that businesses have a responsibility to impact positively and contribute to the well-being of our communities as well as the planet. That's why we are committed to operating in a socially responsible and sustainable way.

    Connect with Us

    • Contact
    • Careers
Get in Touch
Rewterz
Rewterz Threat Alert – Ryuk Ransomware – Active IOCs
September 12, 2022
Rewterz
Rewterz Threat Alert – APT32 Ocean Lotus – Active IOCs
September 13, 2022

How I Bypassed AMSI Statically Using WinDbg

September 13, 2022

This blog has been written by our Senior Security Researcher, S. Nayani

Introduction

Understanding how real attackers develop methods for bypassing security controls and reverse engineering them is always fascinating. It has always been my passion to explore the world of vulnerability research therefore, I started learning debuggers and how to debug applications. Furthermore, I was also looking at different methods to bypass AMSI. Even though there are several blogs and onliners to bypass AMSI, I still wanted to explore it myself and gladly was able to bypass it using WinDbg. 

What is AMSI

Before diving into the bypass part, let’s first take a look at what AMSI is. Microsoft developed AMSI or AntiMalware Scan Interface to defend against Scripting languages such as PowerShell, VBScript, or JScript which are usually easy prey for hackers. These languages are integrated into the OS and have a lot of “legit” functions that could be used by hackers to perform illegitimate activities. AMSI is used by Antiviruses to detect malicious scripts being run on these scripting languages. 

For more information refer to Microsoft documentation: https://docs.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal. 

Bypassing Magic

I’ll be bypassing AMSI in PowerShell using WinDbg and will be going over the basics of WinDbg, so basically, every time a PowerShell session is opened AMSI.dll is initialized with it. 

First, we need to see what functions are there in AMSI.dll, there are a few methods that we can use to get the functions of DLL, 

1. Using the dumpbin.exe

dumpbin /exports <dllname>

2. Using dependency walker:

3. Microsoft also has documentation of AMSI, they have also mentioned the functions: 

https://docs.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-functions

After getting the functions of the dll, the thing we want to figure out is which functions are called when AMSI detects something malicious. For that we are going to use Frida: 

Run Frida-trace to attach to a PowerShell session, you can get the process ID by running the Get-Process command.

 Frida-trace.exe -p 4820 -i *Amsi* -x amsi.dll

-p: Process ID

-i: specify the function name or matching pattern

-x: Module or dll name 

After attaching to the PowerShell session and hooking the functions, we enter a string in the session that is hooked:

Note: Amsi flags a simple string “amsiutils” as malicious. 

Now check Frida-trace output: 

As you may have noticed, 2 functions are called

AmsiOpen() and AmsiScanButter(). The next step would be to examine those functions through a debugger, let’s fire up WinDbg and attach it to our PowerShell session:

Let’s set a breakpoint to the AmsiScanBuffer functions:

You can set a breakpoint using the bp command: 

bp Amsi!AmsiScanBuffer

After setting the breaking point, enter the (g) command to run the process normally and enter another string in the PowerShell session to trigger the breaking point, and enter the (u) command to unassemble the function.

When I was trying to bypass AMSI, I was exploring and trying to figure out the logic behind this function, I went through all the registers that it was using and in the above screenshot, there is a rdi register when I looked at its value it had ‘AMSI’ ASCII string in it.

That was a bit suspicious for me, so I modified that instruction and changed it to just return (c3 in hex):

You can edit the instruction by using the (a) command: 

Let’s see if that worked, run the process normally using the (g) command, and let’s see if we bypassed AMSI:

And there you have it, it was flagging the ‘amsiutils’ string as malicious after our bypass it did not flag that, proving that we have indeed bypassed AMSI successfully. 

Platform

  • Rewterz XDR
  • Rewterz Defense
  • Rewterz Threat Intelligence

Managed Security Services

  • Managed Security Monitoring
  • Remote SOC
  • Onsite SOC
  • Hybrid SOC

Assess

  • Compromise Assessment
  • APT Assessment
  • Penetration Testing
  • Architecture Design & Review
  • Red Team Assessment
  • Purple Team Assessment
  • Social Engineering
  • Source Code Review

Transform

  • SOC Consultancy
  • SOC Maturity Assessment
  • SOC Model Evaluation
  • SOC Gap Analysis
  • SIEM Gap Analysis
  • SIEM Optimization
  • SOC Content Pack

Train

  • Simulated Cyber Attack Exercise
  • Tabletop Exercise
  • Security Awareness and Training

Respond

  • Incident Analysis
  • Incident Response

Threat Insights

  • Threat Advisories
  • Monthly Threat Insights
  • Threat Intelligence Reports

Resources

  • Blog
  • Press Releases

Connect With Us

  • Contact
  • Careers
COPYRIGHT © REWTERZ. ALL RIGHTS RESERVED.
Get a Demo