Skip to content

Instantly share code, notes, and snippets.

@jtpaasch
jtpaasch / primus_set_mem.ml
Created February 19, 2019 22:02
Example of a Primus plugin that sets memory values before executing a subroutine.
(*
MAKEFILE
plugin = primus_set_mem
all: clean build install
build:
bapbuild -pkg bap-primus -tags 'warn(A)' $(plugin).plugin
@jtpaasch
jtpaasch / Z3.quickstart.md
Created February 21, 2019 21:09
Simple Z3 tutorial

Z3

The REPL

In utop:

#use "topfind";;
#require "Z3";;
@jtpaasch
jtpaasch / Syllogism_with_dependent_type.v
Last active April 1, 2019 12:16
Syllogisms in Coq (using classical logic, and dependent types).
Module SigmaTry.
Inductive D : Type :=
| a
| b
| c.
Definition P (x : D) : Prop :=
@jtpaasch
jtpaasch / Assembly_cheat_sheet.md
Created April 1, 2019 12:34
Quick reminder of all the little things I forget.
@jtpaasch
jtpaasch / Dune.md
Created April 9, 2019 18:36
Notes on using `dune` for OCaml.

Dune

A first pass

A library and then an executable that uses that library.

A simple library

Create a folder called foo:

@jtpaasch
jtpaasch / Standalone_primus_machine.ml
Created May 28, 2019 18:20
Example of a simple standalone Primus machine.
(** MAKEFILE:
build = _build
exe = main.native
all: clean build
clean:
rm -rf $(exe)
rm -rf $(build)
@jtpaasch
jtpaasch / CPDT.warmup.v
Created September 19, 2019 12:46
Annotated version of the warmup from Adam Chipala's _Certified Programming with Dependent Types_.
Require Import String.
(* Examples by Adam Chlipala *)
(** * Warm-up: natural numbers *)
Inductive nat := O | S (n : nat).
Fixpoint plus (n m : nat) : nat :=
match n with
| O => m
| S n' => S (plus n' m)
@jtpaasch
jtpaasch / ps1.hs
Created September 27, 2019 13:51
6.820 Program Analysis - Problem Set 1
-- ***************************************************
-- 6.820 - Program Analysis - Fall 2019
-- PROBLEM SET 1
-- ***************************************************
-- ---------------------------------------------------
-- Problem 1
@jtpaasch
jtpaasch / SimpleMonadFunctorApplicativeExample.hs
Created April 3, 2020 20:46
Nice little example of monads, functors, and applicatives, from https://stackoverflow.com/a/47932927
- Otherwise you can't do the Applicative instance.
import Control.Applicative
-- Simple function
foo :: String -> String
foo x = do
x ++ "!!!"
-- Helper for printing Monads
@jtpaasch
jtpaasch / my_bap_loader.ml
Created August 27, 2020 21:20
Custom BAP loader
module Loader = struct
let empty_with_program filename prog =
let arch = `unknown and code = Memmap.empty and data = Memmap.empty in
Project.Input.create arch filename ~code ~data
~finish:(fun proj -> Project.with_program proj prog)
let load filename =
let prog = Program.create () in (* empty prog for now *)
empty_with_program filename prog