샘플
resedit 1.7.2: NtExecutable
검증된 샘플 — npm resedit 1.7.2: NtExecutable. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: NtExecutable.createEmpty creates 32-bit and 64-bit PE…
sha256:d5b080f7befd61a24ad7f30900da95d8d97ab6927bc5c9dc6e9c2bfdbaf0fc03
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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.');
오리진 시더
익명