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.
|
5 years ago | |
---|---|---|
bin | 5 years ago | |
mirage | 5 years ago | |
pkg | 6 years ago | |
src | 5 years ago | |
.gitignore | 6 years ago | |
.merlin | 5 years ago | |
CHANGES.md | 6 years ago | |
LICENSE.md | 6 years ago | |
README.md | 5 years ago | |
_tags | 6 years ago | |
myocamlbuild.ml | 6 years ago | |
opam | 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