GH-011 T1027.010 PHASE RED INSIDE

The Sealed Order

This command touches a marker file and sleeps: touch /tmp/gh011/.marker; sleep 900. This one does exactly the same: dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=. Same bytes, same effect, unreadable text. The process list shows both honestly; a defender grepping for the wrong word sees only one of them. This file runs both, then opens the envelope.

TechniqueCommand Obfuscation (T1027.010)
Target OSUbuntu 24.04.5 LTS
Toolchainbash, coreutils
LevelBeginner
Time20 min

OBJECTIVES

  1. Run the same payload twice, once readable and once base64-sealed, and watch the marker prove both ran
  2. Spot the decoder-shaped process line and decode the blob yourself
  3. Log full command lines and narrow which decoders may run
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1027.010: adversaries rewrite commands so a human reader cannot tell what they do, while the machine still can. This file runs the same payload twice, once readable and once sealed, and shows why the defender must read the decoded form, not the typed form.

Why this technique. The defender's fastest tools are string tools: grep across the process table, SIEM rules matching suspicious words, an eyeball scan of command lines. All of them read the typed form of the command, the exact characters the attacker chose to type. Obfuscation rewrites the command so those characters say nothing. The command still runs, because the machine does not read the typed form; it decodes first, then runs. The technique attacks the reader, not the machine.

Why not just grep for the bad word. That is the obvious defensive move, and this file runs it against the real thing: ps -ef | grep '[m]arker' returns nothing. The marker file is sitting in /tmp/gh011, the payload ran, and grep reports an empty result with a straight face. The typed form contains no suspicious string at all, so string-matching has nothing to match. A control that checks the typed form cannot beat a technique that rewrites the typed form.

Why not the attacker's simpler moves. A forged name or a hidden directory hides WHERE the thing is; sealing the order hides WHAT the command says. A defender who finds the hidden directory still reads the payload; a defender who reads the sealed command line reads nothing. The two hide different things, so they need different observers.

The mechanism, in one line. Obfuscation is rewriting a command so a human reader cannot tell what it does, while the machine still can. Base64 is an encoding that turns any bytes into plain letters and digits, so the command survives being pasted into text; base64 -d turns it back. The sealed order runs echo <blob> | base64 -d | sh: the shell decodes the blob, then executes the result. Nothing secret is happening; the decoding is the plainest operation in the pipeline, which is exactly why it works. Note the boundary: this is encoding, not encryption. Anyone holding the blob can decode it. That is the attacker's tradeoff and the defender's opening.

The concrete case, before the abstraction. The payload is touch /tmp/gh011/.marker; sleep 900. Its base64 form is one line of unreadable text:

blob
dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=

Check the translation by hand: decoding the blob prints the original command.

bash
$ echo 'dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=' | base64 -d
touch /tmp/gh011/.marker; sleep 900

The blob is 48 characters for a 35-character command, about a third longer, roughly one line of this text. That length is the only price the attacker pays.

Scope. T1027 covers obfuscated files and information broadly: encoded payloads, encrypted blobs, stacked encodings. This file works the command-obfuscation case end to end: the sealed command line, and the decoder's-eye view that opens it.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, in a disposable VM used only for this lab. The attack needs no privilege at all: any user can pipe base64 into sh. Run it on a throwaway box anyway, because you are about to practice lying to your own tools.

1

Build the lab

One disposable directory. Everything the payload touches lives inside it, so cleanup is a single rm.

bash
$ rm -rf /tmp/gh011; mkdir -p /tmp/gh011 && cd /tmp/gh011 && pwd
/tmp/gh011
2

The payload: one line

Two statements. touch /tmp/gh011/.marker creates the marker file, the proof the payload ran: inert, one file, inside its own lab directory. The semicolon separates commands. sleep 900 sleeps fifteen minutes, so the process stays visible on the table long enough to inspect, then dies on its own. Nine hundred seconds is about a quarter hour, long enough for the whole lab, short enough to need no cleanup if you forget.

sh: payload
touch /tmp/gh011/.marker; sleep 900
03

Phase Red: seal the order

ATTACK

The same payload, twice: first in the open, then sealed. The marker file is the witness each time. Watch what the process table tells a defender who greps for the payload's name.

