Strings as Evidence: Extracting Indicators
Strings and Entropy showed how strings finds readable text in a binary, in ASCII and in UTF-16. For a reverse engineer, strings are clues to the code. For a malware analyst under time pressure, they are something more immediate: candidate indicators that the detection team can search for within the hour. A URL, a domain, an IP address, a registry path, a mutex name, a user agent, a file name dropped in %TEMP%: each can be grepped in proxy logs, DNS logs and EDR telemetry across the whole organisation. This lesson turns a raw strings dump into a short, classified, defanged list of indicators, and shows why that list must be checked by a human.
Definitions
- Indicator of compromise (IOC): an observable artefact that, seen on a system or network, suggests that the system was compromised. Types: file hashes, file names and paths, registry keys and values, mutexes, network indicators (IP addresses, domains, URLs, user agents, certificate hashes), and more (IOC types).
- Network indicators: the most actionable from strings, because proxy, DNS and firewall logs can be searched for them at once.
- Host indicators: paths, registry keys, mutexes, service and task names: searched with EDR or forensic tools.
- Noise: strings that are present in almost every program (library names, compiler messages, standard API names,
This program cannot be run in DOS mode). They must be filtered, or they drown the signal. - FLOSS (FLARE Obfuscated String Solver): extracts static strings and also decodes stack strings and simple encoded strings by emulating the code. Use it on real Windows samples; it is part of FLARE-VM and REMnux.
From a strings dump to an indicator list
The example builds a synthetic "sample": a blob with a PE-like header, the usual library noise, ASCII and UTF-16LE strings that look like a configuration, and random bytes. Every network name is under lab.test and every address is in the lab or documentation ranges. The code extracts strings in both encodings, classifies them with regular expressions, removes noise, and prints defanged indicators for the ticket.
import re, random
r = random.Random(3)
def u16(s): return s.encode("utf-16-le") + b"\0\0"
blob = (b"MZ" + bytes(62) + b"This program cannot be run in DOS mode.\r\n" + r.randbytes(200)
+ b"KERNEL32.dll\0CreateFileW\0InternetOpenUrlA\0msvcrt.dll\0" + r.randbytes(150)
+ b"\0http://update.beacon.lab.test/api/v1/ping?id=%s\0" + r.randbytes(80)
+ b"Mozilla/5.0 (Windows NT 10.0; LabAgent/1.0)\0" + b"203.0.113.77\0" + r.randbytes(120)
+ u16(r"Software\Microsoft\Windows\CurrentVersion\Run") + u16("LabAgentUpdater")
+ u16(r"C:\Users\Public\Libraries\labagent.dat") + u16("Global\\LabAgent-Mutex-7f3a")
+ b"ops-backup@lab.test\0" + b"C:\\build\\labagent\\Release\\labagent.pdb\0" + r.randbytes(100))
def extract(data, n=6):
ascii_ = [m.group().decode() for m in re.finditer(rb"[\x20-\x7e]{%d,}" % n, data)]
wide = [m.group().decode("utf-16-le") for m in re.finditer(rb"(?:[\x20-\x7e]\x00){%d,}" % n, data)]
return ascii_, wide
PATTERNS = [ # (type, regex): first match wins
("url", r"^https?://[^\s\"']+quot;),
("email", r"^[\w.+-]+@[\w-]+(\.[\w-]+)+quot;),
("ipv4", r"^(\d{1,3}\.){3}\d{1,3}quot;),
("registry", r"^(HK(LM|CU)\\|Software\\)"),
("pdb path", r"\.pdbquot;),
("file path", r"^[A-Za-z]:\\"),
("mutex", r"^(Global|Local)\\"),
("user agent", r"^Mozilla/"),
]
NOISE = re.compile(r"^(This program cannot|\w+\.dll$|(CreateFile|ReadFile|WriteFile|CloseHandle)[AW]?$)")
ascii_, wide = extract(blob)
print(f"strings found: {len(ascii_)} ASCII, {len(wide)} UTF-16LE")
def defang(s): return re.sub(r"(?<=\w)\.(?=\w)", "[.]", s.replace("http", "hxxp", 1)).replace("@", "[@]")
for enc, items in (("ascii", ascii_), ("utf16", wide)):
for s in items:
kind = next((k for k, rx in PATTERNS if re.search(rx, s)), None)
if kind:
shown = defang(s) if kind in ("url", "email", "ipv4") else s
print(f" {kind:<10} [{enc}] {shown}")
elif NOISE.search(s):
continue
else:
print(f" {'review':<10} [{enc}] {s}")strings found: 10 ASCII, 4 UTF-16LE
review [ascii] InternetOpenUrlA
url [ascii] hxxp://update[.]beacon[.]lab[.]test/api/v1/ping?id=%s
user agent [ascii] Mozilla/5.0 (Windows NT 10.0; LabAgent/1.0)
ipv4 [ascii] 203[.]0[.]113[.]77
email [ascii] ops-backup[@]lab[.]test
pdb path [ascii] C:\build\labagent\Release\labagent.pdb
registry [utf16] Software\Microsoft\Windows\CurrentVersion\Run
review [utf16] LabAgentUpdater
file path [utf16] C:\Users\Public\Libraries\labagent.dat
mutex [utf16] Global\LabAgent-Mutex-7f3a
Read the result the way an analyst would:
- The URL and user agent go straight to the proxy team: search for requests to that host and for that user agent string.
- The IP address is a candidate, but might be a fallback, a decoy, or a DNS resolver; it needs context before it becomes a block.
- The Run key (UTF-16, as Windows API strings are) is a persistence location. The value name right after it,
LabAgentUpdater, is the host indicator to search for. - The mutex is a strong host indicator: malware uses a named mutex to avoid running twice, and its name is often constant across a family.
- The PDB path names the developer's build folder. It's useless for blocking, valuable for clustering samples by author.
- The
reviewitems (InternetOpenUrlA, the value name) are the ones no regular expression understands. That is what analysts are for.
How these indicators become detections
- Network: DNS and proxy searches for the domain and URL path, then a block at the resolver or proxy (an RPZ entry, a proxy deny rule), then alerts on any new hit.
- Host: an EDR query for the mutex, the file path and the Run value across all endpoints; a YARA rule for the configuration strings, which survives a changed hash.
- Retro-hunting: search logs back in time: the first hit tells you when the intrusion started.
How analysts keep the list trustworthy
- Record where each string was found (offset, encoding, which sample) and whether it was seen in behaviour too (the sandbox resolved that domain) or is static only.
- Mark confidence: a domain only in strings could be dead code or a decoy.
- Remove infrastructure that is shared or legitimate (CDNs, cloud storage, public resolvers,
windowsupdate.comused as a connectivity check) before anyone blocks it.
Pitfalls
- Missing UTF-16. Half of the interesting Windows strings are wide; always extract both encodings.
- Blocking from strings alone. Strings can be planted to mislead; a sample may contain a legitimate site to look normal.
- Format strings.
?id=%smeans the real request contains a value; search with wildcards, not the literal%s. - No strings at all is a finding: they are encoded or built at run time (decoding).
Practice
1. Which two strings in the output would you search for first in proxy logs?
The URL host and path (update.beacon.lab.test, /api/v1/ping) and the user agent LabAgent/1.0; both are what a proxy log records.
2. Add a pattern for domain names that are not part of a URL, and make sure it does not match KERNEL32.dll.
For example ("domain", r"^(?!.*\.(dll|exe|sys)$)([a-z0-9-]+\.)+[a-z]{2,}quot;), placed after url. The negative look-ahead excludes common file extensions; real tools use a list of top-level domains.
3. Why is the PDB path useful even though nobody can block it?
It names the build environment (C:\build\labagent\Release\), which tends to stay the same across an author's builds, so it links samples to one developer or toolkit and can be a YARA string.
Test yourself
Why should strings be extracted in UTF-16LE as well as ASCII from Windows samples?
- UTF-16 strings are always malicious
- The Windows API uses UTF-16, so registry paths, file paths and mutex names are often wide
- ASCII extraction is slower
- YARA cannot read ASCII
What is a named mutex typically used for by malware, and why is it a good indicator?
- To encrypt files; it changes every run
- To avoid running twice; its name is often constant across a family
- To store passwords
- To open network sockets
A domain appears in a sample's strings but was never contacted in the sandbox. How should it be recorded?
- As a confirmed C2 server to block immediately
- As a static-only candidate with lower confidence, pending more evidence
- It should be discarded
- As a known-good domain
What does FLOSS add over the plain strings tool?
- It runs the sample on the network
- It recovers stack strings and simply encoded strings by emulating code
- It computes fuzzy hashes
- It removes malware