Malware Analysis

Strings Extraction & Analysis

Extracting and analyzing strings from malware samples using the strings utility and FLOSS for deobfuscating encoded or obfuscated strings.

Contents

Strings Extraction & Analysis

Purpose: Extract human-readable text from binaries to discover URLs, file paths, commands, error messages, encryption keys, and other intelligence — without executing the binary.


1. Quick Commands

FLOSS (FireEye Labs Obfuscated String Solver) — Best Tool

# Basic extraction (includes deobfuscated strings)
floss fileName.exe

# Check the FLOSS static unicode strings at the bottom
# These often contain the most interesting artifacts

# Output to file for easier searching
floss fileName.exe > strings_output.txt

# Verbose mode (see decoding attempts)
floss -v fileName.exe

# Minimum string length (default is 4)
floss -n 8 fileName.exe

Traditional strings Command

# ASCII strings (default)
strings fileName.exe

# Unicode strings (Windows uses UTF-16LE)
strings -e l fileName.exe

# Both ASCII and Unicode
strings -a fileName.exe && strings -e l fileName.exe

# Set minimum length (reduce noise)
strings -n 8 fileName.exe

# With byte offset (useful for locating in hex editor)
strings -t x fileName.exe

2. FLOSS vs strings — Why FLOSS Wins

FeaturestringsFLOSS
ASCII stringsYesYes
Unicode stringsWith -e l flagAutomatic
Decoded/deobfuscated stringsNoYes
Stack strings (built char-by-char)NoYes
Tight strings (XOR decoded)NoYes
SpeedVery fastSlower (does emulation)
InstallPre-installedpip install floss or download binary

FLOSS uses emulation to actually execute string decoding routines, revealing strings that strings can never find.

Install FLOSS

# Via pip
pip install floss

# Or download binary from GitHub
# https://github.com/mandiant/flare-floss/releases

3. What to Look For in String Output

High-Value String Categories

CategoryExample StringsIntelligence
URLs / Domainshttp://evil.com/gate.php, api.telegram.orgC2 servers, exfil endpoints
IP Addresses192.168.1.100, 10.0.0.1:4444C2 IPs, callback addresses
File PathsC:\Users\Public\payload.dll, /tmp/.hiddenDrop locations
Registry KeysHKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunPersistence mechanisms
Commandscmd.exe /c, powershell -enc, whoami, net userExecution commands
API NamesVirtualAlloc, CreateRemoteThreadDynamic API resolution
DLL Nameskernel32.dll, ntdll.dll, ws2_32.dllLoaded libraries
Error MessagesConnection failed, File not foundDeveloper debug messages
Crypto Constants-----BEGIN RSA PUBLIC KEY-----Encryption usage
User AgentsMozilla/5.0..., Go-http-client/1.1HTTP fingerprint
Mutex NamesGlobal\MyMutex123Singleton check
Base64 BlobsSGVsbG8gV29ybGQ=Encoded payloads/configs
Passwords / Keysadmin:password123, AES_KEY=Hardcoded credentials
Developer ArtifactsC:\Users\dev\Desktop\malware\Attacker machine info

4. String Analysis Methodology

Step-by-Step Workflow

1. Run FLOSS on the sample
   └── floss sample.exe > floss_output.txt

2. Sort by categories using grep
   └── grep -iE "http|https|ftp|\.com|\.net|\.org" floss_output.txt
   └── grep -iE "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" floss_output.txt
   └── grep -iE "HKLM|HKCU|CurrentVersion|Run" floss_output.txt
   └── grep -iE "cmd|powershell|exec|system|shell" floss_output.txt
   └── grep -iE "password|credential|login|token|key" floss_output.txt

3. Decode any Base64 strings
   └── echo "SGVsbG8gV29ybGQ=" | base64 -d

4. Extract IOCs (Indicators of Compromise)
   └── IPs, domains, file hashes, mutex names, file paths