Real screen recording 68.8s
What you are watching: The payload runs in plain text, then as a base64 blob. Grep for the suspicious word finds nothing; the marker file says otherwise. Every command below is copy-pasteable.
1

The plain order

Baseline first: the readable command, so the reader knows what the hidden version is hiding. Every part of this is inspectable by a tired operator.

bash
$ touch /tmp/gh011/.marker; sleep 900 &
[1] 7
$ sleep 1; test -e /tmp/gh011/.marker && echo "payload ran: marker created"
payload ran: marker created

The marker appeared, which proves the payload ran. The command line says exactly what it did: touch a file, sleep. This is the reference the sealed version will be measured against.

2

Clean the slate

Kill the plain run and remove its marker, so the next run has to prove itself instead of riding on the old evidence.

bash
$ pkill -f '[s]leep 900'; sleep 0.5; rm -f /tmp/gh011/.marker; echo "slate clean"
slate clean
3

The sealed order

Encode the exact same command, then run the blob through the decoder. The -n keeps echo from adding a newline, so the blob encodes the command and nothing else.

bash
$ echo -n 'touch /tmp/gh011/.marker; sleep 900' | base64
dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=
$ sh -c 'echo dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA= | base64 -d | sh' &
[1] 14
$ sleep 1; test -e /tmp/gh011/.marker && echo "same effect: marker created"
same effect: marker created

Identical effect, unreadable command line. The blob says nothing about markers, touching, or sleeping, and no human could tell you what it does by looking at it. The shell decoded it before running it; that decoding is the whole attack, and it is also the whole detection.

4

The greppable lie

Now the defender's obvious move: grep the process table for the suspicious word. The bracket trick in '[m]arker' keeps grep from matching its own process line, so the empty result is honest, not an artifact.

bash
$ ps -ef | grep '[m]arker' || echo "grep found nothing"
grep found nothing
$ ps -ef | grep '[b]ase64'
root          14       1  0 12:14 ?        00:00:00 sh -c echo dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA= | base64 -d | sh

The suspicious word appears nowhere in the typed form, so the grep finds nothing, while the marker file proves the payload ran. The second grep shows what string-matching CAN see: the gibberish line itself, a sh -c wrapping base64 -d. Nobody hand-types that shape. The tell is the decoder in the pipeline, not any word inside the blob.

Stealth confirmed

The same payload ran twice, and the marker file witnessed both runs. The plain command greps cleanly; the sealed command cannot be grepped for at all, because the typed form contains no word worth grepping. String-matching the command line reads what the attacker typed, and the attacker chose to type nothing readable. The machine still decoded and ran it; the defender did not.

04

Phase Blue: open the envelope

DEFENSE

The shell had to decode the blob to run it. The defender runs the same operation in reverse: copy the blob, decode it, read the real command. The envelope was never sealed against the defender, only against the reader.

Here is the trap: staring at the gibberish line, declaring it suspicious, and moving on without reading it. Suspicious is not a finding. The command the blob decodes to is the finding, and it costs one pipeline to read.

Real screen recording 53.9s
What you are watching: The gibberish process line is found, the blob is decoded by hand, and the real command reads in plain text. Every command below is copy-pasteable.
1

The tell

Watch for the shape, not the words: a process line that decodes its own command. The typed form is a lead, not a verdict. Decode-then-execute is everyday legitimate infrastructure: cloud-init decodes base64 user-data and runs it as a shell script on every cloud boot, and CI pipelines routinely pipe echo "$VAR" | base64 -d | bash. So the shape alone never convicts. Decode the blob; the decoded command is the finding. A blob that decodes to touch /tmp/...; sleep 900 with no provisioning context is the attack. A blob that decodes to your own cloud-init user-data is Tuesday.

bash
$ ps -ef | grep '[b]ase64'
root          14       1  0 12:14 ?        00:00:00 sh -c echo dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA= | base64 -d | sh

There it is: the wrapper, with the full blob in its command line. The detection keyed on base64 -d inside a sh -c, not on any property of the blob. The blob is evidence to be opened, not a string to be matched.

