Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postject

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postject

Easily inject arbitrary read-only resources into executable formats (Mach-O, PE, ELF) and use it at runtime.

  • 1.0.0-dev-9054aa2
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
156K
increased by0.88%
Maintainers
3
Weekly downloads
 
Created
Source

postject

CircleCI

Easily inject arbitrary read-only resources into executable formats (Mach-O, PE, ELF) and use it at runtime.

Building

Prerequisites

Build Command

$ npm run build

The final output is placed in dist/, with main.js being the entrypoint.

Usage

$ postject -h
Usage: postject [options] <filename> <resource_name> <resource>

Inject arbitrary read-only resources into an executable for use at runtime

Arguments:
  filename                             The executable to inject into
  resource_name                        The resource name to use (section name on Mach-O and ELF, resource name for PE)
  resource                             The resource to inject

Options:
  --macho-segment-name <segment_name>  Name for the Mach-O segment (default: "__POSTJECT")
  --output-api-header                  Output the API header to stdout
  --overwrite                          Overwrite the resource if it already exists
  -h, --help                           display help for command

Testing

$ npm test

Design

To ensure maximum capatibility and head off unforeseen issues, the implementation for each format tries to use that format's standard practices for embedding binary data. As such, it should be possible to embed the binary data at build-time as well. The CLI provides the ability to inject the resources into pre-built executables, with the goal that the end result should be as close as possible to what is obtained by embedding them at build-time.

Windows

For PE executables, the resources are added into the .rsrc section, with the RT_RCDATA (raw data) type.

The build-time equivalent is adding the binary data as a resource in the usual manner, such as the Resource Compiler, and marking it as RT_RCDATA.

The run-time lookup uses the FindResource and LoadResource APIs.

macOS

For Mach-O executables, the resources are added as sections inside a new segment.

The build-time equivalent of embedding binary data with this approach uses a linker flag: -sectcreate,__FOO,__foo,content.txt

The run-time lookup uses APIs from <mach-o/getsect.h>.

Linux

For ELF executables, the resources are added as notes.

The build-time equivalent is to use a linker script.

FAQs

Package last updated on 27 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc