0sec-cli 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/0sec.js +322 -0
  2. package/README.md +63 -52
  3. package/attacks/data-exfiltration/pii-leakage.yaml +27 -0
  4. package/attacks/encoding-bypass/base64-encoding.yaml +24 -0
  5. package/attacks/jailbreak/dan-roleplay.yaml +27 -0
  6. package/attacks/jailbreak/hypothetical-scenario.yaml +25 -0
  7. package/attacks/jailbreak/multilingual-bypass.yaml +22 -0
  8. package/attacks/output-manipulation/harmful-content.yaml +25 -0
  9. package/attacks/prompt-injection/context-manipulation.yaml +32 -0
  10. package/attacks/prompt-injection/direct-injection.yaml +28 -0
  11. package/attacks/prompt-injection/indirect-injection.yaml +33 -0
  12. package/attacks/system-prompt-extraction/direct-ask.yaml +30 -0
  13. package/attacks/system-prompt-extraction/markdown-exfil.yaml +26 -0
  14. package/attacks/tool-misuse/ssrf-via-tools.yaml +27 -0
  15. package/chunks/adapt-loop-ECQG7454.js +18 -0
  16. package/chunks/adgraph-JLGA6RYI.js +54 -0
  17. package/chunks/agent/skills/frameworks/entra-id.yaml +63 -0
  18. package/chunks/agent/skills/frameworks/graphql-introspection.yaml +116 -0
  19. package/chunks/agent/skills/frameworks/nextjs.yaml +82 -0
  20. package/chunks/agent/skills/frameworks/python-web.yaml +85 -0
  21. package/chunks/agent/skills/frameworks/supabase.yaml +83 -0
  22. package/chunks/agent/skills/frameworks/wordpress-deep.yaml +122 -0
  23. package/chunks/agent/skills/techniques/ad-attack-paths.yaml +57 -0
  24. package/chunks/agent/skills/techniques/advisory-disclosure.yaml +59 -0
  25. package/chunks/agent/skills/techniques/assumption-mining.yaml +53 -0
  26. package/chunks/agent/skills/techniques/blind-exploitation.yaml +143 -0
  27. package/chunks/agent/skills/techniques/crypto-misuse.yaml +88 -0
  28. package/chunks/agent/skills/techniques/cve-poc-adaptation.yaml +82 -0
  29. package/chunks/agent/skills/techniques/entra-attack-paths.yaml +55 -0
  30. package/chunks/agent/skills/techniques/http-conformance-diff.yaml +48 -0
  31. package/chunks/agent/skills/techniques/jwt-attacks.yaml +137 -0
  32. package/chunks/agent/skills/techniques/kernel-weaponization.yaml +53 -0
  33. package/chunks/agent/skills/techniques/llm-excessive-agency.yaml +55 -0
  34. package/chunks/agent/skills/techniques/llm-insecure-output-handling.yaml +56 -0
  35. package/chunks/agent/skills/techniques/llm-prompt-injection.yaml +54 -0
  36. package/chunks/agent/skills/techniques/llm-prompt-layer-write.yaml +68 -0
  37. package/chunks/agent/skills/techniques/llm-rag-poisoning.yaml +57 -0
  38. package/chunks/agent/skills/techniques/llm-safety-eval.yaml +51 -0
  39. package/chunks/agent/skills/techniques/npm-ecosystem.yaml +51 -0
  40. package/chunks/agent/skills/techniques/poc-verification.yaml +55 -0
  41. package/chunks/agent/skills/techniques/race-condition.yaml +122 -0
  42. package/chunks/agent/skills/techniques/scoped-fix.yaml +49 -0
  43. package/chunks/agent/skills/techniques/seedless-depth-review.yaml +59 -0
  44. package/chunks/agent/skills/techniques/spec-differential.yaml +48 -0
  45. package/chunks/agent/skills/techniques/variant-hunting.yaml +55 -0
  46. package/chunks/agent/skills/vulnerabilities/cardano-eutxo-validators.yaml +72 -0
  47. package/chunks/agent/skills/vulnerabilities/command-injection.yaml +99 -0
  48. package/chunks/agent/skills/vulnerabilities/deserialization-chains.yaml +106 -0
  49. package/chunks/agent/skills/vulnerabilities/native-memory-safety.yaml +93 -0
  50. package/chunks/agent/skills/vulnerabilities/path-traversal.yaml +78 -0
  51. package/chunks/agent/skills/vulnerabilities/prototype-pollution.yaml +132 -0
  52. package/chunks/agent/skills/vulnerabilities/request-smuggling.yaml +129 -0
  53. package/chunks/agent/skills/vulnerabilities/sqli-advanced.yaml +102 -0
  54. package/chunks/agent/skills/vulnerabilities/ssrf-bypass.yaml +84 -0
  55. package/chunks/agent/skills/vulnerabilities/ssti-exploitation.yaml +112 -0
  56. package/chunks/agent/skills/vulnerabilities/structural-sqli.yaml +91 -0
  57. package/chunks/appsec-catalog-CBWHGTEL.js +24 -0
  58. package/chunks/artifact-scraper-GJEZMOHF.js +34 -0
  59. package/chunks/assumption-mining-BVMMUZHB.js +79 -0
  60. package/chunks/chunk-2CJ776PV.js +2430 -0
  61. package/chunks/chunk-2RMLOJVB.js +47 -0
  62. package/chunks/chunk-2SANI5RH.js +4728 -0
  63. package/chunks/chunk-3MOLBTLS.js +953 -0
  64. package/chunks/chunk-3QFDYBZQ.js +5108 -0
  65. package/chunks/chunk-47TQJWDH.js +3729 -0
  66. package/chunks/chunk-4Y4KQJXE.js +600 -0
  67. package/chunks/chunk-53G27VPS.js +136 -0
  68. package/chunks/chunk-57ZENEX2.js +169 -0
  69. package/chunks/chunk-5G3ZXFBW.js +182 -0
  70. package/chunks/chunk-6LKRLK2R.js +542 -0
  71. package/chunks/chunk-7DQEV5QI.js +287 -0
  72. package/chunks/chunk-A6CLR72I.js +235 -0
  73. package/chunks/chunk-BKZFDZ23.js +361 -0
  74. package/chunks/chunk-CLHCDHP4.js +471 -0
  75. package/chunks/chunk-D6S3IIPG.js +518 -0
  76. package/chunks/chunk-DN25OQQA.js +1070 -0
  77. package/chunks/chunk-DW5UWPFY.js +275 -0
  78. package/chunks/chunk-F3WBKITT.js +687 -0
  79. package/chunks/chunk-H2FFLZNK.js +3 -0
  80. package/chunks/chunk-H44E2CRN.js +193 -0
  81. package/chunks/chunk-HDWV7PGI.js +596 -0
  82. package/chunks/chunk-HE7LCA7G.js +381 -0
  83. package/chunks/chunk-HT6P7RY3.js +2597 -0
  84. package/chunks/chunk-IOL7D5YV.js +515 -0
  85. package/chunks/chunk-IORC6MQX.js +72828 -0
  86. package/chunks/chunk-IR537GON.js +49 -0
  87. package/chunks/chunk-K26SZ37E.js +5735 -0
  88. package/chunks/chunk-KKGE5RQE.js +1094 -0
  89. package/chunks/chunk-KLTNTE2Z.js +121 -0
  90. package/chunks/chunk-KTQDLNSR.js +1732 -0
  91. package/chunks/chunk-LOHTE223.js +2572 -0
  92. package/chunks/chunk-LP3HHYQU.js +245 -0
  93. package/chunks/chunk-MMLDQR4H.js +852 -0
  94. package/chunks/chunk-MYVT64FN.js +16 -0
  95. package/chunks/chunk-O462Y7P2.js +33019 -0
  96. package/chunks/chunk-OEFNRYI2.js +150 -0
  97. package/chunks/chunk-P6WKNFWX.js +1968 -0
  98. package/chunks/chunk-QI233I24.js +333 -0
  99. package/chunks/chunk-QJQKHO7G.js +917 -0
  100. package/chunks/chunk-QKICO43A.js +808 -0
  101. package/chunks/chunk-QOKTUOU2.js +102 -0
  102. package/chunks/chunk-RDZYQQLW.js +596 -0
  103. package/chunks/chunk-RJWOYEOG.js +271 -0
  104. package/chunks/chunk-RRMJC3ZE.js +105 -0
  105. package/chunks/chunk-RWONANDA.js +973 -0
  106. package/chunks/chunk-SAFFWQW4.js +5921 -0
  107. package/chunks/chunk-SF4KZ4O3.js +502 -0
  108. package/chunks/chunk-SNKTC4BP.js +1422 -0
  109. package/chunks/chunk-SOG2U7B3.js +662 -0
  110. package/chunks/chunk-SZJCPG2I.js +110 -0
  111. package/chunks/chunk-UJ4IK5PO.js +2010 -0
  112. package/chunks/chunk-UM3ZNQIM.js +9329 -0
  113. package/chunks/chunk-VGRDNSHA.js +3249 -0
  114. package/chunks/chunk-VQG4FT5D.js +685 -0
  115. package/chunks/chunk-WKNNZVJS.js +2798 -0
  116. package/chunks/chunk-WU6AFRAZ.js +1167 -0
  117. package/chunks/chunk-WVTBZEQO.js +1531 -0
  118. package/chunks/chunk-YLMN3N25.js +4054 -0
  119. package/chunks/commands-U3AMV5ZU.js +16795 -0
  120. package/chunks/corpus-v1.json +403 -0
  121. package/chunks/cost-ledger-ZCKMBJEN.js +13 -0
  122. package/chunks/data/appsec-archetypes.json +102 -0
  123. package/chunks/data/chromium-archetypes.json +204 -0
  124. package/chunks/data/freebsd-archetypes.json +171 -0
  125. package/chunks/data/kernel-archetypes.json +611 -0
  126. package/chunks/db-26NGQFKO.js +16 -0
  127. package/chunks/disclose-A6AEIEDA.js +132 -0
  128. package/chunks/dist-FDKALV4R.js +2772 -0
  129. package/chunks/dist-GL66KMUX.js +74 -0
  130. package/chunks/dist-JR67XKYO.js +159 -0
  131. package/chunks/eval-runner-DDLE5RQ3.js +27 -0
  132. package/chunks/example-manifest.json +95 -0
  133. package/chunks/exploit-agent-XP23ISN7.js +98 -0
  134. package/chunks/exploit-autoclimb-E6T7RRSC.js +81 -0
  135. package/chunks/exploit-climb-2FAUP6XU.js +358 -0
  136. package/chunks/fix-IG7LYXH3.js +12 -0
  137. package/chunks/github-issues-MJ6OYOOU.js +157 -0
  138. package/chunks/harness-HWOYFKFY.js +22 -0
  139. package/chunks/http-conformance-DU66MZIU.js +11 -0
  140. package/chunks/http-sender-GWH2IYEA.js +10 -0
  141. package/chunks/hunt-scan-XPELSPQQ.js +38 -0
  142. package/chunks/identity-6ZAIIWOR.js +191 -0
  143. package/chunks/kernel-primitive-TENE3R7T.js +44 -0
  144. package/chunks/kernel-vm-runner-4F6QSNFY.js +62 -0
  145. package/chunks/memsafety-scan-J7SECV5W.js +16 -0
  146. package/chunks/native-loop-NTONUDP7.js +54 -0
  147. package/chunks/npm-detectors-KB5Y5ZFX.js +69 -0
  148. package/chunks/npm-dynamic-discovery-AHROOZDB.js +13 -0
  149. package/chunks/orchestrate-ZUWAUWBC.js +62 -0
  150. package/chunks/pipeline-FCARFZU3.js +14 -0
  151. package/chunks/pre-recon-cve-66EB6G4M.js +351 -0
  152. package/chunks/prepare-MYY743TK.js +13 -0
  153. package/chunks/process-3Q7QJIOZ.js +13 -0
  154. package/chunks/replay-runner-RRR4E2A7.js +39 -0
  155. package/chunks/run-ESNN4V5W.js +32632 -0
  156. package/chunks/runtime-62ZQAH7H.js +43 -0
  157. package/chunks/runtime-J7PLXZNM.js +12 -0
  158. package/chunks/scan-stream-FHI2FYZE.js +96 -0
  159. package/chunks/scope-BI7BF4ZY.js +18 -0
  160. package/chunks/session-store-BCFQYDCE.js +28 -0
  161. package/chunks/source-files-PWRQR6LY.js +12 -0
  162. package/chunks/specdrift-WCLH6TTQ.js +19 -0
  163. package/chunks/variant-candidates-6KM6F6MD.js +13 -0
  164. package/chunks/web-recon-prepass-DPVCBRZA.js +1148 -0
  165. package/dashboard/assets/0sec-icon-66SreztZ.gif +0 -0
  166. package/dashboard/assets/bot-yILPnRgD.js +1 -0
  167. package/dashboard/assets/chevron-down-BeDJ-Vka.js +1 -0
  168. package/dashboard/assets/circle-alert-BEnMBMT-.js +1 -0
  169. package/dashboard/assets/client-DRYsuOGl.js +9 -0
  170. package/dashboard/assets/copy-Bi5vzoF9.js +1 -0
  171. package/dashboard/assets/desktop-CXTQonNm.js +32 -0
  172. package/dashboard/assets/desktop-NOekk4QS.css +1 -0
  173. package/dashboard/assets/dist-CmX-h7a4.js +1 -0
  174. package/dashboard/assets/dist-DAwYQmf_.js +45 -0
  175. package/dashboard/assets/findings-page-CACW9nw2.js +5 -0
  176. package/dashboard/assets/format-PoISqsES.js +1 -0
  177. package/dashboard/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  178. package/dashboard/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  179. package/dashboard/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  180. package/dashboard/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  181. package/dashboard/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  182. package/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  183. package/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  184. package/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  185. package/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  186. package/dashboard/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  187. package/dashboard/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  188. package/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  189. package/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  190. package/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  191. package/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  192. package/dashboard/assets/jsx-runtime-C7oxC63R.js +1 -0
  193. package/dashboard/assets/live-page-DrgQqQK5.js +1 -0
  194. package/dashboard/assets/meta-tile-CcskIV_o.js +1 -0
  195. package/dashboard/assets/operations-BKE8T-vY.css +2 -0
  196. package/dashboard/assets/operations-D8nUP5_m.js +4 -0
  197. package/dashboard/assets/operations-app-CQQhG54n.js +2 -0
  198. package/dashboard/assets/overview-page-DTGS8dPo.js +1 -0
  199. package/dashboard/assets/page-header-MFVvEtZW.js +1 -0
  200. package/dashboard/assets/play-Dwo-9xt6.js +1 -0
  201. package/dashboard/assets/scans-page-ChVtq8Us.js +1 -0
  202. package/dashboard/assets/search-CiooTLck.js +1 -0
  203. package/dashboard/assets/siren-CCBwTSuk.js +1 -0
  204. package/dashboard/assets/table-BYS-nIVA.js +1 -0
  205. package/dashboard/assets/tabs-DivxbhQy.js +1 -0
  206. package/dashboard/desktop.html +21 -0
  207. package/dashboard/index.html +15 -0
  208. package/package.json +30 -18
  209. package/bin/0sec.cjs +0 -361
