How to Read Binary Files Without Running Them

A .wasm from a vendor, a binary from a container, a pprof dump, a font with no license sheet. What their headers and tables state, and how to read each one safely in the browser.

By · · Updated · 9 min read

Illustration for the WASM Module Inspector guide

A file lands on your machine that you are not going to run: a .wasm from a vendor, a binary pulled out of a container image, a profile.pb.gz attached to an incident ticket, a font whose license nobody can find. Every one of these carries its own answers in its first kilobytes, because binary formats describe themselves to their loaders, and a parser can read that description without executing anything. The four tools in this guide, the WASM Module Inspector, pprof Profile Analyzer, Executable File Inspector and Font File Inspector, read those headers and tables in your browser, so the file never leaves your machine and never gets a chance to run.

Magic bytes: the first four bytes decide everything

Each format opens with a signature its tooling checks before anything else. 7F 45 4C 46 is ELF, per the System V gABI. FE ED FA CE or FE ED FA CF is Mach-O, and CA FE BA BE opens a macOS universal binary, with the caveat that Java class files start with the same four bytes; the next field disambiguates, because a fat binary has a tiny architecture count where a class file has its version. 4D 5A ("MZ") is a Windows PE, whose real signature sits wherever the pointer at offset 0x3C says. 00 61 73 6D ("\0asm") is WebAssembly. 1F 8B is gzip, which for this guide usually means a pprof profile. Fonts declare 00 01 00 00, OTTO or ttcf.

The first bytes of each format: ELF, Mach-O, universal binaries, PE, WebAssembly, gzipped pprof and OpenType fonts, with the Java class file collision called out
The first bytes of each format: ELF, Mach-O, universal binaries, PE, WebAssembly, gzipped pprof and OpenType fonts, with the Java class file collision called out

The practical rule: identify first, then parse with the matching tool. A wrong guess fails loudly at a named offset; a right one reads every structure cleanly. For bytes nothing recognises, the Binary Hex Editor shows the raw dump, and for 50 4B archives the ZIP File Inspector lists contents without extracting, covered in the binary formats guide.

WebAssembly: the import table is the contract

A .wasm module is a preamble plus numbered sections: types, imports, functions, memory, exports, code, data, with custom sections carrying names and debug info. The WebAssembly Core Specification defines memory in pages of exactly 65536 bytes, and the optional name section's subsection 0 holds the module name, which release builds usually strip.

Drop the WASM Module Inspector's built-in sample (press Load a sample) and the 77-byte module reads: module "demo", 2 functions (1 imported), 1 export, memory 1 page (64.0 KiB) growable to 4 pages (256 KiB). The sorted section table shows where the bytes went, custom "name" 12 B down to function 2 B, which scales directly to the 2 MB production question of whether a fat module is code, data or strippable metadata.

The table to read first is imports. Each entry is a module.name pair the host must supply, and instantiation throws a LinkError if one is missing, so the imports table is the integration spec for any blob a vendor hands you. The flip side is exports: what you can actually call. One warning flag matters for untrusted modules: a start section means code runs at instantiation itself, before you invoke anything.

pprof profiles: the top table without the toolchain

A pprof file is a gzip-compressed profile.proto message; the proto file itself requires gzip on disk, and Go's runtime/pprof writes exactly that format. Inside are sample types (cpu/nanoseconds, inuse_space/bytes), stacks stored leaf first, and one deduplicated string table whose first entry must be empty, which is how a parser tells pprof from random varints.

The pprof Profile Analyzer gunzips the file in the browser and prints the go tool pprof top view. On its built-in sample, two CPU samples over a 10.0s window total 10.0ms of cpu: main.hot shows 10.0ms flat and 10.0ms cum because it is the leaf of both stacks, while main.caller shows 0 flat and 3.0ms cum because it only ever appears above main.hot. That pair is the whole flat-versus-cum concept: flat is time in the function itself, cum is the function plus everything it calls, so high cum with no flat marks a dispatcher whose children do the work.

Two honest limits. First, the table ranks by the last sample type, which is the default profile.proto tells clients to use; a heap profile's other types still show in the totals. Second, flame graphs are out of scope here on purpose: go tool pprof -http=:8080 profile.pb.gz renders flame, graph and source views interactively, and a browser page should be the triage step, not a worse copy. Note also what does not produce pprof: py-spy writes flamegraph, speedscope, raw and chrometrace outputs, and async-profiler writes collapsed, flame graph, tree, text, JFR and OTLP, so files from those need their own viewers.

Executables: identity, dependencies and shape from headers

The questions that headers settle are the ones that block deployments: which architecture, 32 or 64 bit, executable or library, and what must exist on the target machine. The Executable File Inspector reads all three families. Its sample, a minimal 512-byte ELF64, reports x86_64, 64-bit little-endian, executable, entry point 0x401000, linking libc.so.6, with a 512 B LOAD and a 64 B DYNAMIC segment. That library name is a DT_NEEDED entry resolved through the dynamic string table, the same walk the runtime loader performs, which is why the list predicts "cannot open shared object file" errors before they happen.

