PE executables
Inspect PE, ELF and Mach-O executables for malware triage without ever running them
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/pe/index.md to help me query PE executables with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Inspect an executable before running it
Reads a public sample executable as data; it does not execute the file.
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SET VARIABLE sample_binary = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT pe.main.binary_format(getvariable('sample_binary')) AS format, pe.main.machine(getvariable('sample_binary')) AS architecture, round(pe.main.overall_entropy(getvariable('sample_binary')), 3) AS entropy;
| format | architecture | entropy |
|---|---|---|
| PE | X86_64 | 5.444 |
Quick start
Choose where to run PE executables, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'pe' AS pe (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-pe-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'pe' AS pe (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-pe:0.5.0'
);
3. Run a query
SET VARIABLE sample_binary = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT pe.main.binary_format(getvariable('sample_binary')) AS format, pe.main.machine(getvariable('sample_binary')) AS architecture, round(pe.main.overall_entropy(getvariable('sample_binary')), 3) AS entropy;
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'pe' AS pe
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SET VARIABLE sample_binary = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT pe.main.binary_format(getvariable('sample_binary')) AS format, pe.main.machine(getvariable('sample_binary')) AS architecture, round(pe.main.overall_entropy(getvariable('sample_binary')), 3) AS entropy;
Query Farm operates PE executables for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use pe as the catalog alias for the query below.
4. Run a query
SET VARIABLE sample_binary = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT pe.main.binary_format(getvariable('sample_binary')) AS format, pe.main.machine(getvariable('sample_binary')) AS architecture, round(pe.main.overall_entropy(getvariable('sample_binary')), 3) AS entropy;
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'pe' AS pe (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-pe-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'pe' AS pe (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-pe:0.5.0'
);
Overview
Defensive malware-triage worker: static, read-only analysis of PE/ELF/Mach-O executables as SQL functions (the binary is never executed)

Static, read-only malware triage and binary forensics over Apache Arrow — parse Windows PE, Linux ELF, and macOS Mach-O executables and query their format, architecture, entropy, imports, exports, sections, and strings directly from DuckDB SQL.
The pe catalog turns static binary analysis into ordinary SQL. It is built for malware analysts, incident responders, threat hunters, reverse engineers, and anyone running build-provenance or binary-corpus checks at scale. Instead of shelling out to a pile of command-line tools and stitching their output together, you ATTACH this worker and SELECT the facts you need — across thousands of samples — with the full power of joins, filters, and aggregation. Every input is treated as untrusted and possibly hostile: the worker only reads and describes the bytes. It NEVER executes the sample and never resolves an external reference, and malformed, truncated, or non-binary input degrades cleanly to NULL (scalars) or no rows (table functions) rather than crashing or hanging.
Cross-format parsing is powered by LIEF (Library to Instrument Executable Formats), a permissive Apache-2.0 library that reads PE, ELF, and Mach-O through one consistent API. See the LIEF source on GitHub and the LIEF documentation for format details. The worker wraps LIEF in total, crash-proof extractors and exposes them as Arrow-native DuckDB functions; bounds on input size, string counts, and row counts keep even adversarial "bomb" inputs from exhausting memory.
The catalog exposes two shapes of query. Per-binary facts answer a single question about a sample — its container format and CPU architecture, its entry point, whether it is code-signed, its build timestamp and import-hash fingerprint, and its whole-file entropy — so they slot directly into a projection or a filter and scale across an entire corpus. Set-returning functions expand one binary into many rows — its per-section layout with entropy, its imported and exported symbols, and its printable strings — for row-level IOC hunting, filtering, and joining. Every function accepts the binary as either a filesystem path it opens or raw bytes passed inline, so you can analyze files on disk or blobs already living in a table, and each pairs its narrative with runnable, tested example queries. Static analysis only — the binary is never executed.
Catalog
Everything pe exposes once attached — read straight from the worker's
released build.
main 1 table · 12 functions
Binary-analysis functions: format/architecture, entry point, signing, entropy, imphash, sections, imports, exports, and strings over PE/ELF/Mach-O input
Schema examples (11)
Browse the worker's analysis catalog before owning a binary.
SELECT name, kind, formats FROM pe.main.analyses ORDER BY kind, name;
Detect the executable container format of a sample.
SELECT pe.main.binary_format((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
Read the target CPU architecture of a sample.
SELECT pe.main.machine((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho')));
Compute whole-file entropy as a packing/encryption signal.
SELECT round(pe.main.overall_entropy((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'))), 3) AS file_entropy;
7 more examples
Fingerprint a PE by its import hash for clustering.
SELECT pe.main.imphash((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
Rank a sample's sections by per-section entropy.
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT name, entropy FROM pe.main.sections(getvariable('bin')) ORDER BY entropy DESC;
List the first imported symbols of a sample.
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT library, function FROM pe.main.imports(getvariable('bin')) LIMIT 10;
Extract long printable strings for IOC hunting.
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT seq, value FROM pe.main.strings(getvariable('bin'), min_len := 8) LIMIT 10;
Triage a set of files in one pass (read_blob also takes a folder glob such as 'samples/*'): container format, CPU architecture, code-signing, section count and whole-file entropy per file (a non-executable such as garbage.bin comes back all-NULL instead of failing the query).
SELECT filename, pe.main.binary_format(content) AS container,
pe.main.machine(content) AS arch, pe.main.is_signed(content) AS signed,
pe.main.section_count(content) AS n_sections,
round(pe.main.overall_entropy(content), 2) AS file_entropy
FROM read_blob(['https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/garbage.bin'])
ORDER BY filename;
Localize the densest content of a sample: the sections whose entropy exceeds the file's own whole-file entropy (for hello.exe, `.text` and the `/19` debug section at ~5.9-6.0 bits/byte against a 5.44 baseline).
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
WITH baseline AS (SELECT pe.main.overall_entropy(getvariable('bin')) AS file_entropy) SELECT s.name, round(s.entropy, 3) AS entropy, round(b.file_entropy, 3) AS file_entropy FROM pe.main.sections(getvariable('bin')) AS s, baseline AS b WHERE s.entropy > b.file_entropy ORDER BY s.entropy DESC;
Cluster a folder of PE samples by import hash and show each cluster's size, build-time span and member files (non-PE files have no imphash and are skipped; the sample set holds a single PE, so it yields one cluster).
SELECT pe.main.imphash(content) AS imphash, count(*) AS samples,
min(pe.main.compile_timestamp(content)) AS first_built,
max(pe.main.compile_timestamp(content)) AS last_built,
list(filename ORDER BY filename) AS files
FROM read_blob(['https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/garbage.bin'])
WHERE pe.main.imphash(content) IS NOT NULL
GROUP BY 1
ORDER BY samples DESC, imphash;
analyses
Browsable registry of every analysis (scalar/table) this worker exposes (discovery table).
List the scalar analyses (one value per binary) in category order.
SELECT name, category, result
FROM pe.main.analyses
WHERE kind = 'scalar'
ORDER BY category, name;
Which analyses are PE-only?
SELECT name FROM pe.main.analyses WHERE formats = 'PE only' ORDER BY name;
Count analyses by kind.
SELECT kind, count(*) AS n
FROM pe.main.analyses
GROUP BY kind
ORDER BY kind;
binary_format (binary VARCHAR) +1 overload
Executable format ('PE'/'ELF'/'MachO') of a binary (VARCHAR path), or NULL
binary_format(binary VARCHAR) → VARCHARbinary_format(binary BLOB) → VARCHAR
Detect the executable format of a Linux ELF sample (returns 'ELF')
SELECT pe.main.binary_format((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf')));
Detect the executable format of a Windows PE sample's bytes
SELECT pe.main.binary_format((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
Triage a set of files in one pass (read_blob also takes a folder glob such as 'samples/*'): container format, CPU architecture, code-signing, section count and whole-file entropy per file (a non-executable such as garbage.bin comes back all-NULL instead of failing the query).
SELECT filename, pe.main.binary_format(content) AS container,
pe.main.machine(content) AS arch, pe.main.is_signed(content) AS signed,
pe.main.section_count(content) AS n_sections,
round(pe.main.overall_entropy(content), 2) AS file_entropy
FROM read_blob(['https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/garbage.bin'])
ORDER BY filename;
compile_timestamp (binary VARCHAR) +1 overload
PE build timestamp (TimeDateStamp) of a binary (VARCHAR path); NULL for ELF/Mach-O
compile_timestamp(binary VARCHAR) → TIMESTAMPcompile_timestamp(binary BLOB) → TIMESTAMP
Build year of a Windows PE sample, from its compile timestamp
SELECT year(pe.main.compile_timestamp((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')))) AS build_year;
PE compile timestamp of a Windows PE sample
SELECT pe.main.compile_timestamp((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
entry_point (binary VARCHAR) +1 overload
Entry-point virtual address of a binary (VARCHAR path), or NULL
entry_point(binary VARCHAR) → UBIGINTentry_point(binary BLOB) → UBIGINT
Entry-point address of a Linux ELF sample
SELECT pe.main.entry_point((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf')));
Entry-point address of a Windows PE sample
SELECT pe.main.entry_point((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
imphash (binary VARCHAR) +1 overload
PE import hash (for clustering) of a binary (VARCHAR path); NULL for ELF/Mach-O
imphash(binary VARCHAR) → VARCHARimphash(binary BLOB) → VARCHAR
Check whether a PE sample's import hash matches a known cluster's imphash
SELECT pe.main.imphash((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'))) = '7ff113ca9631a5215fdc9b66c067ad8f' AS in_known_cluster;
Import hash of a Windows PE sample
SELECT pe.main.imphash((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
Cluster a folder of PE samples by import hash and show each cluster's size, build-time span and member files (non-PE files have no imphash and are skipped; the sample set holds a single PE, so it yields one cluster).
SELECT pe.main.imphash(content) AS imphash, count(*) AS samples,
min(pe.main.compile_timestamp(content)) AS first_built,
max(pe.main.compile_timestamp(content)) AS last_built,
list(filename ORDER BY filename) AS files
FROM read_blob(['https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho', 'https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/garbage.bin'])
WHERE pe.main.imphash(content) IS NOT NULL
GROUP BY 1
ORDER BY samples DESC, imphash;
is_signed (binary VARCHAR) +1 overload
True if a binary (VARCHAR path) carries a code signature (PE Authenticode / Mach-O)
is_signed(binary VARCHAR) → BOOLEANis_signed(binary BLOB) → BOOLEAN
Whether a macOS Mach-O sample is code-signed (true: it carries an ad-hoc signature)
SELECT pe.main.is_signed((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho')));
Whether a Windows PE sample is code-signed (false: it has no Authenticode signature)
SELECT pe.main.is_signed((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
machine (binary VARCHAR) +1 overload
Architecture of a binary (VARCHAR path), e.g. 'X86_64'/'ARM64', or NULL
machine(binary VARCHAR) → VARCHARmachine(binary BLOB) → VARCHAR
Architecture of a macOS Mach-O sample (returns 'ARM64')
SELECT pe.main.machine((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho')));
Architecture of a Windows PE sample
SELECT pe.main.machine((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
overall_entropy (binary VARCHAR) +1 overload
Shannon entropy (bits/byte, 0-8) of a binary (VARCHAR path); high => packed/encrypted
overall_entropy(binary VARCHAR) → DOUBLEoverall_entropy(binary BLOB) → DOUBLE
Whole-file entropy of a mostly zero-padded Mach-O sample (a low value, about 0.34)
SELECT round(pe.main.overall_entropy((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho'))), 2) AS file_entropy;
Whole-file entropy of a Windows PE sample
SELECT pe.main.overall_entropy((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
section_count (binary VARCHAR) +1 overload
Number of sections in a binary (VARCHAR path), or NULL
section_count(binary VARCHAR) → INTEGERsection_count(binary BLOB) → INTEGER
Section count of a Linux ELF sample
SELECT pe.main.section_count((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_elf')));
Section count of a Windows PE sample
SELECT pe.main.section_count((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')));
exports (binary VARCHAR) +1 overload
Exported symbols (name, address) of a binary (VARCHAR path)
exports(binary VARCHAR)exports(binary BLOB)
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho'));
SELECT name, address FROM pe.main.exports(getvariable('bin')) ORDER BY name;
imports (binary VARCHAR) +1 overload
Imported symbols (library, function) of a binary (VARCHAR path)
imports(binary VARCHAR)imports(binary BLOB)
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT library, function FROM pe.main.imports(getvariable('bin')) ORDER BY library, function LIMIT 10;
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT library, count(*) AS n_functions FROM pe.main.imports(getvariable('bin')) GROUP BY library ORDER BY n_functions DESC;
sections (binary VARCHAR) +1 overload
Per-section (name, virtual_size, raw_size, entropy, flags) of a binary (VARCHAR path)
sections(binary VARCHAR)sections(binary BLOB)
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT name, entropy FROM pe.main.sections(getvariable('bin')) ORDER BY entropy DESC LIMIT 5;
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT name, virtual_size, raw_size, round(entropy, 3) AS entropy FROM pe.main.sections(getvariable('bin')) ORDER BY entropy DESC LIMIT 5;
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT name, round(entropy, 3) AS entropy FROM pe.main.sections(getvariable('bin')) WHERE entropy > 5.5 ORDER BY entropy DESC;
1 more example
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
WITH baseline AS (SELECT pe.main.overall_entropy(getvariable('bin')) AS file_entropy) SELECT s.name, round(s.entropy, 3) AS entropy, round(b.file_entropy, 3) AS file_entropy FROM pe.main.sections(getvariable('bin')) AS s, baseline AS b WHERE s.entropy > b.file_entropy ORDER BY s.entropy DESC;
strings (binary VARCHAR, min_len := INTEGER) +1 overload
strings(binary VARCHAR, min_len INTEGER)strings(binary BLOB, min_len INTEGER)
Extract printable strings from raw BLOB bytes (no file needed)
SELECT seq, value
FROM pe.main.strings('\x00\x01demo payload: printable ASCII recovered straight from a BLOB\x00\xFFcmd.exe /c whoami\x00\x02http://example.invalid/beacon\x00ok\x00'::BLOB, min_len := 5)
ORDER BY seq;
Count the strings of at least 12 characters in a BLOB
SELECT count(*) AS long_strings
FROM pe.main.strings('\x00\x01demo payload: printable ASCII recovered straight from a BLOB\x00\xFFcmd.exe /c whoami\x00\x02http://example.invalid/beacon\x00ok\x00'::BLOB, min_len := 12);
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT seq, value FROM pe.main.strings(getvariable('bin'), min_len := 8) ORDER BY seq LIMIT 5;
1 more example
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT DISTINCT value FROM pe.main.strings(getvariable('bin')) WHERE lower(value) LIKE '%.dll' ORDER BY value;
Try these queries
Browse the worker's analysis catalog before owning a binary.
SELECT name, kind, formats FROM pe.main.analyses ORDER BY kind, name
Uses analyses
Detect the executable container format of a sample.
SELECT pe.main.binary_format((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')))
Uses binary_format
Read the target CPU architecture of a sample.
SELECT pe.main.machine((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello_macho')))
Uses machine
Compute whole-file entropy as a packing/encryption signal.
SELECT round(pe.main.overall_entropy((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'))), 3) AS file_entropy
Uses overall_entropy
Fingerprint a PE by its import hash for clustering.
SELECT pe.main.imphash((SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe')))
Uses imphash
Rank a sample's sections by per-section entropy.
SET VARIABLE bin = (SELECT content FROM read_blob('https://raw.githubusercontent.com/Query-farm/vgi-pe/v0.4.0/test/sql/data/hello.exe'));
SELECT name, entropy FROM pe.main.sections(getvariable('bin')) ORDER BY entropy DESC
Uses sections
31 more examples in the Catalog, each listed under the table or function it uses.
PE executables is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Disassembler
Security & forensics
Disassemble binaries and shellcode, then triage their sections, imports, strings, and MITRE ATT&CK capabilities
Secret scanning
Security & forensics
Find leaked API keys, tokens and private keys in text from SQL, offline and with redacted output
CVE
Security & forensics
Look up CVE records, flag known-exploited CVEs, score exploit likelihood, find open-source package advisories, and compute CVSS v3.1 scores