Detecting Obfuscated Command-lines with a Giant Language Mannequin

Within the safety trade, there’s a fixed, indisputable fact that practitioners should take care of: criminals are working additional time to continually change the menace panorama to their benefit. Their strategies are many, they usually exit of their option to keep away from detection and obfuscate their actions. In truth, one factor of obfuscation – command-line obfuscation – is the method of deliberately disguising command-lines, which hinders automated detection and seeks to cover the true intention of the adversary’s scripts.

Forms of Obfuscation

There are a couple of instruments publicly obtainable on GitHub that give us a glimpse of what strategies are utilized by adversaries. Certainly one of such instruments is Invoke-Obfuscation, a PowerShell script that goals to assist defenders simulate obfuscated payloads. After analyzing a number of the examples in Invoke-Obfuscation, we recognized completely different ranges of the approach:

Every of the colours within the picture represents a unique approach, and whereas there are numerous sorts of obfuscation, they’re not altering the general performance of the command. Within the easiest type, Gentle obfuscation adjustments the case of the letters on the command line; and Medium generates a sequence of concatenated strings with added characters “`” and “^” that are usually ignored by the command line. Along with the earlier strategies, it’s attainable to reorder the arguments on the command-line as seen on the Heavy instance, by utilizing the {} syntax specify the order of execution. Lastly, the Extremely degree of obfuscation makes use of Base64 encoded instructions, and by utilizing Base8*8 can keep away from a big quantity EDR detections.

Within the wild, that is what an un-obfuscated command-line would seem like:

One of many easiest, and least noticeable strategies an adversary may use, is altering the case of the letters on the command-line, which is what the beforehand talked about ‘Gentle’ approach demonstrated:

The insertion of characters which can be ignored by the command-line such because the ` (tick image) or ^ (caret image), which was beforehand talked about within the ‘Medium’ approach, would seem like this within the wild:

In our examples, the command silently installs software program from the web site The approach used on this case is very stealthy, since it’s utilizing software program that’s benign by itself and already pre-installed on any laptop working the Home windows working system.

Don’t Ignore the Warning Indicators, Examine Obfuscated Parts Rapidly

The presence of obfuscation strategies on the command-line typically serves as a powerful indication of suspicious (nearly at all times malicious) exercise. Whereas in some situation’s obfuscation could have a legitimate use-case, resembling utilizing credentials on the command-line (though this can be a very unhealthy concept), menace actors use these strategies to cover their malicious intent.  The Gamarue and Raspberry Robin malware campaigns generally used this method to keep away from detection by conventional EDR merchandise. This is the reason it’s important to detect obfuscation strategies as shortly as attainable and act on them.

Utilizing Giant Language Fashions (LLMs) to detect obfuscation

We created an obfuscation detector utilizing massive language fashions as the answer to the continually evolving state of obfuscation strategies. These fashions include two distinct elements: the tokenizer and the language mannequin.

The tokenizer augments the command traces and transforms them right into a low-dimensional illustration with out shedding details about the underlying obfuscation approach. In different phrases, the aim of the tokenizer is to separate the sentence or command-line into smaller items which can be normalized, and the LLM can perceive.

The tokens into which the command-line is separated are primarily a statistical illustration of frequent mixtures of characters. Due to this fact, the frequent mixtures of letters get a “longer” token and the much less frequent ones are represented as separate characters.

It is usually essential to maintain the context of what tokens are generally seen collectively, within the English language these are phrases and the syllables they’re constructed from. This idea is represented by “##” on this planet of pure language processing (NLP), which implies if a syllable or token is a continuation of a phrase we prepend “##”. The easiest way to exhibit that is to take a look at two examples; Certainly one of an English sentence that the frequent tokenizer received’t have an issue with, and the second with a malicious command line.

For the reason that command-line has a unique construction than pure language it’s essential to coach a customized tokenizer mannequin for our use-case. Moreover, this practice tokenizer goes to be considerably higher statistical illustration of the command-line and goes to be splitting the enter into for much longer (extra frequent) tokens.

For the second a part of the detection mannequin – the language mannequin – the Electra mannequin was chosen. This mannequin is tiny when in comparison with different generally used language fashions (~87% much less trainable parameters in comparison with BERT),  however continues to be capable of be taught the command line construction and detect beforehand unseen obfuscation strategies. The pre-training of the Electra mannequin is carried out on a number of benign command-line samples taken from telemetry, after which tokenized. Throughout this section, the mannequin learns the relationships between the tokens and their “regular” mixtures of tokens and their occurrences.

The following step for this mannequin is to be taught to distinguish between obfuscated and un-obfuscated samples, which is known as the fine-tuning section. Throughout this section we give the mannequin true optimistic samples that have been collected internally. Nevertheless, there weren’t sufficient samples noticed within the wild, so we additionally created an artificial obfuscated dataset from benign command-line samples. In the course of the fine-tuning section, we give the Electra mannequin each malicious and benign samples. By displaying completely different samples, the mannequin learns the underlying approach and notes that sure binaries have the next likelihood of being obfuscated than others.

The ensuing mannequin achieves spectacular outcomes having 99% precision and recall.

As we seemed by way of the outcomes of our LLM-based obfuscation detector, we discovered a couple of new tips identified malware resembling Raspberry Robin or Gamarue used. Raspberry Robin leveraged a closely obfuscated command-line utilizing wt.exe, that may solely be discovered on the Home windows 11 working system. However, Gamarue leveraged a brand new technique of encoding utilizing unprintable characters. This was a uncommon approach, not generally seen in reviews or uncooked telemetries.

Raspberry Robin:


The Electra mannequin has helped us detect anticipated types of obfuscation, in addition to these new tips utilized by the Gamarue, Raspberry Robin, and different malware households. Together with the prevailing safety occasions from the Cisco XDR portfolio, the script will increase its detection constancy.


There are a lot of strategies on the market which can be utilized by adversaries to cover their intent and it’s only a matter of time earlier than we come upon one thing new. LLMs present new potentialities to detect obfuscation strategies that generalize nicely and enhance the accuracy of our detections within the XDR portfolio. Let’s keep vigilant and hold our networks secure utilizing the Cisco XDR portfolio.

We’d love to listen to what you assume. Ask a Query, Remark Beneath, and Keep Related with Cisco Safety on social!

Cisco Safety Social Channels



Supply hyperlink


Please enter your comment!
Please enter your name here

Stay in Touch

To follow the best weight loss journeys, success stories and inspirational interviews with the industry's top coaches and specialists. Start changing your life today!


Related Articles