Good versus bad, concrete: good is a decode pipeline whose decoded content matches a known provisioning source (cloud-init user-data, a CI job definition, an installer you can name). Bad is a decode pipeline whose decoded content references paths and persistence no legitimate job owns (/tmp markers, sleep loops, outbound fetches). The check is always on the decoded form.

2

Open the envelope

Copy the blob out of the command line and run it through the same decoder the shell used. The shell decoded it to run it; the defender decodes it to read it. Same operation, both directions.

bash
$ echo 'dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=' | base64 -d
touch /tmp/gh011/.marker; sleep 900

The real command prints in plain text: touch a marker, sleep. The envelope opened because it was never locked, only folded. Encoding hides the command from readers; it cannot hide it from anyone willing to decode.

3

Confirm the effect

The decoded command predicts two effects. Check both against the system, not just against the blob.

bash
$ test -e /tmp/gh011/.marker && echo "marker exists: the sealed order ran"
marker exists: the sealed order ran
$ ps -ef | grep '[s]leep 900'
root          20      18  0 12:14 ?        00:00:00 sleep 900

The marker file exists and a sleep 900 process is on the table. The reading is confirmed: the decoded command matches the running reality.

4

Break it down

Identify the wrapper by the decoder's shape, confirm it from its own command line, and kill that pid, not the pattern. Then kill the sleeper by the name the decoded command gave you. Confirm each kill landed before moving on.

bash
$ WPID=$(pgrep -f 'base64 -d' | head -1); echo "wrapper pid=$WPID"
wrapper pid=4
$ tr '\0' ' ' < /proc/$WPID/cmdline; echo
sh -c echo dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA= | base64 -d | sh 
$ kill "$WPID"; sleep 0.5; kill -0 "$WPID" 2>/dev/null || echo "wrapper gone"
wrapper gone
Terminated
$ pkill -f '[s]leep 900'; sleep 0.5; pgrep -af 'sleep 900' || echo "sleeper gone"
sleeper gone

Decode first, aim at pids, never at the decoder's name. The old pattern kill, pkill -f 'base64 -d', is gone from this page because testing showed it kills innocent long-lived decoders: the pattern matches the decoder's command line, not malice. The innocent decoder from that test survived this pid-scoped procedure. The [s]leep bracket guard stays.

Before the files go, scope the incident: persistence, timeline, ownership.

bash
$ ls -la /tmp/gh011/                                   # the decoded command named this dir; list all of it, dots included
$ stat -c '%y %U %n' /tmp/gh011/.marker                # when it arrived, who owns it
$ crontab -l 2>/dev/null; systemctl --user list-timers --all 2>/dev/null | head  # persistence
$ grep -rl 'gh011' ~/.bashrc ~/.profile /etc/cron* 2>/dev/null                  # launch hooks

In this lab the order was only a pipeline, and pipelines die when their processes do. On a real box, the sweep above decides whether it was only a pipeline: the decoded command tells you what it did, not what else is scheduled.

bash
$ rm -rf /tmp/gh011; ls /tmp/gh011 2>/dev/null || echo "lab directory gone"
lab directory gone
Detection verified

One grep on the decoder's shape found the sealed order; one decode read it. The defender never needed to recognize the payload's word, because the payload's word never appeared. Read the decoded form, not the typed form, and the envelope opens every time.

05

Countermeasures

DEFENSE

Three moves, in order: take it down, watch for its shape, narrow the stage. Each is one way, not the way.

1

Mitigate: decode, then kill by PID

Decode first, so you know what you are killing; then kill the wrapper by its pid and the payload by the name the decoded command gave you, and remove the lab. The pattern kill is gone from this page because testing showed pkill -f 'base64 -d' kills innocent long-lived decoders: the pattern matches the decoder's command line, not malice. It is an ordinary unprivileged pipeline. Nothing here needs root to remove.

bash
$ echo 'dG91Y2ggL3RtcC9naDAxMS8ubWFya2VyOyBzbGVlcCA5MDA=' | base64 -d
touch /tmp/gh011/.marker; sleep 900
$ WPID=$(pgrep -f 'base64 -d' | head -1); echo "wrapper pid=$WPID"
wrapper pid=4
$ kill "$WPID"; sleep 0.5; kill -0 "$WPID" 2>/dev/null || echo "wrapper gone"
wrapper gone
Terminated
$ pkill -f '[s]leep 900'; sleep 0.5; pgrep -af 'sleep 900' || echo "sleeper gone"
sleeper gone
$ rm -rf /tmp/gh011; ls /tmp/gh011 2>/dev/null || echo "lab directory gone"
lab directory gone
2

