A file the listing never shows is still a file. This file plants a payload in a dot-directory that plain ls walks past, then sweeps it out with the tools that never honored the convention.
MITRE ATT&CK T1564.001: adversaries hide files and directories from standard listings, most simply by giving them names the listing tools skip by convention. This file plants one such hiding place end to end, then takes the defender's side of the same directory.
Why this technique. The default directory listing is a courtesy, not a census. Every name that starts with a dot is left out of plain ls output, and attackers have used that courtesy as a hiding place for decades: staging directories, dropped payloads, persistence scripts, all sitting in plain sight of anyone who asks with the right flag and invisible to everyone who does not. The technique is not a bug in ls. It is the gap between what the tool promises, a formatted display of names, and what the operator assumes, a complete inventory of what is there.
Why not just always type ls -a. The obvious fix is to always add the flag and move on. Break it on a concrete input: a normal home directory already holds twenty or more dotfiles and dot-directories, .bashrc, .cache, .config, .local, and the attacker's .svc-data sits among them looking exactly as boring as the rest. ls -a answers which names exist but not which of them is running, and it cannot tell a payload from clutter. So the working move is to stop asking the display and start asking the system: find walks the directory tree at the filesystem level, where a leading dot is just another character, and pgrep asks the kernel's process table who is actually executing.
The mechanism, with terms earned. A dotfile is any name beginning with a period; the name is the whole trick, because the hiding lives in ls, not in the filesystem. The kernel's readdir returns every entry including the dotted ones, and ls filters its display by convention, a choice from the 1970s that stuck. A hidden directory is the same trick one level up: a container whose name keeps it out of the default view. Detached means the payload keeps running after the shell that started it moves on; here the & operator backgrounds it. The process table is the kernel's own list of running programs, exposed under /proc and queried with pgrep, which matches by name pattern instead of asking any listing tool for its opinion.
The concrete case, before the abstraction. /tmp/gh009 holds one visible file, notes.txt, and one hidden directory, .svc-data, containing sync.sh and the marker file it touched. Plain ls prints one name. ls -a prints four. find -name '.*' prints the two hidden paths by their real names. pgrep finds the sleeper by its command line. Four tools, four answers, and only the last two are asking the system instead of the display.
Scope. T1564 Hide Artifacts covers fourteen sub-techniques, from hidden files and directories (.001, this file) to alternate data streams and virtualization-based hiding. This file works the .001 case end to end on Linux: the dotfile convention, the listing that honors it, and the defender's filesystem-level sweep.
Ubuntu 24.04.5 LTS, bash 5.2, x86-64. No privilege needed, no network, no persistence: the payload touches one marker file inside its own lab directory and sleeps. The lab stands in for the payload with one hidden directory and one script.
One directory, one decoy file, one hidden directory, one script. The decoy, notes.txt, is the boring visible file the casual listing sees.
$ rm -rf /tmp/gh009; mkdir -p /tmp/gh009 && cd /tmp/gh009 && touch notes.txt
A fresh lab directory with the decoy inside, and the shell moved into it. Now the hidden directory and the payload.
$ mkdir .svc-data
$ cat > .svc-data/sync.sh <<'EOF' > #!/bin/sh > # GH-009 lab: benign stand-in for a hidden payload. > # Touches one marker file inside its own directory, then sleeps. > # Nothing else. No network, no persistence, no privilege. > touch .svc-data/.marker > sleep 900 > EOF
$ chmod +x .svc-data/sync.sh && ./.svc-data/sync.sh & [1] 11846
The [1] line is the shell confirming the background job and its process id. The payload is now detached: it touched its marker file and is sleeping. Nothing about the directory looks different to a casual glance, which is the entire attack.
Six lines. Every line glossed, because the whole technique lives in this file.
#!/bin/sh # GH-009 lab: benign stand-in for a hidden payload. # Touches one marker file inside its own directory, then sleeps. # Nothing else. No network, no persistence, no privilege. touch .svc-data/.marker sleep 900
Line by line. #!/bin/sh runs the file under the system shell. The comment lines say what the file is for; they do nothing. touch .svc-data/.marker creates the marker file: the only filesystem write the script ever makes, and the proof it actually executed. touch on a name that does not exist creates an empty file. sleep 900 keeps the process alive for fifteen minutes, 900 seconds, so the defender has something to find; it does nothing else. There is no network call, no cron entry, no startup script: when the process dies, nothing remains but the files, and the blue phase removes those too.
The payload is planted and sleeping. Now ask the directory what is in it, three different ways, and watch the answers disagree. Every command below is copy-pasteable.
Two commands, same directory, seconds apart.
$ ls notes.txt
One name: the decoy.
$ ls -a . .. .svc-data notes.txt
Four names. Nothing about the directory changed between the two commands; only the question changed. The -a flag tells ls to skip its dotfile courtesy and print everything readdir returned.
The hidden directory is not an idea; it holds files.
$ ls -a .svc-data/ . .. .marker sync.sh
.marker is the proof of execution: the script touched it when it started. sync.sh is the payload itself, sitting in the open for anyone who looks past the default view.
$ pgrep -af '[s]ync\.sh' 11849 /bin/sh ./.svc-data/sync.sh
The kernel's answer: one process, /bin/sh running ./.svc-data/sync.sh. pgrep matched the command line against the pattern; the [s] bracket keeps the pattern from matching pgrep's own command line.
The payload executed, wrote its marker, and persists as a running process, while the default listing shows a single boring text file. The hiding cost one leading dot.
The red phase asked the display. Now ask the defender's questions: what sees past the convention, how to stop the sleeper, and how to leave nothing behind. Every command below is copy-pasteable.
Here is the trap: treating the dotfile as a hostile artifact and hunting for dots. Dots are not hostile. Your own shell config lives in dotfiles. The hiding is not an object to find; it is a convention to stop trusting, and the fix is to ask tools that never honored it.
Triage that stops at the default listing closes the case here.
$ cd /tmp/gh009 && ls notes.txt
One boring text file. Case closed, and the payload keeps sleeping.
find does not know about the dotfile courtesy. It walks the tree and matches names at the filesystem level, where a leading dot is just another character. -name '.*' matches every name that starts with a dot; the quotes keep the shell from expanding the pattern before find sees it; sort orders the output.
$ find /tmp/gh009 -name '.*' | sort /tmp/gh009/.svc-data /tmp/gh009/.svc-data/.marker
Two hidden paths, by their real names. No flag on ls could have produced this list, because the hiding was never in the filesystem.
The process table never honored the convention either.
$ pgrep -af '[s]ync\.sh' 11849 /bin/sh ./.svc-data/sync.sh
Same sleeper, same command line.
$ pkill -f '[s]ync\.sh'
pkill signals by the same name match pgrep uses. The [s] bracket keeps pkill from matching its own command line and killing the shell that runs it.
$ pgrep -af '[s]ync\.sh' || echo "process gone" process gone
Empty output, and the echo confirms it: no matching processes. The sleeper is gone.
Files last. But before the files go, scope the incident: persistence, timeline, ownership. The four lines below decide whether this was one sleeper or a foothold.
$ ls -la /tmp/gh009/.svc-data/ # what is actually in the drawer $ stat -c '%y %U %n' /tmp/gh009/.svc-data/* # when it arrived, who owns it $ crontab -l 2>/dev/null; systemctl --user list-timers --all 2>/dev/null | head # persistence $ grep -rl 'svc-data' ~/.bashrc ~/.profile /etc/cron* 2>/dev/null # launch hooks
Rule: kill stops the bleeding; the four lines above decide whether the incident is one sleeper or a foothold. Only then rm -rf.
$ rm -rf /tmp/gh009; ls /tmp/gh009 ls: cannot access '/tmp/gh009': No such file or directory
rm -rf removes the whole tree, hidden names included, because rm never asked the display either. The ls error is the confirmation: no such file or directory. Nothing persists after the demo: no process, no files, no marker.
The filesystem-level sweep surfaced what the display hid, the process table named the sleeper, and the lab directory is gone.
Three moves, in order: stop trusting the display, watch the writes, decide what may run. Each is one way, not the way.
In triage, replace the listing with a walk, but narrow the walk. A raw find -name '.*' under $HOME returns hundreds of legitimate dotfiles, and comparing inherited working directories flags your own session, so the fleet form scopes the walk to world-writable and service dirs and compares command-line paths instead of inherited cwd. This is the fleet form of the blue phase: the idea does not change, only the coverage. This control clears the first-principles gate: it works because it rests on what the tools actually promise, not on what their output looks like.
$ for d in /tmp /var/tmp /dev/shm; do [ -d "$d" ] && find "$d" -name '.*' -newermt '7 days ago' 2>/dev/null done | sort /tmp/gh009/.svc-data /tmp/gh009/.svc-data/.marker
Second, the process-table half. Compare command-line paths, not inherited working directories, and keep your own session out of the results.
$ me=$$
$ for d in /proc/[0-9]*/; do
pid=${d#/proc/}; pid=${pid%/}
[ "$pid" = "$me" ] && continue
tr '\0' ' ' < "$d/cmdline" 2>/dev/null | grep -q '/\.[^/]*/' && echo "pid=$pid: $(tr '\0' ' ' < $d/cmdline)"
done
pid=5: sh ./.svc-data/sync.sh
Tested: the sweep listed the two hidden paths, and the process loop flagged the sleeper by its script path, while a raw cwd scan had flagged the operator's own shell. Good versus bad: good is a dot-directory with an old mtime and no process pointing into it (config, cache). Bad is a dot-directory with a fresh mtime, check with stat -c '%y %n', plus a live process whose command line references it. The fastest triage signal is the count disagreement from the IOC checklist: ls <dir> | wc -l against find <dir> -maxdepth 1 | wc -l.
Honest limit. A rootkit below /proc (T1014, named in step 3) defeats this loop, and a bind mount over the directory defeats find.
A hidden file is still a created file. File integrity monitoring (D3-FIM) notices a new file appearing in a watched directory regardless of its first character; the display convention is invisible at the layer FIM watches. Software inventory (D3-SWI) flags binaries that were never supposed to be on the machine, whatever their names start with. Production versions run in the EDR or auditd, not by hand; the principle is the same: watch the kernel's facts, not the display's.
The payload needed no privilege to hide; hiding is free, so prevention targets execution instead. Executable allowlisting means an unknown script dropped into a hidden directory never runs, whatever its name. Cheaper and closer to this file's lesson: nothing here persists unless something runs it, so the inventory that matters is the process table, taken regularly, not the directory listing. One executable form, verified: log every exec under the world-writable dirs. It is cheap and targeted; nobody watches all of /tmp by default, so say what you do watch.
$ auditctl -a exit,always -F arch=b64 -S execve -F dir=/tmp -k t1564-tmp-exec $ auditctl -a exit,always -F arch=b64 -S execve -F dir=/var/tmp -k t1564-tmp-exec $ ausearch -k t1564-tmp-exec --start recent | grep -E 'exe=.*tmp'
Honest limit: this logs executions, not the dot convention. Pair it with a weekly find /tmp /var/tmp /dev/shm -name '.*' -newermt '7 days ago' sweep. Allowlisting remains the durable control for servers that can carry it.
Honest limit. Every control above watches a layer the attacker can go under. A rootkit that hooks directory reads or hides processes from /proc, T1014, the subject of GH-002, hides from find and pgrep too. FIM sees the write only if it was already watching that path, and an allowlist is only as good as its list. This file teaches the layer beneath all of those: what your listing tools actually promise. A defender who knows ls is a display convention is never fooled by a leading dot. A defender who mistakes it for a census is.
The display is replaced by the walk, the writes are watched at the kernel's layer, and execution is decided by policy. None of them changes the core fact: a leading dot was never a lock, only a shut drawer.
A file the listing never shows is still a file: ls hides dotfiles by convention, not by enforcement, so triage asks the filesystem and the process table, never the display.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1564.001: Hidden Files and Directories
ls(1), find(1), pgrep(1), pkill(1)
D3FEND D3-FIM: File Integrity Monitoring, D3-SWI: Software Inventory: version 1.6.0 maps its T1564 defenders to the whole Hide Artifacts family; FIM and SWI are the two that add real coverage for the .001 case, so those are the ones wired here
A payload can ask whether a debugger is watching it run. The next file takes that question apart.