5. Cross-reference with threat intelligence
   └── VirusTotal, MalwareBazaar, OTX

Useful grep Patterns for Malware Analysis

# Network indicators
grep -oP 'https?://[^\s"<>]+' floss_output.txt
grep -oP '\b\d{1,3}(\.\d{1,3}){3}\b' floss_output.txt
grep -oP '\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' floss_output.txt

# Windows paths
grep -oP '[A-Z]:\\[^\s"]+' floss_output.txt

# Registry keys
grep -iP '(HKLM|HKCU|HKCR)\\[^\s"]+' floss_output.txt

# Base64 encoded strings (min length 20)
grep -oP '[A-Za-z0-9+/]{20,}={0,2}' floss_output.txt

# Potential encryption keys (hex strings)
grep -oP '\b[0-9a-fA-F]{32,}\b' floss_output.txt

5. Obfuscated Strings — What FLOSS Catches

Stack Strings

Malware builds strings one character at a time on the stack to avoid detection:

// In the binary (no complete strings visible to `strings`)
char s[20];
s[0] = 'c'; s[1] = 'm'; s[2] = 'd'; s[3] = '.';
s[4] = 'e'; s[5] = 'x'; s[6] = 'e'; s[7] = '\0';

FLOSS emulates this and recovers cmd.exe

XOR-Encoded Strings

char encoded[] = {0x2C, 0x37, 0x37, 0x30, 0x1A}; // XOR 0x5C = "http:"
for(int i=0; i<5; i++) encoded[i] ^= 0x5C;

FLOSS tries common XOR keys and recovers the plaintext

RC4 / Custom Encrypted Strings

More complex decryption routines — FLOSS emulates the decoder function to recover strings


6. Advanced String Techniques

Extract Strings from Specific PE Sections

# Only .rdata section (constants, string literals)
objdump -s -j .rdata malware.exe | strings

# Only .data section (global variables)
objdump -s -j .data malware.exe | strings

# Resource section (often contains payloads)
objdump -s -j .rsrc malware.exe | strings

String Diffing Between Samples

# Compare strings between two variants
floss variant_a.exe > strings_a.txt
floss variant_b.exe > strings_b.txt
diff strings_a.txt strings_b.txt

# Or use comm to find unique/common strings
sort strings_a.txt > a_sorted.txt
sort strings_b.txt > b_sorted.txt
comm -12 a_sorted.txt b_sorted.txt > common_strings.txt  # Shared
comm -23 a_sorted.txt b_sorted.txt > only_in_a.txt        # Unique to A

Strings in Memory Dumps

# Extract strings from a memory dump
strings -n 10 memory_dump.dmp > mem_strings.txt

# Search for specific patterns in memory
strings memory_dump.dmp | grep -iE "(password|http|cmd\.exe)"

ToolDescriptionUse Case
FLOSSDeobfuscating string solverPrimary tool for malware strings
stringsBasic string extractionQuick first pass
Bstrings (Eric Zimmerman)Enhanced strings for WindowsBetter Unicode, regex support
binwalkFirmware/embedded file analysisFind embedded files & strings
foremostFile carvingExtract files from binary blobs
yaraPattern matchingScan for known string signatures
StringSifterML-based string rankingPrioritize interesting strings

StringSifter — AI-Powered String Ranking

# Ranks strings by maliciousness likelihood
pip install stringsifter
floss sample.exe | rank_strings
# Output: most suspicious strings first

Pro Tips

Always run FLOSS, not just strings — You’ll miss 30-50% of interesting strings with the basic strings command.

Check FLOSS decoded strings section — The bottom section labeled “FLOSS decoded strings” and “FLOSS stack strings” contains the real gold — these are strings the malware tried to hide.

Pipe to less or save to file — Large binaries can have thousands of strings. Save output and search systematically.

Combine with entropy analysis — High-entropy sections with few strings = likely packed/encrypted. Low-entropy sections are worth deep string analysis.