Spaces:
Sleeping
Sleeping
Deploy FoxDec research artifacts
Browse filesFiles changed (6)
- Dockerfile+6-7
- README.md+1-1
- app.py+21-8
- catalog.md+1-1
- ccs.py+21-16
- runner.py+5-5
51 unmodified lines5253545556575813 unmodified lines7273747576777828 unmodified lines1071081091101111121131141151161171181191201211221231241252 unmodified lines12812913013113213313451 unmodified linesCOPY CCS_artifact.zip .RUN echo '7b27886e28f05c30cc8932acb0f32e07184627f51a2da4b12801ea29f6f7547d CCS_artifact.zip' | sha256sum -c - \&& unzip -q CCS_artifact.zip 'NASM_generation/foxdec_v0.5.zip' 'NASM_generation/binary/wc*' \'NASM_generation/artifacts/nasm/__gmon_start__.c' 'certificate_generation/*.zip' 'isabelle/PCode.thy' \&& unzip -q NASM_generation/foxdec_v0.5.zip -d lift \&& unzip -q certificate_generation/app.zip 'app/*' -d cert \&& unzip -q certificate_generation/scripts.zip 'scripts/*' -d cert13 unmodified lines--mount=type=cache,id=foxdec-stack-snapshots,target=/root/.stack/snapshots \stack --install-ghc --jobs 4 --local-bin-path /opt/foxdec/ccs/bin install \&& cp -r config ../NASM_generation/binary /opt/foxdec/ccs/ \&& cp ../NASM_generation/artifacts/nasm/__gmon_start__.c ../isabelle/PCode.thy /opt/foxdec/ccs/ \&& cp /usr/lib/libcapstone.so.4 /opt/foxdec/ccs/ \&& sed -i -e 's@"/artifacts"@"."@g' -e 's@/Ghidra/@/opt/ghidra/@g' ../cert/app/Main.hs \&& sed -i -e 's@"/Users/nna/GitHub/binary-certificate-generator/app/entry.txt"@"entry.txt"@' \28 unmodified linesCOPY --from=ghidra /opt/ghidra /opt/ghidraCOPY --from=isabelle /opt/Isabelle2023 /opt/Isabelle2023COPY --from=isabelle /opt/Word_Lib /opt/Word_LibENV LD_LIBRARY_PATH=/opt/foxdec/ccsWORKDIR /home/user/appCOPY runner.py ccs.py ./USER userENTRYPOINT ["/usr/bin/tini", "--", "python", "ccs.py"]FROM python:3.11-slim-bookworm AS spaceRUN --mount=type=cache,id=foxdec-apt-lists,target=/var/lib/apt/lists,sharing=locked \--mount=type=cache,id=foxdec-apt-archives,target=/var/cache/apt,sharing=locked \rm -f /etc/apt/apt.conf.d/docker-clean \&& apt-get update && apt-get install -y --no-install-recommends \binutils graphviz libcapstone4 libgmp10 libgomp1 libtinfo5 libz3-4 make time tini \&& useradd --create-home --uid 1000 userCOPY requirements.txt /tmp/requirements.txtRUN --mount=type=cache,id=foxdec-pip,target=/root/.cache/pip \pip install -r /tmp/requirements.txt2 unmodified linesCOPY --from=quickstart --chmod=644 /build/foxdec_v0.7/LICENSE /opt/foxdec/quickstart/LICENSECOPY --from=pldi --chmod=644 /build/construct-ssm/LICENSE /opt/foxdec/pldi/LICENSEWORKDIR /home/user/appCOPY app.py runner.py catalog.md ./USER userEXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]51 unmodified lines5253545556575813 unmodified lines7273747576777828 unmodified lines1071081091101111121131141151161171181191201211221231242 unmodified lines12712812913013113213351 unmodified linesCOPY CCS_artifact.zip .RUN echo '7b27886e28f05c30cc8932acb0f32e07184627f51a2da4b12801ea29f6f7547d CCS_artifact.zip' | sha256sum -c - \&& unzip -q CCS_artifact.zip 'NASM_generation/foxdec_v0.5.zip' 'NASM_generation/binary/wc*' \'certificate_generation/*.zip' 'isabelle/PCode.thy' \&& unzip -q NASM_generation/foxdec_v0.5.zip -d lift \&& unzip -q certificate_generation/app.zip 'app/*' -d cert \&& unzip -q certificate_generation/scripts.zip 'scripts/*' -d cert13 unmodified lines--mount=type=cache,id=foxdec-stack-snapshots,target=/root/.stack/snapshots \stack --install-ghc --jobs 4 --local-bin-path /opt/foxdec/ccs/bin install \&& cp -r config ../NASM_generation/binary /opt/foxdec/ccs/ \&& cp ../isabelle/PCode.thy /opt/foxdec/ccs/ \&& cp /usr/lib/libcapstone.so.4 /opt/foxdec/ccs/ \&& sed -i -e 's@"/artifacts"@"."@g' -e 's@/Ghidra/@/opt/ghidra/@g' ../cert/app/Main.hs \&& sed -i -e 's@"/Users/nna/GitHub/binary-certificate-generator/app/entry.txt"@"entry.txt"@' \28 unmodified linesCOPY --from=ghidra /opt/ghidra /opt/ghidraCOPY --from=isabelle /opt/Isabelle2023 /opt/Isabelle2023COPY --from=isabelle /opt/Word_Lib /opt/Word_LibWORKDIR /home/user/appCOPY runner.py ccs.py ./USER userENTRYPOINT ["/usr/bin/tini", "--", "python", "ccs.py"]FROM ccs-validation AS spaceUSER rootRUN --mount=type=cache,id=foxdec-apt-lists,target=/var/lib/apt/lists,sharing=locked \--mount=type=cache,id=foxdec-apt-archives,target=/var/cache/apt,sharing=locked \rm -f /etc/apt/apt.conf.d/docker-clean \&& apt-get update && apt-get install -y --no-install-recommends \libcapstone4 libz3-4 make timeCOPY requirements.txt /tmp/requirements.txtRUN --mount=type=cache,id=foxdec-pip,target=/root/.cache/pip \pip install -r /tmp/requirements.txt2 unmodified linesCOPY --from=quickstart --chmod=644 /build/foxdec_v0.7/LICENSE /opt/foxdec/quickstart/LICENSECOPY --from=pldi --chmod=644 /build/construct-ssm/LICENSE /opt/foxdec/pldi/LICENSEWORKDIR /home/user/appCOPY app.py catalog.md ./USER userEXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]
8 unmodified lines91011121314158 unmodified lines# FoxDec research artifactsRun the FoxDec v0.7 `wc` quickstart or the PLDI 2022 `simple_local_array` example. The app runs one job at a time, gives each run up to five minutes, and displays generated results in the page. The [artifact catalog](catalog.md) links to the original papers and reproduction packages.## Run locally8 unmodified lines91011121314158 unmodified lines# FoxDec research artifactsRun the FoxDec v0.7 `wc` quickstart, PLDI 2022 `simple_local_array`, or the CCS 2024 certificate workflow. The app runs one job at a time and displays the results in the page. Quickstart and PLDI have five-minute deadlines. CCS has an eight-minute deadline after completing in about four minutes on two CPUs and 16 GB of memory. The [artifact catalog](catalog.md) links to the original papers and reproduction packages.## Run locally
5 unmodified lines67891011121314151619 unmodified lines3637383940414243444546474849505152535455565758596 unmodified lines666768697071725 unmodified linesimport gradio as grfrom runner import DEADLINE, pldi, quickstart, read_previewEXAMPLES = {"FoxDec v0.7 · wc": quickstart,"PLDI 2022 · simple_local_array": pldi,}logger = logging.getLogger(__name__)19 unmodified linesreturnstarted = monotonic()deadline = started + DEADLINEwith TemporaryDirectory(prefix="foxdec-job-") as directory:work = Path(directory)log = work / "run.log"try:note, files = EXAMPLES[example](work, log, deadline)results = display_results(work, files)status = f"Completed in {monotonic() - started:.1f}s{note}"except (OSError, RuntimeError) as error:if isinstance(error, TimeoutError):status = str(error)else:logger.exception("FoxDec job failed")status = f"Failed. {error}"diagnostics = (log, work / "simple_local_array.err")message = "\n".join(filter(None, (read_preview(path, tail=True) for path in diagnostics)))results = f'<div class="foxdec-results"><pre>{escape(message)}</pre></div>' if message else ""yield status, results, gr.update(interactive=True)with gr.Blocks(6 unmodified lineswith gr.Row():example = gr.Dropdown(list(EXAMPLES), value=next(iter(EXAMPLES)), label="Example")run = gr.Button("Run", variant="primary", scale=0)status = gr.Textbox(label="Status", interactive=False)results = gr.HTML()with gr.Accordion("Artifact catalog", open=False):gr.Markdown(Path(__file__).with_name("catalog.md").read_text())5 unmodified lines678910111213141516171819 unmodified lines38394041424344454647484950515253545556575859606162636465666768697071726 unmodified lines798081828384855 unmodified linesimport gradio as grfrom ccs import stages as ccs_stagesfrom runner import DEADLINE, pldi, quickstart, read_previewEXAMPLES = {"FoxDec v0.7 · wc": (DEADLINE, quickstart),"PLDI 2022 · simple_local_array": (DEADLINE, pldi),"CCS 2024 · wc certificate": (480, ccs_stages),}logger = logging.getLogger(__name__)19 unmodified linesreturnstarted = monotonic()budget, workflow = EXAMPLES[example]deadline = started + budgetphases = []with TemporaryDirectory(prefix="foxdec-job-") as directory:work = Path(directory)log = work / "run.log"try:files = ()for phase, files in workflow(work, log, deadline):if phase:phases.append(phase)if not files:yield "\n".join(phases), "", gr.update(interactive=False)if not files:raise RuntimeError("The job produced no results.")results = display_results(work, files)if monotonic() >= deadline:raise TimeoutError("The job reached its time limit.")status = f"Completed in {monotonic() - started:.1f}s"except (OSError, RuntimeError) as error:if isinstance(error, TimeoutError):status = str(error)else:logger.exception("FoxDec job failed")status = f"Failed. {error}"diagnostics = (log, work / "simple_local_array.err", work / "verification.log")message = "\n".join(filter(None, (read_preview(path, tail=True) for path in diagnostics)))results = f'<div class="foxdec-results"><pre>{escape(message)}</pre></div>' if message else ""yield "\n".join([status, *phases]), results, gr.update(interactive=True)with gr.Blocks(6 unmodified lineswith gr.Row():example = gr.Dropdown(list(EXAMPLES), value=next(iter(EXAMPLES)), label="Example")run = gr.Button("Run", variant="primary", scale=0)status = gr.Textbox(label="Status", lines=2, max_lines=6, interactive=False)results = gr.HTML()with gr.Accordion("Artifact catalog", open=False):gr.Markdown(Path(__file__).with_name("catalog.md").read_text())
3 unmodified lines456789103 unmodified lines| --- | --- | --- || FoxDec v0.7 quickstart | Lifts the bundled `wc` to NASM and generates metrics, a call graph and per-function results. [Quickstart](https://ssrg-vt.github.io/FoxDec/#how-to-use) · [Pinned release ZIP](https://github.com/ssrg-vt/FoxDec/blob/0abd8c85cda0ccf3da9ef6683acb77a99c04b8b6/foxdec/release/FoxDec.zip) | Runnable || PLDI 2022 · Formally Verified Lifting of C-compiled x86-64 Binaries | Runs the symbolic state analysis on the bundled `simple_local_array` example. [Paper](https://doi.org/10.1145/3519939.3523702) · [Tagged artifact](https://github.com/jabocken/SSM-Construction/releases/tag/v2.0.0.2) · [Benchmark instructions](https://github.com/jabocken/SSM-Construction/tree/v2.0.0.2#running-test-cases) · [Isabelle instructions](https://github.com/jabocken/SSM-Construction/blob/v2.0.0.2/isabelle/README) | Example runnable. Full benchmark and proofs available upstream. || CCS 2024 · Verifiably Correct Lifting of Position-Independent x86-64 Binaries to Symbolized Assembly | Lifts the paper’s `wc` with FoxDec v0.5, recompiles it, generates an equivalence certificate with Ghidra and checks it in Isabelle2023. [Paper](https://doi.org/10.1145/3658644.3690244) · [Archived artifact and instructions](https://zenodo.org/records/12721325) | Catalog only pending end-to-end certificate verification. || ICSE 2025 · Formally Verified Binary-level Pointer Analysis | Binary-level pointer analysis, benchmark cases and Isabelle/HOL proofs. [Paper](https://arxiv.org/abs/2501.17766) · [Artifact](https://doi.org/10.5281/zenodo.14223108) | Catalog only || DIMVA 2024 · Exceptional Interprocedural Control Flow Graphs for x86-64 Binaries | Recovers control flow for C++ exceptions in x86-64 binaries. [Paper](https://ssrg.ece.vt.edu/papers/dimva24.pdf) · [Artifact](https://doi.org/10.5281/zenodo.11081942) | Catalog only || CCS 2024 poster · Formally Verified Binary Lifting to P-Code | Uses Isabelle to study whether lifting x86-64 assembly to Ghidra P-Code preserves instruction behavior. [Poster paper](https://doi.org/10.1145/3658644.3691386) | Catalog only |3 unmodified lines456789103 unmodified lines| --- | --- | --- || FoxDec v0.7 quickstart | Lifts the bundled `wc` to NASM and generates metrics, a call graph and per-function results. [Quickstart](https://ssrg-vt.github.io/FoxDec/#how-to-use) · [Pinned release ZIP](https://github.com/ssrg-vt/FoxDec/blob/0abd8c85cda0ccf3da9ef6683acb77a99c04b8b6/foxdec/release/FoxDec.zip) | Runnable || PLDI 2022 · Formally Verified Lifting of C-compiled x86-64 Binaries | Runs the symbolic state analysis on the bundled `simple_local_array` example. [Paper](https://doi.org/10.1145/3519939.3523702) · [Tagged artifact](https://github.com/jabocken/SSM-Construction/releases/tag/v2.0.0.2) · [Benchmark instructions](https://github.com/jabocken/SSM-Construction/tree/v2.0.0.2#running-test-cases) · [Isabelle instructions](https://github.com/jabocken/SSM-Construction/blob/v2.0.0.2/isabelle/README) | Example runnable. Full benchmark and proofs available upstream. || CCS 2024 · Verifiably Correct Lifting of Position-Independent x86-64 Binaries to Symbolized Assembly | Lifts the paper’s `wc` with FoxDec v0.5, recompiles it, generates an equivalence certificate with Ghidra and checks it in Isabelle2023. [Paper](https://doi.org/10.1145/3658644.3690244) · [Archived artifact and instructions](https://zenodo.org/records/12721325) | Runnable. Checks a newly generated certificate. || ICSE 2025 · Formally Verified Binary-level Pointer Analysis | Binary-level pointer analysis, benchmark cases and Isabelle/HOL proofs. [Paper](https://arxiv.org/abs/2501.17766) · [Artifact](https://doi.org/10.5281/zenodo.14223108) | Catalog only || DIMVA 2024 · Exceptional Interprocedural Control Flow Graphs for x86-64 Binaries | Recovers control flow for C++ exceptions in x86-64 binaries. [Paper](https://ssrg.ece.vt.edu/papers/dimva24.pdf) · [Artifact](https://doi.org/10.5281/zenodo.11081942) | Catalog only || CCS 2024 poster · Formally Verified Binary Lifting to P-Code | Uses Isabelle to study whether lifting x86-64 assembly to Ghidra P-Code preserves instruction behavior. [Poster paper](https://doi.org/10.1145/3658644.3691386) | Catalog only |
1235 unmodified lines91011121314151617181920212223242526272829302 unmodified lines333435363738398 unmodified lines48495051525354553 unmodified lines5960616263646566676869import shutilimport sysfrom pathlib import Path5 unmodified linesTOOL = ROOT / "ccs"def stages(work, deadline):log = work / "run.log"lift(TOOL, work, log, deadline, ["--GNASM"])nasm = work / "nasm"assembly = nasm / "wc.asm"mapping = nasm / "wc.map"require_outputs(assembly, mapping)yield "Lifted wc to NASM"shutil.copyfile(TOOL / "__gmon_start__.c", nasm / "__gmon_start__.c")run_command(["nasm", "-felf64", "-g", "-F", "dwarf", "-o", "wc.o", "wc.asm"], nasm, log, deadline)run_command(["gcc", "-c", "__gmon_start__.c", "-o", "__gmon_start__.o"], nasm, log, deadline)run_command(["gcc", "-g", "-m64", "-nostartfiles", "-fgnu-tm", "-o", "a.out", "wc.o","__gmon_start__.o"], nasm, log, deadline)require_outputs(nasm / "a.out")yield "Recompiled the NASM"certificate = work / "certificate"certificate.mkdir()2 unmodified linesif not blocks:raise RuntimeError("The generator produced no block theories.")require_outputs(certificate / "PCode_wc.thy", certificate / "PCode_wc_mapping.thy", *blocks)yield "Generated the certificate with Ghidra"shutil.copyfile(TOOL / "PCode.thy", certificate / "PCode.thy")(certificate / "ROOT").write_text(8 unmodified lines"-d", "/opt/Word_Lib", "-D", ".", "FoxDec_Certificate"],certificate, verification, deadline,)yield "Isabelle2023 verified PCode_wc.thy"return [verification,assembly, mapping, *sorted(certificate.glob("*.thy")),certificate / "ROOT", log,]3 unmodified linesstart = monotonic()with TemporaryDirectory(prefix="foxdec-ccs-") as directory:work = Path(directory)steps = stages(work, start + float(timeout))try:while True:print(f"{monotonic() - start:.1f}s · {next(steps)}", flush=True)except StopIteration:print(read_preview(work / "verification.log", tail=True))except (RuntimeError, TimeoutError, OSError):for log in ("run.log", "verification.log"):12345 unmodified lines101112131415161718192021222324252627282930313233343536372 unmodified lines404142434445468 unmodified lines55565758596061623 unmodified lines666768697071727374import osimport shutilimport sysfrom pathlib import Path5 unmodified linesTOOL = ROOT / "ccs"def stages(work, log, deadline):env = dict(os.environ, LD_LIBRARY_PATH=str(TOOL))lift(TOOL, work, log, deadline, ["--GNASM"], env=env)nasm = work / "nasm"assembly = nasm / "wc.asm"mapping = nasm / "wc.map"require_outputs(assembly, nasm / "__gmon_start__.c")_, opening, annotations = assembly.read_text().partition("\n%ifdef COMMENT\n")addresses, closing, _ = annotations.partition("\n%endif")if not (opening and addresses and closing):raise RuntimeError("FoxDec did not emit the address mapping in the NASM output.")mapping.write_text(addresses + "\n")yield "Lifted wc to NASM", ()run_command(["nasm", "-felf64", "-g", "-F", "dwarf", "-o", "wc.o", "wc.asm"], nasm, log, deadline)run_command(["gcc", "-c", "__gmon_start__.c", "-o", "__gmon_start__.o"], nasm, log, deadline)# Keep the end-of-data label distinct from the stderr copy relocation.(nasm / "layout.ld").write_text("SECTIONS { . = ALIGN(32); } INSERT BEFORE .data;\n")run_command(["gcc", "-g", "-m64", "-nostartfiles", "-fgnu-tm", "-Wl,-T,layout.ld","-o", "a.out", "wc.o", "__gmon_start__.o"], nasm, log, deadline)require_outputs(nasm / "a.out")yield "Recompiled the NASM", ()certificate = work / "certificate"certificate.mkdir()2 unmodified linesif not blocks:raise RuntimeError("The generator produced no block theories.")require_outputs(certificate / "PCode_wc.thy", certificate / "PCode_wc_mapping.thy", *blocks)yield "Generated the certificate with Ghidra", ()shutil.copyfile(TOOL / "PCode.thy", certificate / "PCode.thy")(certificate / "ROOT").write_text(8 unmodified lines"-d", "/opt/Word_Lib", "-D", ".", "FoxDec_Certificate"],certificate, verification, deadline,)yield "Isabelle2023 verified PCode_wc.thy", [verification,assembly, mapping, *sorted(certificate.glob("*.thy")),certificate / "ROOT", log,]3 unmodified linesstart = monotonic()with TemporaryDirectory(prefix="foxdec-ccs-") as directory:work = Path(directory)try:for stage, _ in stages(work, work / "run.log", start + float(timeout)):print(f"{monotonic() - start:.1f}s · {stage}", flush=True)print(read_preview(work / "verification.log", tail=True))except (RuntimeError, TimeoutError, OSError):for log in ("run.log", "verification.log"):
53 unmodified lines545556575859606162636465665 unmodified lines727374757677788 unmodified lines878889909192939453 unmodified linesraise RuntimeError(f"Expected output was missing or empty: {path.name}.")def lift(tool, work, log, deadline, options):for name in ("wc", "wc.entry"):shutil.copyfile(tool / "binary" / name, work / name)run_command([tool / "bin/foxdec-exe", "-c", tool / "config/config.dhall", "-d","./", "-n", "wc", "-i", "BINARY", *options],work, log, deadline,)5 unmodified linesif not functions:raise RuntimeError("FoxDec produced no per-function results.")require_outputs(*files, *functions)return "", [*files, *functions, log]def pldi(work, log, deadline):8 unmodified linesexpected = "construct-ssm: Don't know where to return: val == 64varRSP00, pred =="if error.code != 2 or not read_preview(diagnostics).startswith(expected):raisenote = " · Reproduced the release’s unresolved return diagnostic."require_outputs(analysis)if not diagnostics.is_file():raise RuntimeError("The PLDI example produced no diagnostics file.")return note, [analysis, diagnostics, log]53 unmodified lines545556575859606162636465665 unmodified lines727374757677788 unmodified lines878889909192939453 unmodified linesraise RuntimeError(f"Expected output was missing or empty: {path.name}.")def lift(tool, work, log, deadline, options, *, env=None):for name in ("wc", "wc.entry"):shutil.copyfile(tool / "binary" / name, work / name)run_command([tool / "bin/foxdec-exe", "-c", tool / "config/config.dhall", "-d","./", "-n", "wc", "-i", "BINARY", *options],work, log, deadline, env=env,)5 unmodified linesif not functions:raise RuntimeError("FoxDec produced no per-function results.")require_outputs(*files, *functions)yield "", [*files, *functions, log]def pldi(work, log, deadline):8 unmodified linesexpected = "construct-ssm: Don't know where to return: val == 64varRSP00, pred =="if error.code != 2 or not read_preview(diagnostics).startswith(expected):raisenote = "Reproduced the release’s unresolved return diagnostic."require_outputs(analysis)if not diagnostics.is_file():raise RuntimeError("The PLDI example produced no diagnostics file.")yield note, [analysis, diagnostics, log]
Dockerfile+6-7
README.md+1-1
app.py+21-8
catalog.md+1-1
ccs.py+21-16
runner.py+5-5