You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Your Name 9a65bdc0bf unikernel: split input packets on newline 5 years ago
bin Make vulnerable 5 years ago
mirage unikernel: split input packets on newline 5 years ago
pkg initial 6 years ago
src better input validation 5 years ago
.gitignore initial 6 years ago
.merlin add instructions for mirage build 5 years ago
CHANGES.md initial 6 years ago
LICENSE.md initial 6 years ago
README.md better input validation 5 years ago
_tags initial 6 years ago
myocamlbuild.ml initial 6 years ago
opam more info in README 5 years ago

README.md

WIP

An example of insecure programming in OCaml.

The purpose is to let people experiment with the consequences of insecure programming practices under various OCaml target platforms, and the impact of exploit mitigation features.

This repo consists of a library, hackme, and a MirageOS unikernel exposing the library over TCP.

The MirageOS unikernel will listen for TCP connections on 10.0.0.2 port 1337 by default (this can be overridden with --port=1234 and --ipv4=10.1.2.3/24 at invocation time)

There is also a native unix application, test.native.

Installing the library

These commands are to be run from inside this repo root:

opam pin add -k git hackme `.#HEAD`

Running the demo unix utility

ocaml pkg/pkg.ml build

./_build/bin/test.native help

Compiling the mirage utility for the Solo5 target

cd mirage
opam install mirage hackme logs lwt mirage-bootvar-solo5 \
     mirage-clock-freestanding mirage-logs \
     mirage-net-solo5 mirage-random mirage-runtime mirage-solo5 \
     mirage-types mirage-types-lwt ocamlbuild ocamlfind solo5-bindings-hvt tcpip

mirage configure -t hvt

mirage build

make

./solo5-hvt --net=tap0 --mem=32 hackme.hvt --ipv4=10.7.33.1/24

Compiling and running the mirage utility for the unix target on Linux

cd mirage

opam install mirage

mirage configure -t unix

make depend

make

since the unikernel configures its own tap device, it needs capability to do

so. alternatively you can run it as root:

sudo setcap cap_net_admin+ep "$(realpath main.native)"

./main.native --ipv4=10.7.33.1/24


Once the unikernel has set up a tap device, you can connect to it over TCP:
```shell
# you need to set an IP for the tap device:
# (since the unikernel creates a new tap device for each invocation,
#  you need to do this every time you restart it.)
sudo ifconfig tap0 10.7.33.2

nc -vn 10.7.33.1 1337
(UNKNOWN) [10.7.33.1] 1337 (?) open

> motd-sub 0
1234, Hello world!
> help