Each format keeps its dependency list somewhere different: ELF in DT_NEEDED entries, Mach-O in one LC_LOAD_DYLIB load command per library, PE in the import directory of its data directory table. And each has a reading worth knowing. ELF type 3 is officially "shared object", but position-independent executables use the same type, so the label alone does not make a file a library. An ELF with no .symtab section is what "stripped" means, while the separate dynamic symbol table keeps imports working. A Mach-O's LC_BUILD_VERSION command states the minimum OS, the field behind "requires macOS 13" launch errors, and a universal binary is one CAFEBABE container holding a full Mach-O per architecture. A PE sets bit 0x2000 of its characteristics when it is a DLL.

What headers cannot do is also worth saying plainly: no disassembly, no symbol listing, no signature verification, and a packed binary can arrange its sections to mislead. Identity and shape are safe facts to collect in a browser; intent is a sandbox-and-Ghidra question.

Fonts: the licensing switch lives in one field

Font files are table directories, and four tables answer almost every practical question. The Font File Inspector's sample is DejaVu Sans Bold, the font this site's own PDF reports embed: 6,196 glyphs (maxp), 2048 units per em (head), weight class 700 (OS/2), 5,367 characters mapped (cmap), embedding installable. The gap between 6,196 glyphs and 5,367 characters is normal, because ligatures, alternates and components are glyphs no character points to.

Where DejaVu Sans Bold's 689 KiB goes: glyf outlines dominate at 508 KiB, followed by post glyph names at 59.8 KiB and GPOS positioning at 34.1 KiB
Where DejaVu Sans Bold's 689 KiB goes: glyf outlines dominate at 508 KiB, followed by post glyph names at 59.8 KiB and GPOS positioning at 34.1 KiB

The field with legal weight is fsType in the OS/2 table. Value 0 grants installable embedding, the OpenType spec's most permissive level: embed freely, even install permanently on the receiving system. Bit 1 is Restricted License embedding, a font that must not be modified, embedded or exchanged without the owner's permission, and PDF and Office exporters check it; a failing font export is usually this bit, not the exporter. Between the extremes sit preview-and-print and editable embedding, and separate bits can forbid subsetting or restrict embedding to bitmaps. The per-table byte sizes answer the other recurring question, web font weight: in the DejaVu example the outlines (glyf, 508 KiB) dominate, but nearly 60 KiB of post-table glyph names and 15 KiB of license prose in the name table are exactly what subsetters strip. WOFF and WOFF2 wrap these same tables in zlib and Brotli compression respectively, so the inspector names them and asks for the decompressed TTF/OTF instead of misreading them.

Tools for this job

  • WASM Module Inspector: sections with sizes, imports and exports by kind, memory pages and the module name from a .wasm file.
  • pprof Profile Analyzer: sample types, duration and the top functions by flat and cum from a profile.pb.gz, gunzipped in the browser.
  • Executable File Inspector: architecture, bit width, file type, linked libraries, segments and entry point for ELF, Mach-O and PE.
  • Font File Inspector: names, glyph and character counts, weight class, embedding permissions and per-table sizes for TTF, OTF and TTC.
  • Binary Hex Editor: the raw byte view for files none of the parsers accept.
  • ZIP File Inspector: the same header-first treatment for archives, JARs and APKs, with extraction-risk warnings.

Related reading: decoding binary payloads without a schema for protobuf, MessagePack and CBOR, analyzing HAR, GC logs and SQLite files for the log-shaped half of debugging artifacts, and triaging pcap captures and Arrow files for network captures and columnar data files.

Frequently asked questions

Is inspecting a binary file the same as running it?

No. These inspectors decode structures from a byte array: nothing is executed, instantiated, linked or rendered. That is why reading headers is a safe first step for files you distrust. The limits are real too: static header facts cannot tell you what code would do, only what the file claims to be.

Why read files in the browser instead of using the native tools?

The native tools are better when you have them: readelf, otool, dumpbin, wasm-objdump, go tool pprof. The browser versions exist for the machine that has none installed, the locked-down laptop, or the file too sensitive to upload to a random converter site. Local parsing means the bytes stay in the tab.

Can these tools tell me whether a file is malicious?

No, and a tool that claims to is overselling. Headers give identity: format, architecture, dependencies, shape. Malice is behavior, which takes sandboxed dynamic analysis and real reverse-engineering tooling. What header reading does prevent is the category error of running something to find out what it is.

What should I try when none of the inspectors accept a file?

Check the first bytes in a hex editor against the signatures above. Common surprises: a gzip layer around the real payload (1F 8B), a ZIP wearing another extension (50 4B), a WOFF2 that needs decompressing to TTF first, or a WebAssembly component where a core module was expected. The refusal messages name these cases when the parsers meet them.

Sources and further reading

  • WebAssembly Core Specification: Modules (binary format), WebAssembly Community Group. The magic, version and section encodings, with the name section in the appendix.
  • profile.proto, google pprof project on GitHub. The profile message: sample types, leaf-first stacks, the string table and the gzip requirement.
  • pprof user documentation, google pprof project on GitHub. Flat and cum definitions and the -http web interface with flame graphs.
  • System V gABI: ELF header, SCO. The class, data, type and machine tables the ELF reading follows.
  • mach-o/loader.h, Apple xnu sources on GitHub. Mach-O magics, file types and the load commands for libraries, entry and build version.
  • PE Format, Microsoft. The 0x3C pointer, COFF header, optional header and import directory.
  • OpenType specification: OS/2 table, Microsoft Typography. usWeightClass and the fsType embedding permission bits.

Open the WASM Module Inspector

More Debugging

Every tool in the Debugging section, free and in your browser.