@@ -0,0 +1,358 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ findingSchema,
6
+ formatZodError
7
+ } from "./chunk-KKGE5RQE.js";
8
+ import {
9
+ external_exports
10
+ } from "./chunk-YLMN3N25.js";
11
+ import "./chunk-IR537GON.js";
12
+
13
+ // packages/cli/src/commands/exploit-climb.ts
14
+ import { readFileSync as readFileSync2 } from "node:fs";
15
+ import { resolve } from "node:path";
16
+
17
+ // packages/benchmark/dist/kernel-weaponization-collector.js
18
+ import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from "node:fs";
19
+ import { join, dirname, isAbsolute } from "node:path";
20
+ import { fileURLToPath, pathToFileURL } from "node:url";
21
+ var __dirname = dirname(fileURLToPath(import.meta.url));
22
+ var ESCALATION_RUNGS = [
23
+ "none",
24
+ "attempted",
25
+ "reclaim",
26
+ "arb-read",
27
+ "arb-write",
28
+ "root"
29
+ ];
30
+ function pick(obj, ...keys) {
31
+ if (!obj)
32
+ return void 0;
33
+ for (const k of keys) {
34
+ if (obj[k] !== void 0 && obj[k] !== null)
35
+ return obj[k];
36
+ }
37
+ return void 0;
38
+ }
39
+ function asString(v) {
40
+ return typeof v === "string" ? v : v === void 0 || v === null ? "" : String(v);
41
+ }
42
+ function rungRank(rung) {
43
+ const idx = ESCALATION_RUNGS.indexOf(rung);
44
+ return idx;
45
+ }
46
+ function normalizeStep(raw) {
47
+ const r = raw ?? {};
48
+ const attemptedRung = asString(pick(r, "attempted_rung", "attemptedRung", "target_rung", "targetRung"));
49
+ const reachedRung = asString(pick(r, "reached_rung", "reachedRung"));
50
+ const reason = asString(pick(r, "reason"));
51
+ const refused = attemptedRung !== "" && reachedRung !== "" && rungRank(reachedRung) < rungRank(attemptedRung);
52
+ return {
53
+ stepId: asString(pick(r, "strategy_id", "strategyId", "node_id", "nodeId")),
54
+ title: asString(pick(r, "title")),
55
+ attemptedRung,
56
+ reachedRung,
57
+ reason,
58
+ refused
59
+ };
60
+ }
61
+ function collectSampleFromRun(run, index = 0) {
62
+ if (!run || typeof run !== "object")
63
+ return void 0;
64
+ const root = run;
65
+ const result = root["result"] ?? root;
66
+ const weap = result["weaponization"] ?? result;
67
+ const detail = weap["detail"] ?? weap;
68
+ const highestRung = asString(pick(weap, "highestRung", "highest_rung"));
69
+ if (highestRung === "")
70
+ return void 0;
71
+ const rawSteps = pick(detail, "perStep", "per_step", "attempts");
72
+ const perStep = Array.isArray(rawSteps) ? rawSteps.map(normalizeStep) : [];
73
+ const exploitContext = pick(detail, "exploitContext", "exploit_context") ?? void 0;
74
+ const findingId = asString(pick(root, "finding_id", "findingId") || pick(result, "finding_id", "findingId") || pick(weap, "finding_id", "findingId"));
75
+ const runId = asString(pick(root, "run_id", "runId", "id"));
76
+ const source = runId || findingId || `run-${index}`;
77
+ return {
78
+ id: source,
79
+ input: {
80
+ ...findingId ? { findingId } : {},
81
+ ...asString(pick(root, "kasan", "signature", "crash_dmesg")) ? { kasan: asString(pick(root, "kasan", "signature", "crash_dmesg")) } : {},
82
+ ...pick(root, "primitive") ? { primitive: pick(root, "primitive") } : {},
83
+ ...pick(exploitContext, "writeProfile", "write_profile") ? { writeProfile: pick(exploitContext, "writeProfile", "write_profile") } : {},
84
+ ...pick(exploitContext, "sprayPlans", "spray_plans") ? { sprayPlans: pick(exploitContext, "sprayPlans", "spray_plans") } : {},
85
+ ...pick(exploitContext, "rootTailPlan", "root_tail_plan") ? { rootTailPlan: pick(exploitContext, "rootTailPlan", "root_tail_plan") } : {},
86
+ ...asString(pick(root, "cache_key", "cacheKey")) ? { cacheKey: asString(pick(root, "cache_key", "cacheKey")) } : {}
87
+ },
88
+ label: {
89
+ highestRung,
90
+ lpeAchieved: Boolean(pick(weap, "lpeAchieved", "lpe_achieved")),
91
+ reclaimLanded: Boolean(pick(weap, "reclaimLanded", "reclaim_landed")),
92
+ perStep,
93
+ refusedReasons: perStep.filter((s) => s.refused && s.reason !== "").map((s) => s.reason)
94
+ },
95
+ source
96
+ };
97
+ }
98
+ function collectFromRunsFile(path) {
99
+ const data = JSON.parse(readFileSync(path, "utf8"));
100
+ const runs = Array.isArray(data) ? data : Array.isArray(data?.runs) ? data.runs : Array.isArray(data?.rows) ? data.rows : [];
101
+ const samples = [];
102
+ runs.forEach((run, i) => {
103
+ const s = collectSampleFromRun(run, i);
104
+ if (s)
105
+ samples.push(s);
106
+ });
107
+ return samples;
108
+ }
109
+ function toJsonl(sample) {
110
+ return JSON.stringify({
111
+ id: sample.id,
112
+ input: sample.input,
113
+ label: sample.label,
114
+ source: sample.source
115
+ });
116
+ }
117
+ var KERNEL_WEAPONIZATION_CORPUS_PATH = "results/kernel-weaponization-v1.jsonl";
118
+ function resolveKernelWeaponizationCorpusPath(override, packageRoot = join(__dirname, "..")) {
119
+ const requested = override ?? process.env.KERNEL_WEAPONIZATION_CORPUS_PATH;
120
+ if (requested && requested.length > 0) {
121
+ return isAbsolute(requested) ? requested : join(process.cwd(), requested);
122
+ }
123
+ return join(packageRoot, KERNEL_WEAPONIZATION_CORPUS_PATH);
124
+ }
125
+ function appendWeaponizationRun(run, opts = {}) {
126
+ try {
127
+ const sample = collectSampleFromRun(run);
128
+ if (!sample)
129
+ return false;
130
+ const corpus = resolveKernelWeaponizationCorpusPath(opts.corpusPath);
131
+ const dir = dirname(corpus);
132
+ if (dir && dir !== ".")
133
+ mkdirSync(dir, { recursive: true });
134
+ const line = toJsonl(sample) + "\n";
135
+ if (existsSync(corpus)) {
136
+ appendFileSync(corpus, line);
137
+ } else {
138
+ writeFileSync(corpus, line);
139
+ }
140
+ return true;
141
+ } catch (err) {
142
+ opts.logger?.(`[weaponization-corpus] append skipped: ${err instanceof Error ? err.message : String(err)}`);
143
+ return false;
144
+ }
145
+ }
146
+ async function main() {
147
+ const args = process.argv.slice(2);
148
+ const runsIdx = args.indexOf("--runs");
149
+ if (runsIdx === -1) {
150
+ console.error("usage: kernel-weaponization-collector --runs <runs.json> [--output <out.jsonl>]");
151
+ process.exit(1);
152
+ }
153
+ const runsPath = args[runsIdx + 1];
154
+ const samples = collectFromRunsFile(runsPath);
155
+ const lpe = samples.filter((s) => s.label.lpeAchieved).length;
156
+ const refused = samples.filter((s) => s.label.refusedReasons.length > 0).length;
157
+ console.error("\n=== Kernel Weaponization Corpus ===");
158
+ console.error(` Runs collected: ${samples.length}`);
159
+ console.error(` LPE achieved: ${lpe}`);
160
+ console.error(` With REFUSED rows: ${refused}`);
161
+ const outIdx = args.indexOf("--output");
162
+ const outputPath = outIdx !== -1 ? args[outIdx + 1] : void 0;
163
+ const lines = samples.map(toJsonl);
164
+ if (outputPath) {
165
+ const dir = dirname(outputPath);
166
+ if (dir && dir !== ".")
167
+ mkdirSync(dir, { recursive: true });
168
+ writeFileSync(outputPath, lines.length > 0 ? lines.join("\n") + "\n" : "");
169
+ console.error(` Written to: ${outputPath}`);
170
+ } else {
171
+ const corpus = join(__dirname, "..", KERNEL_WEAPONIZATION_CORPUS_PATH);
172
+ if (existsSync(dirname(corpus))) {
173
+ writeFileSync(corpus, lines.length > 0 ? lines.join("\n") + "\n" : "");
174
+ console.error(` Written to: ${corpus}`);
175
+ } else {
176
+ for (const line of lines)
177
+ console.log(line);
178
+ }
179
+ }
180
+ }
181
+ var isScript = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;
182
+ if (isScript) {
183
+ main().catch((err) => {
184
+ console.error("Kernel weaponization collection failed:", err);
185
+ process.exit(1);
186
+ });
187
+ }
188
+
189
+ // packages/cli/src/commands/exploit-climb.ts
190
+ function readFinding(findingPath) {
191
+ const abs = resolve(findingPath);
192
+ let raw;
193
+ try {
194
+ raw = readFileSync2(abs, "utf8");
195
+ } catch (err) {
196
+ throw new Error(
197
+ `failed to read finding from ${abs}: ${err instanceof Error ? err.message : String(err)}`
198
+ );
199
+ }
200
+ let parsed;
201
+ try {
202
+ parsed = JSON.parse(raw);
203
+ } catch (err) {
204
+ throw new Error(
205
+ `failed to parse finding as JSON (${abs}): ${err instanceof Error ? err.message : String(err)}`
206
+ );
207
+ }
208
+ try {
209
+ return findingSchema.parse(parsed);
210
+ } catch (err) {
211
+ if (err instanceof external_exports.ZodError) {
212
+ throw new Error(formatZodError(err, "finding JSON"));
213
+ }
214
+ throw err;
215
+ }
216
+ }
217
+ function widenerStatusFromEnv() {
218
+ const symbol = process.env["0SEC_KERNEL_QEMU_WIDEN_SYMBOL"]?.trim();
219
+ const offset = process.env["0SEC_KERNEL_QEMU_WIDEN_OFFSET"]?.trim();
220
+ const delay = process.env["0SEC_KERNEL_QEMU_WIDEN_DELAY_MS"]?.trim();
221
+ const guestBuildDir = process.env["0SEC_KERNEL_QEMU_GUEST_BUILD_DIR"]?.trim();
222
+ const configured = Boolean(symbol && offset && delay && guestBuildDir);
223
+ return {
224
+ configured,
225
+ note: configured ? `race-widener configured at ${symbol}+${offset} delay=${delay}ms (in-guest build is fail-soft; outcome is in the guest widen.log)` : "race-widener NOT configured (0SEC_KERNEL_QEMU_WIDEN_SYMBOL/_OFFSET/_DELAY_MS + _GUEST_BUILD_DIR); boots run WITHOUT widening \u2014 a flaky root race may simply not have been hit"
226
+ };
227
+ }
228
+ async function runClimb(opts) {
229
+ const log = opts.logger ?? ((line) => process.stderr.write(line + "\n"));
230
+ const {
231
+ runKernelExploitChain,
232
+ bootedCacheKey,
233
+ writeProofFileReadOnly,
234
+ defaultDmesgOutPath
235
+ } = await import("./dist-FDKALV4R.js");
236
+ const finding = readFinding(opts.findingPath);
237
+ const reproducer = opts.reproducerPath ? readFileSync2(resolve(opts.reproducerPath), "utf8") : void 0;
238
+ const kernelConfigText = opts.kernelConfigPath ? readFileSync2(resolve(opts.kernelConfigPath), "utf8") : void 0;
239
+ const vmlinuxPath = opts.vmlinuxPath ? resolve(opts.vmlinuxPath) : void 0;
240
+ const widener = widenerStatusFromEnv();
241
+ log(`[climb] ${widener.note}`);
242
+ const weaponizeLane = /^(1|true|on|yes)$/i.test(process.env["0SEC_KERNEL_QEMU_INITRAMFS"]?.trim() ?? "") || /^(1|true|on|yes)$/i.test(process.env.USE_KERNEL_WEAPONIZE?.trim() ?? "");
243
+ log(
244
+ weaponizeLane ? "[climb] weaponize lane: lightweight busybox-initramfs boot (rdinit=/init, no 9p root disk)" : "[climb] weaponize lane: 9p disk boot (set USE_KERNEL_WEAPONIZE=1 for the lightweight initramfs lane)"
245
+ );
246
+ const attempts = [];
247
+ let highestRung = "none";
248
+ let rootsAchieved = 0;
249
+ let creditingCacheKey;
250
+ let creditingReason = "";
251
+ let proofPath = null;
252
+ for (let boot = 1; boot <= opts.loopBoots; boot++) {
253
+ log(`[climb] boot ${boot}/${opts.loopBoots} \u2014 driving real chain runner`);
254
+ const result = await runKernelExploitChain([finding], {
255
+ bootKaslr: false,
256
+ ...reproducer ? { reproducer } : {},
257
+ ...vmlinuxPath ? { vmlinuxPath } : {},
258
+ ...kernelConfigText ? { kernelConfigText } : {},
259
+ ...opts.freedStruct ? { freedStruct: opts.freedStruct } : {},
260
+ logger: log
261
+ });
262
+ const cacheKey = bootedCacheKey();
263
+ const attempt = {
264
+ boot,
265
+ ran: result.ran,
266
+ highestRung: result.highestRung,
267
+ lpeAchieved: result.lpeAchieved,
268
+ reclaimLanded: result.reclaimLanded,
269
+ ...cacheKey ? { cacheKey } : {},
270
+ reason: result.reason
271
+ };
272
+ attempts.push(attempt);
273
+ if (result.ran) {
274
+ appendWeaponizationRun(
275
+ {
276
+ run_id: `${finding.id}-boot${boot}`,
277
+ finding_id: finding.id,
278
+ result: {
279
+ weaponization: {
280
+ highestRung: result.highestRung,
281
+ lpeAchieved: result.lpeAchieved,
282
+ reclaimLanded: result.reclaimLanded,
283
+ attempts: result.summary.attempts,
284
+ detail: {
285
+ perStep: result.perStep,
286
+ ...result.exploitContext ? { exploitContext: result.exploitContext } : {}
287
+ }
288
+ }
289
+ }
290
+ },
291
+ { corpusPath: opts.corpusPath, logger: log }
292
+ );
293
+ }
294
+ if (result.lpeAchieved || highestRung === "none") {
295
+ highestRung = result.highestRung;
296
+ }
297
+ if (!result.ran) {
298
+ log(
299
+ "[climb] artifacts not present \u2014 chain returned plan-only (ran:false). No QEMU was spawned. Stage the vulnerable-kernel target (see runbook)."
300
+ );
301
+ creditingReason = result.reason;
302
+ break;
303
+ }
304
+ if (result.lpeAchieved) {
305
+ rootsAchieved++;
306
+ creditingCacheKey = cacheKey;
307
+ creditingReason = result.reason;
308
+ highestRung = result.highestRung;
309
+ const out = opts.proofOutPath ? resolve(opts.proofOutPath) : defaultDmesgOutPath();
310
+ const proof = JSON.stringify(
311
+ {
312
+ kind: "kernel-root-climb-proof",
313
+ finding_id: finding.id,
314
+ boot,
315
+ boots_attempted: boot,
316
+ highest_rung: result.highestRung,
317
+ lpe_achieved: true,
318
+ reclaim_landed: result.reclaimLanded,
319
+ cache_key: cacheKey ?? null,
320
+ verdict: result.reason,
321
+ rationale: result.rationale,
322
+ per_step: result.perStep,
323
+ summary: result.summary,
324
+ artifact_c: result.summary.artifactC ?? null
325
+ },
326
+ null,
327
+ 2
328
+ );
329
+ writeProofFileReadOnly(out, proof + "\n");
330
+ proofPath = out;
331
+ log(`[climb] ROOT credited on boot ${boot}. proof: ${out} cacheKey: ${cacheKey ?? "<none>"}`);
332
+ break;
333
+ }
334
+ creditingReason = result.reason;
335
+ log(`[climb] boot ${boot}: no root (rung='${result.highestRung}'). ${result.reason}`);
336
+ }
337
+ const rootReached = rootsAchieved > 0;
338
+ const exitCode = rootReached ? 0 : attempts.some((a) => a.ran) ? 1 : 2;
339
+ return {
340
+ exitCode,
341
+ result: {
342
+ mode: "kernel-root-climb",
343
+ finding_id: finding.id,
344
+ boots_attempted: attempts.length,
345
+ roots_achieved: rootsAchieved,
346
+ root_reached: rootReached,
347
+ highest_rung: highestRung,
348
+ cache_key: creditingCacheKey ?? null,
349
+ proof_path: proofPath,
350
+ verdict: creditingReason,
351
+ widener,
352
+ attempts
353
+ }
354
+ };
355
+ }
356
+ export {
357
+ runClimb
358
+ };
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ runSourceFix
6
+ } from "./chunk-F3WBKITT.js";
7
+ import "./chunk-LP3HHYQU.js";
8
+ import "./chunk-YLMN3N25.js";
9
+ import "./chunk-IR537GON.js";
10
+ export {
11
+ runSourceFix
12
+ };
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import "./chunk-IR537GON.js";
5
+
6
+ // packages/cli/src/exporters/github-issues.ts
7
+ function buildIssueTitle(finding) {
8
+ const sev = finding.severity.toUpperCase();
9
+ return `[${sev}] ${finding.title}`;
10
+ }
11
+ function buildIssueBody(finding) {
12
+ const lines = [];
13
+ lines.push(`## Description`);
14
+ lines.push(finding.description);
15
+ lines.push("");
16
+ lines.push(`## Details`);
17
+ lines.push(`- **Severity:** ${finding.severity}`);
18
+ lines.push(`- **Category:** ${finding.category}`);
19
+ lines.push(`- **Status:** ${finding.status}`);
20
+ if (finding.cvssScore !== void 0) {
21
+ lines.push(`- **CVSS Score:** ${finding.cvssScore}`);
22
+ }
23
+ if (finding.cvssVector) {
24
+ lines.push(`- **CVSS Vector:** ${finding.cvssVector}`);
25
+ }
26
+ if (finding.confidence !== void 0) {
27
+ lines.push(`- **Confidence:** ${(finding.confidence * 100).toFixed(0)}%`);
28
+ }
29
+ lines.push("");
30
+ if (finding.evidence) {
31
+ lines.push(`## Evidence`);
32
+ if (finding.evidence.request) {
33
+ lines.push(`### Request`);
34
+ lines.push("```");
35
+ lines.push(finding.evidence.request);
36
+ lines.push("```");
37
+ lines.push("");
38
+ }
39
+ if (finding.evidence.response) {
40
+ lines.push(`### Response`);
41
+ lines.push("```");
42
+ lines.push(finding.evidence.response);
43
+ lines.push("```");
44
+ lines.push("");
45
+ }
46
+ if (finding.evidence.analysis) {
47
+ lines.push(`### Analysis`);
48
+ lines.push(finding.evidence.analysis);
49
+ lines.push("");
50
+ }
51
+ }
52
+ lines.push("---");
53
+ lines.push(`*Exported by [0sec](https://github.com/0sec-labs/0sec) | Finding ID: \`${finding.id}\`*`);
54
+ return lines.join("\n");
55
+ }
56
+ function getLabels(finding) {
57
+ const labels = ["0sec", `severity:${finding.severity}`, `category:${finding.category}`];
58
+ return labels;
59
+ }
60
+ async function githubApi(method, url, token, body) {
61
+ const headers = {
62
+ Authorization: `Bearer ${token}`,
63
+ Accept: "application/vnd.github+json",
64
+ "X-GitHub-Api-Version": "2022-11-28"
65
+ };
66
+ if (body !== void 0) {
67
+ headers["Content-Type"] = "application/json";
68
+ }
69
+ const resp = await fetch(url, {
70
+ method,
71
+ headers,
72
+ body: body !== void 0 ? JSON.stringify(body) : void 0
73
+ });
74
+ if (!resp.ok) {
75
+ const text = await resp.text();
76
+ throw new Error(`GitHub API ${method} ${url} returned ${resp.status}: ${text}`);
77
+ }
78
+ return resp.json();
79
+ }
80
+ async function fetchExistingIssueTitles(repo, token) {
81
+ const titles = /* @__PURE__ */ new Set();
82
+ let page = 1;
83
+ const perPage = 100;
84
+ while (true) {
85
+ const url = `https://api.github.com/repos/${repo}/issues?state=open&labels=0sec&per_page=${perPage}&page=${page}`;
86
+ const issues = await githubApi("GET", url, token);
87
+ for (const issue of issues) {
88
+ titles.add(issue.title);
89
+ }
90
+ if (issues.length < perPage) break;
91
+ page++;
92
+ }
93
+ return titles;
94
+ }
95
+ async function ensureLabels(repo, token, labels) {
96
+ const url = `https://api.github.com/repos/${repo}/labels?per_page=100`;
97
+ const existing = await githubApi("GET", url, token);
98
+ const existingNames = new Set(existing.map((l) => l.name));
99
+ const severityColors = {
100
+ "severity:critical": "b60205",
101
+ "severity:high": "d93f0b",
102
+ "severity:medium": "e4e669",
103
+ "severity:low": "0e8a16",
104
+ "severity:info": "c5def5"
105
+ };
106
+ for (const label of labels) {
107
+ if (existingNames.has(label)) continue;
108
+ const color = severityColors[label] ?? "ededed";
109
+ try {
110
+ await githubApi("POST", `https://api.github.com/repos/${repo}/labels`, token, {
111
+ name: label,
112
+ color
113
+ });
114
+ } catch {
115
+ }
116
+ }
117
+ }
118
+ async function exportToGitHubIssues(findings, repo) {
119
+ const token = process.env.GITHUB_TOKEN;
120
+ if (!token) {
121
+ throw new Error(
122
+ "GITHUB_TOKEN environment variable is required for GitHub Issues export. Create a token at https://github.com/settings/tokens with the 'repo' scope."
123
+ );
124
+ }
125
+ if (findings.length === 0) {
126
+ return { created: 0, skipped: 0 };
127
+ }
128
+ const allLabels = /* @__PURE__ */ new Set();
129
+ allLabels.add("0sec");
130
+ for (const f of findings) {
131
+ for (const l of getLabels(f)) {
132
+ allLabels.add(l);
133
+ }
134
+ }
135
+ await ensureLabels(repo, token, [...allLabels]);
136
+ const existingTitles = await fetchExistingIssueTitles(repo, token);
137
+ let created = 0;
138
+ let skipped = 0;
139
+ for (const finding of findings) {
140
+ const title = buildIssueTitle(finding);
141
+ if (existingTitles.has(title)) {
142
+ skipped++;
143
+ continue;
144
+ }
145
+ await githubApi("POST", `https://api.github.com/repos/${repo}/issues`, token, {
146
+ title,
147
+ body: buildIssueBody(finding),
148
+ labels: getLabels(finding)
149
+ });
150
+ existingTitles.add(title);
151
+ created++;
152
+ }
153
+ return { created, skipped };
154
+ }
155
+ export {
156
+ exportToGitHubIssues
157
+ };
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ bootedCacheKey,
6
+ kernelVmArtifactsReady,
7
+ mintCanary,
8
+ runStrategy,
9
+ runWeaponization
10
+ } from "./chunk-KTQDLNSR.js";
11
+ import "./chunk-SNKTC4BP.js";
12
+ import "./chunk-RJWOYEOG.js";
13
+ import "./chunk-KKGE5RQE.js";
14
+ import "./chunk-YLMN3N25.js";
15
+ import "./chunk-IR537GON.js";
16
+ export {
17
+ bootedCacheKey,
18
+ kernelVmArtifactsReady,
19
+ mintCanary,
20
+ runStrategy,
21
+ runWeaponization
22
+ };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ runHttpConformanceCheck
6
+ } from "./chunk-IOL7D5YV.js";
7
+ import "./chunk-YLMN3N25.js";
8
+ import "./chunk-IR537GON.js";
9
+ export {
10
+ runHttpConformanceCheck
11
+ };
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ createLiveHttpSender
6
+ } from "./chunk-2RMLOJVB.js";
7
+ import "./chunk-IR537GON.js";
8
+ export {
9
+ createLiveHttpSender
10
+ };
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0secCreateRequire } from "node:module";
3
+ const require = __0secCreateRequire(import.meta.url);
4
+ import {
5
+ AimdState,
6
+ composeGate,
7
+ makeMultiLensVerifier,
8
+ makeSkepticVerifier,
9
+ runHuntScan
10
+ } from "./chunk-K26SZ37E.js";
11
+ import "./chunk-RJWOYEOG.js";
12
+ import "./chunk-O462Y7P2.js";
13
+ import "./chunk-LOHTE223.js";
14
+ import "./chunk-3MOLBTLS.js";
15
+ import "./chunk-P6WKNFWX.js";
16
+ import "./chunk-SOG2U7B3.js";
17
+ import "./chunk-LP3HHYQU.js";
18
+ import "./chunk-KLTNTE2Z.js";
19
+ import "./chunk-HT6P7RY3.js";
20
+ import "./chunk-RRMJC3ZE.js";
21
+ import "./chunk-H2FFLZNK.js";
22
+ import "./chunk-UM3ZNQIM.js";
23
+ import "./chunk-57ZENEX2.js";
24
+ import "./chunk-MMLDQR4H.js";
25
+ import "./chunk-2SANI5RH.js";
26
+ import "./chunk-CLHCDHP4.js";
27
+ import "./chunk-QOKTUOU2.js";
28
+ import "./chunk-KKGE5RQE.js";
29
+ import "./chunk-YLMN3N25.js";
30
+ import "./chunk-DW5UWPFY.js";
31
+ import "./chunk-IR537GON.js";
32
+ export {
33
+ AimdState,
34
+ composeGate,
35
+ makeMultiLensVerifier,
36
+ makeSkepticVerifier,
37
+ runHuntScan
38
+ };