示例
resedit 1.7.2: NtExecutable
已验证示例 — npm resedit 1.7.2: NtExecutable. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: NtExecutable.createEmpty creates 32-bit and 64-bit PE…
sha256:d5b080f7befd61a24ad7f30900da95d8d97ab6927bc5c9dc6e9c2bfdbaf0fc03
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-06 |
案例
HOW- 目标
- verify resedit.NtExecutable in pkg:npm/resedit@1.7.2
- 符号
-
- resedit.NtExecutable
- 环境
- node 22.23.2
- 创建时间
- 2026-09-06T09:43:56Z
契约
- NtExecutable.createEmpty creates 32-bit and 64-bit PE executable headers with valid DOS and NT signatures
- NtExecutable.setExtraData appends custom overlay payload data and getExtraData retrieves the binary overlay
- NtExecutable.getAllSections and getSectionByEntry query executable sections including resource directory entries
- NtExecutable.generate serializes the PE structure to an ArrayBuffer and NtExecutable.from re-parses identical header properties and sections
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
源代码
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify resedit.NtExecutable in pkg:npm/resedit@1.7.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/resedit@1.7.2
Demonstrate these symbols/APIs:
- resedit.NtExecutable
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:d56075f1e181551acd33e5c7ce2586094d7bf236888f4766c5e8f29923341a2b","contract":["NtExecutable.createEmpty creates 32-bit and 64-bit PE executable headers with valid DOS and NT signatures","NtExecutable.setExtraData appends custom overlay payload data and getExtraData retrieves the binary overlay","NtExecutable.getAllSections and getSectionByEntry query executable sections including resource directory entries","NtExecutable.generate serializes the PE structure to an ArrayBuffer and NtExecutable.from re-parses identical header properties and sections"],"goal":"verify resedit.NtExecutable in pkg:npm/resedit@1.7.2","kind":"HOW","packages":["pkg:npm/resedit@1.7.2"],"schemaVersion":1,"symbols":["resedit.NtExecutable"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/resedit@1.7.2"],"schemaVersion":1,"subject":"pkg:npm/resedit@1.7.2","symbols":["resedit.NtExecutable"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-resedit-ntexecutable",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-resedit-ntexecutable",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"resedit": "1.7.2"
}
},
"node_modules/pe-library": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/pe-library/-/pe-library-0.4.1.tgz",
"integrity": "sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==",
"license": "MIT",
"engines": {
"node": ">=12",
"npm": ">=6"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/jet2jet"
}
},
"node_modules/resedit": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz",
"integrity": "sha512-vHjcY2MlAITJhC0eRD/Vv8Vlgmu9Sd3LX9zZvtGzU5ZImdTN3+d6e/4mnTyV8vEbyf1sgNIrWxhWlrys52OkEA==",
"license": "MIT",
"dependencies": {
"pe-library": "^0.4.1"
},
"engines": {
"node": ">=12",
"npm": ">=6"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/jet2jet"
}
}
}
}
{
"name": "sample-resedit-ntexecutable",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"resedit": "1.7.2"
}
}
{
"schemaVersion": 1,
"goal": "verify resedit.NtExecutable in pkg:npm/resedit@1.7.2",
"kind": "HOW",
"packages": [
"pkg:npm/resedit@1.7.2"
],
"symbols": [
"resedit.NtExecutable"
]
}
import { NtExecutable, NtExecutableResource, Format } from 'resedit';
/**
* Creates an empty PE executable structure.
*
* @param {Object} [options]
* @param {boolean} [options.is32Bit=false] - Whether to create a 32-bit (PE32) executable instead of 64-bit (PE32+).
* @param {boolean} [options.isDLL=false] - Whether to create a DLL instead of an EXE.
* @returns {NtExecutable}
*/
export function createExecutable(options = {}) {
const is32Bit = Boolean(options.is32Bit);
const isDLL = Boolean(options.isDLL);
return NtExecutable.createEmpty(is32Bit, isDLL);
}
/**
* Sets binary extra data (overlay data appended to the executable).
*
* @param {NtExecutable} exe - The NtExecutable instance.
* @param {ArrayBuffer|ArrayBufferView|null} data - Overlay binary data to attach.
*/
export function setExecutableOverlay(exe, data) {
exe.setExtraData(data);
}
/**
* Retrieves binary extra data (overlay data) from the executable.
*
* @param {NtExecutable} exe - The NtExecutable instance.
* @returns {ArrayBuffer|null}
*/
export function getExecutableOverlay(exe) {
return exe.getExtraData();
}
/**
* Retrieves section information by directory entry enum value.
*
* @param {NtExecutable} exe - The NtExecutable instance.
* @param {number} entry - Directory entry enum value (e.g. Format.ImageDirectoryEntry.Resource).
* @returns {{ name: string, virtualSize: number, sizeOfRawData: number, byteLength: number } | null}
*/
export function getSectionByEntry(exe, entry) {
const section = exe.getSectionByEntry(entry);
if (!section) {
return null;
}
return {
name: section.info.name,
virtualSize: section.info.virtualSize,
sizeOfRawData: section.info.sizeOfRawData,
byteLength: section.data ? section.data.byteLength : 0
};
}
/**
* Serializes an NtExecutable to an ArrayBuffer and re-parses it back to a new NtExecutable instance.
*
* @param {NtExecutable} exe - The NtExecutable instance to serialize.
* @param {number} [paddingSize] - Optional section alignment padding size.
* @returns {{ binary: ArrayBuffer, parsedExe: NtExecutable }}
*/
export function roundtripExecutable(exe, paddingSize) {
const binary = exe.generate(paddingSize);
const parsedExe = NtExecutable.from(binary);
return { binary, parsedExe };
}
export { NtExecutable, NtExecutableResource, Format };
import assert from 'node:assert/strict';
import { NtExecutable, NtExecutableResource, Format, Resource } from 'resedit';
import {
createExecutable,
setExecutableOverlay,
getExecutableOverlay,
getSectionByEntry,
roundtripExecutable
} from '../src/index.mjs';
// 1. NtExecutable.createEmpty creates 32-bit and 64-bit PE executable headers with valid DOS and NT signatures
{
const exe64 = NtExecutable.createEmpty(false, false);
assert.equal(exe64.is32bit(), false);
assert.equal(exe64.dosHeader.magic, 0x5A4D); // 'MZ'
assert.equal(exe64.newHeader.signature, 0x4550); // 'PE\0\0'
assert.equal(exe64.newHeader.optionalHeader.magic, 0x20B); // PE32+
assert.ok(exe64.getTotalHeaderSize() > 0);
assert.ok(exe64.getImageBase() > 0);
const exe32 = NtExecutable.createEmpty(true, true);
assert.equal(exe32.is32bit(), true);
assert.equal(exe32.dosHeader.magic, 0x5A4D);
assert.equal(exe32.newHeader.signature, 0x4550);
assert.equal(exe32.newHeader.optionalHeader.magic, 0x10B); // PE32
const helperExe = createExecutable({ is32Bit: false, isDLL: false });
assert.equal(helperExe.is32bit(), false);
assert.equal(helperExe.dosHeader.magic, 0x5A4D);
}
// 2. NtExecutable.setExtraData appends custom overlay payload data and getExtraData retrieves the binary overlay
{
const exe = NtExecutable.createEmpty(false, false);
assert.equal(exe.getExtraData(), null);
const payload = new Uint8Array([0xAA, 0xBB, 0xCC, 0xDD, 0x11, 0x22, 0x33, 0x44]);
exe.setExtraData(payload);
const retrieved = exe.getExtraData();
assert.ok(retrieved instanceof ArrayBuffer);
assert.deepEqual(new Uint8Array(retrieved), payload);
setExecutableOverlay(exe, null);
assert.equal(getExecutableOverlay(exe), null);
setExecutableOverlay(exe, payload);
const helperRetrieved = getExecutableOverlay(exe);
assert.ok(helperRetrieved instanceof ArrayBuffer);
assert.deepEqual(new Uint8Array(helperRetrieved), payload);
}
// 3. NtExecutable.getAllSections and getSectionByEntry query executable sections including resource directory entries
{
const exe = NtExecutable.createEmpty(false, false);
assert.equal(exe.getAllSections().length, 0);
assert.equal(exe.getSectionByEntry(Format.ImageDirectoryEntry.Resource), null);
assert.equal(getSectionByEntry(exe, Format.ImageDirectoryEntry.Resource), null);
const res = NtExecutableResource.from(exe);
const st = new Resource.StringTable();
st.lang = 1033;
st.setById(1, 'Sample Entry');
st.replaceStringEntriesForExecutable(res);
res.outputResource(exe);
const sections = exe.getAllSections();
assert.equal(sections.length, 1);
assert.equal(sections[0].info.name, '.rsrc');
const rsrcSection = exe.getSectionByEntry(Format.ImageDirectoryEntry.Resource);
assert.ok(rsrcSection);
assert.equal(rsrcSection.info.name, '.rsrc');
assert.ok(rsrcSection.data instanceof ArrayBuffer);
assert.ok(rsrcSection.data.byteLength > 0);
const details = getSectionByEntry(exe, Format.ImageDirectoryEntry.Resource);
assert.ok(details);
assert.equal(details.name, '.rsrc');
assert.equal(details.byteLength > 0, true);
}
// 4. NtExecutable.generate serializes the PE structure to an ArrayBuffer and NtExecutable.from re-parses identical header properties and sections
{
const exe = NtExecutable.createEmpty(false, false);
const payload = new Uint8Array([0x50, 0x45, 0x5F, 0x44, 0x41, 0x54, 0x41]);
exe.setExtraData(payload);
const res = NtExecutableResource.from(exe);
const st = new Resource.StringTable();
st.lang = 1033;
st.setById(42, 'Answer');
st.replaceStringEntriesForExecutable(res);
res.outputResource(exe);
const binary = exe.generate();
assert.ok(binary instanceof ArrayBuffer);
assert.ok(binary.byteLength > 0);
const parsed = NtExecutable.from(binary);
assert.equal(parsed.is32bit(), false);
assert.equal(parsed.getImageBase(), exe.getImageBase());
assert.equal(parsed.getFileAlignment(), exe.getFileAlignment());
assert.equal(parsed.getSectionAlignment(), exe.getSectionAlignment());
assert.equal(parsed.dosHeader.magic, 0x5A4D);
assert.equal(parsed.newHeader.signature, 0x4550);
const parsedRsrc = parsed.getSectionByEntry(Format.ImageDirectoryEntry.Resource);
assert.ok(parsedRsrc);
assert.equal(parsedRsrc.info.name, '.rsrc');
const parsedExtra = parsed.getExtraData();
assert.ok(parsedExtra instanceof ArrayBuffer);
assert.deepEqual(new Uint8Array(parsedExtra), payload);
const roundtripResult = roundtripExecutable(exe);
assert.ok(roundtripResult.binary instanceof ArrayBuffer);
assert.equal(roundtripResult.parsedExe.is32bit(), false);
assert.equal(roundtripResult.parsedExe.dosHeader.magic, 0x5A4D);
}
console.log('Contract tests passed successfully.');
原始种子者
匿名