Monitor: log the process creations

Process-creation logging with full command lines (auditd execve rules) catches the sealed order at birth: the wrapper's command line, blob included, is on record before it can run. D3FEND names the heavier forms Script Execution Analysis (D3-SEA) and Executable Allowlisting (D3-EAL): analyze what the script does as it runs, and authenticate files before opening them. The mapping is honest about its edges: the D3FEND 1.6.0 release carries no defender specific to the .010 sub-technique, so these two are the grounded best-practice pair for this shape, not claimed .010 defenders.

Honest limit. Command-line logging captures the typed form, so the sealed order lands in the log as gibberish. Without decode-at-collection or an EDR that resolves the decoded tree, the log becomes a haystack of blobs and the reading cost falls on the human. An attacker can also stack encodings, base64 inside base64, or tr and xxd instead of base64. Each layer costs the defender one decode, and the layers never stop decoding; they only multiply the work.

3

Prevent: narrow what a shell may launch

Execution policy and interpreter allowlisting decide which binaries may run at all. Prevention does not remove decoding; it narrows what may execute the decoded output. Server builds drop interpreters they do not need. Verified on this platform: blocking base64 changes nothing while python3 and openssl ship, so the control is "few interpreters, all logged", never "no decoders".

The executable part: know your interpreters, log their launches.

bash
$ for b in python3 perl openssl base64; do command -v $b; done   # inventory what can decode here
/usr/bin/python3
/usr/bin/perl
/usr/bin/openssl
/usr/bin/base64
$ auditctl -a exit,always -F arch=b64 -S execve -F path=/usr/bin/base64 -k decoder-exec

Pair with decode-at-collection: the SIEM decodes base64-looking argv at ingest, so the analyst searches the decoded tree instead of opening envelopes by hand.

Honest limit. Allowlisting carries a usability cost: every unlisted script, installer, and admin one-liner needs an exception. It does not stop an attacker who is already allowed to run a shell; it only narrows what the shell may launch. Blocking base64 does not block the idea: tr, xxd, and python -c all decode. The first principle outlives every control: read the decoded form, not the typed form.

Countermeasures verified

The sealed order is an ordinary pipeline, so killing it is trivial. Full command-line logging catches the decoder's shape at birth, and interpreter allowlisting narrows the stage it runs on. None of them reads the blob; the defender still opens every envelope by hand. That is the honest division of labor: automation finds the shape, the human decodes it.

06

Debrief

TAKEAWAY

An obfuscated command still has to be decoded before it runs, so the defender never reads the typed form; the defender reads the decoded form.

IOC checklist: signs this technique was used

  • Process lines containing base64 -d, tr, eval, or a python3 -c base64 decode chained into a shell
  • Long base64-looking blobs inside sh -c command lines
  • A long-lived process like sleep whose command line is a single unreadable blob
  • Process-creation logs where the typed form is encoded but the decoded tree was never resolved
  • Marker-style artifacts, files touched in /tmp, paired with unreadable command lines

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, x86-64, on 2026-09-19
  • Both recordings are real executions on that platform, not simulations
  • The attack runs fully unprivileged: any user can pipe base64 into sh
  • Cleanup: kill the wrapper by PID (confirm the sealed order in /proc/<pid>/cmdline first), the payload with pkill -f '[s]leep 900', then rm -rf /tmp/gh011. Never pkill -f 'base64 -d': the pattern matches innocent decoders too

Sources

MITRE ATT&CK T1027.010: Command Obfuscation
base64(1) (the encoding and its -d flag)
ps(1) (the process table the demo greps)
MITRE D3FEND: D3-SEA, D3-EAL (the mapping carries no .010-specific defender; these are the grounded pair)

Next file

GH-012 The Exact Address

A hostile file can wear a legitimate name in a legitimate place. The next file runs that case, and shows where the trust stops.