• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created almost 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

scriptable strace

CircleCI

hatrace - scripted strace

Includes:

  • hatrace executable similar to strace
  • Haskell library to write sophisticated scripts

Use cases

  • General
    • Get all syscalls in a list and process them programmatically.
    • Audit high-assurance software systems.
    • Debug difficult bugs that occur only in certain rare situations.
    • Change the results of system calls as seen by the traced program.
  • Bug reproducers
    • Demonstrate how a program fails when a given syscall returns certain data.
    • Kill your build tool at the 3rd write() syscall to an .o file, checking whether it will recover from that in the next run.
  • Testing
    • Write test suites that assert how your code uses system calls, for correctness or performance.
    • Mock syscalls to test how your program would behave in situations that are difficult to create in the real world, for example verifying fault-tolerance in specific scenarios
    • Implement anomaly test suites like sqlite does, exhaustively testing whether your program can recover from a crash in any syscall.
  • Fuzzing
    • Insert garbage data into the program by changing syscall results or directly changing its memory contents.
    • Speed up your fuzzing by having full insight into the fuzzed program's behaviour.
  • Adding features to existing programs
    • Add "magic" support for new file systems without modifying existing programs (like this paper shows).
    • Add logging capabilities to programs that were designed without.

Building / Installing

  • Clone: git clone --recursive https://github.com/nh2/hatrace && cd hatrace
  • After fetching new changes, update submodules with: git submodule init && git submodule update --init --recursive
  • Building for development:
    • With Stack: stack build or even better stack test
    • With Cabal: cabal build or even better cabal test
    • Use a recent version of these tools, e.g. at least Stack >= 2.
  • Installing:
    • With Stack: stack install
    • With Cabal: cabal install

Work in progress

This software is work in progress.

The hatrace executable is extremely basic and can't do much.

While syscall names are automatically generated, detail data needs to be implemented by hand and is done for only a few so far. Help to add more is appreciated.

However, the Haskell API to write scripts can already do a lot. Take a look at the test suite for examples.

TODO list for contributors

If you find any of the below topics interesting give it a shot! It is recommended to file an issue when picking up one of the tasks to coordinate and avoid doing duplicate work.

  • Implement all the syscalls
  • Remembering syscall arguments in a PID/TID map
  • Support for sysenter
  • reading tracee memory more efficiently (see how strace does it)
  • Helpers for modifying memory
  • One real-world example each for the use cases on Use cases above
  • hatrace executable features:
    • JSON output
    • Coloured output
    • Timing strace -ttt and -T
    • special run modes tailored to specific tasks (e.g. execve tree)
      • Show hanging syscalls
      • Filter away GHC's spammy output around sched_yield, futex and signals
  • Support for setting options (for example enabling/disabling tracing into subprocesses, like strace -f)
  • Equivalent to strace -y (tracking origin of file descriptors, printing paths)
  • Equivalent to strace -c (keeping counts, summary statistics)
  • Something similar to strace -y but telling which PID is which executable from /proc/PID/exe
  • Extraction of PTRACE_EVENT detail information (see section PTRACE_SETOPTIONS in man 2 ptrace)
  • Filtering based on string buffer contents
  • PID remapping (e.g. to a range starting from 0) for better diffability of the output of multiple runs
  • Handling of exit() of the direct child (grand-child daemonisation)
  • Don't die on peekBytes returning EIO when the tracee passes invalid memory to the kernel; instead, peek only what's possible and print some info. That makes it possible to correctly trace processes that rely on e.g. SIGSEGV handlers.
  • Re-using strace's test suite for per-syscall tests
  • other TODOs in the code
  • Use it to do specific investigations in other programs:

More Repositories

1

static-haskell-nix

easily build most Haskell programs into fully static Linux executables
Nix
389
star
2

call-haskell-from-anything

Call Haskell functions from any programming language via serialization and dynamic libraries
Haskell
386
star
3

strace-pipes-presentation

Presentation: Debugging across pipes and sockets with strace
Python
149
star
4

nixops-tutorial

Tutorial for practical deployments with NixOps
Nix
108
star
5

haskell-cpu-instruction-counter

Measuring CPU instructions in Haskell using Linux Performance Counters
Haskell
85
star
6

haskell-from-python

Example how to call Haskell from Python easily (using ctypes.cdll.LoadLibrary)
Haskell
60
star
7

nix-binary-cache-proxy

An NGINX caching proxy to serve the cache.nixos.org binary cache from your local network, ready-to-deploy with nixops
Nix
51
star
8

link-with-lld-example

Example how to link Haskell programs very quickly with lld
Haskell
47
star
9

haskell-jobs-statistics

37
star
10

haskell-ordnub

Data.List.nub is O(n²). This one is O(n log n) by requiring an Ord instance.
HTML
31
star
11

hemokit

Haskell library for the Emotiv EEG, inspired by the Emokit code
Haskell
31
star
12

nixos-vm-examples

Examples of how to build and run NixOS VMs with nix
Nix
29
star
13

nixos-ami-building

Methods for building custom NixOS AMIs
Shell
28
star
14

arduino-a7105

Fixed code from http://www.instructables.com/id/Easy-Android-controllable-PC-Interfaceable-Relati/step6/Arduino-Software/
Arduino
23
star
15

housescan

Building-scale interior 3D reconstruction with KinectFusion
Haskell
22
star
16

asus-xtion-fix

For making the Asus Xtion work on USB 3.0 on Linux (e.g. for PCL)
17
star
17

loop

Fast loops for Haskell (for when GHC can't optimize forM_), with benchmarks
HTML
17
star
18

gmail-spamfilters-paypal-security-messages

Screenshot of how GMail classified PayPal security message as spam
16
star
19

hackage-download

Script to download all of Hackage
Python
14
star
20

dentls

Fixed version of the program at https://serverfault.com/a/328305/128321
C
14
star
21

haskellerz-async-tutorial-2020

Async tutorial (my HaskellerZ 2020 talk)
Haskell
13
star
22

network-house

Haskell data structures and parsers for Ethernet, TCP, UDP, IPv4, IPv6, ICMP, DHCP, and TFTP packages. Extracted from the House project network stack.
Haskell
13
star
23

diskorder

read files in physical order to reduce hard drive seeks
Python
12
star
24

niceshare

GUI for gstreamer-based screen sharing
Python
11
star
25

aesonbson

Mapping between Aeson's JSON and Bson objects
Haskell
11
star
26

haskell-static-data-sqlite

Example how to append data to a Haskell executable using sqlite
C
11
star
27

shared-memory

Haskell shared memory library
Haskell
10
star
28

sublime-text-move-tabs

Arranging tabs in Sublime Text like in Chrome
Python
9
star
29

conduit-concurrent-map

Concurrent, order-preserving mapping Conduit for Haskell
Haskell
8
star
30

kibana-importer

Imports a Kibana export.json file into Kibana
Python
8
star
31

iso8601-time

Convert to/from the ISO 8601 time format in Haskell
Haskell
7
star
32

nixops-gluster-example

Advanced nixops deployment example: GlusterFS
Nix
7
star
33

haskell-todos

nh2's Haskell TODO / wish list for Open Source tasks to improve Haskell
6
star
34

nixos-configs

My NixOS configs
Nix
6
star
35

lambdabot-zulip

Lambdabot for Zulip Chat
Haskell
6
star
36

eventstreamexamples

Example Turbogears project for implementing server-side events in Python
Python
6
star
37

custom-hackage

Script that allows to run your own hackage with select packages/versions that you drop in
Shell
6
star
38

ghc-mod-socket

Makes ghc-modi behave like hdevtools
Haskell
6
star
39

call-python-via-msgpack

Call Python from Haskell by FFI-via-serialisation over MessagePack
Haskell
6
star
40

ar-timestamp-wiper

Wipes time stamps from .a files (like ar -D)
Haskell
5
star
41

proctest

A Haskell library for testing interactive command line programs
Haskell
5
star
42

selfrestart

Allows restarting the currently running Haskell executable
Haskell
5
star
43

lz4-frame-conduit

Haskell Conduit implementing the official LZ4 frame streaming format
Haskell
5
star
44

chrubuntu-anyos

Run any Linux distro on your legacy Chromebook, ChrUbuntu style
Nix
4
star
45

multishake

A Shake build system that builds a cabal project together with a set of dependencies available in source
Haskell
4
star
46

darcs-fastconvert

Import/export git repos to/from darcs. Also contains darcs-bridge for bidirectional synchronisation. Forked from http://darcsden.com/mornfall/darcs-fastconvert to fix build on newer platforms.
Haskell
4
star
47

git-rewrite-history-on-patches

Script to replace words in a range of recent git commits
Python
3
star
48

stack-nix-caching-example

Example of how to use nix Haskell binary packages with stack
Nix
3
star
49

haskell-netpbm

Loading PBM, PGM, PPM image files in pure Haskell
Haskell
3
star
50

nixos-blockdevice-attachment-explanations

Article about block device file-system auto-creation on NixOS
3
star
51

quadcopter-simulation

Rust
3
star
52

nixos-vm-building

Example of how to iterate on a NixOS config in a local VM.
Shell
3
star
53

vinput

Virtual input devices on Linux for multitouch tables and other funny stuff.
Python
3
star
54

sublime-toggle-line-numbers

Adds a command to enable/disable line numbers for the current buffer.
Python
3
star
55

Abacus

A Better Alignment Plugin for Sublime Text 2 `⌘⌥^ ]`
Python
3
star
56

hello_wayland_haskell

Example Wayland program (client) in Haskell
Haskell
2
star
57

internal-contstrained-pki

Safely shareable TLS root CA for .internal networks using Name Constraints
Shell
2
star
58

blog

nh2's blog posts
Haskell
2
star
59

haskell-pdxhouse

Git mirror of the Haskell House operating system project (https://code.google.com/p/pdxhouse)
Haskell
2
star
60

cv

JavaScript
2
star
61

bupstash-kopia-comparison

Evaluation benchmarks of backup tools bupstash and kopiia
2
star
62

wordwang

Haskell
2
star
63

reinterpret-cast

Memory reinterpretation casts for Float/Double and Word32/Word64 in Haskell
HTML
2
star
64

KinectStreamer

Streams Kinect data (such as the depth image) as a TCP server
C#
2
star
65

lambdanumbers

Haskell
2
star
66

staticfetcher

Fetches static files.
Python
2
star
67

jsschema

Object structure checking for the rescue!
JavaScript
2
star
68

AntiMersenne

Predicting Python's Mersenne twister PRNG for 30c3 CTF, with Python calling Java, yeah
Java
2
star
69

obse

Git mirror of the Oblivion Script Extender (http://obse.silverlock.org)
C++
2
star
70

dsa42

Spieleprogrammieren im Kurs "Extreme Programming" auf der Deutschen Schülerakademie Schelklingen 2008
Java
2
star
71

temperature-sensor-server

Haskell server to serve temperature from Arduino
Haskell
2
star
72

linux-bad-core-scheduling-investigation

Write-up of a Linux kernel bisection to find a scheduler bug that results in reduced performance
Python
2
star
73

udp-splitter

Haskell program to forward incoming UDP packets to N many targets
Haskell
2
star
74

empty-angular-project

A browser project template using: angular, coffeescript, stylus, testacular, bower, grunt.
CoffeeScript
2
star
75

psqueue-benchmarks

Benchmark of Haskell Priority Search Queue implementations
Haskell
2
star
76

flippi

Flippi: a Wiki clone written in Haskell (http://www.flippac.org/projects/flippi/). I have nothing to do with this project nor do I maintain it - I just fixed the build because someone in Haskell-Cafe had a problem with that.
Haskell
2
star
77

ghc-generics-deriving-is-slow

Reproduction for `deriving Generic` being quadratic in the Glorious Haskell Compiler
Haskell
2
star
78

gtkpasswordentry

A GTK text box for passwords with an icon to show the password in plain text
C
1
star
79

jquery-elastic

JavaScript
1
star
80

inner-loop-benchmarks

Criterion benchmarks for http://neilmitchell.blogspot.co.uk/2014/01/optimising-haskell-for-tight-inner-loop.html
Haskell
1
star
81

hspec-experiment

Test trees as modifiable data for hspec
Haskell
1
star
82

WashNGo

A Haskell EDSL for programming Web applications. I have nothing to do with this project nor do I maintain it - I just fixed the build because someone in Haskell-Cafe had a problem with that.
Haskell
1
star
83

dig-5-seconds-hang

Linux kernel dropped DNS requests investigation (visible to iptables but not Wireshark)
1
star
84

e57-dump

Simple executable to dump .e57 file structure as text for quick inspection
Meson
1
star
85

copier

Tool to copy files in parallel for use on networked file systems. Written in Haskell
Haskell
1
star
86

haskell-socketio

(Unfinished) Haskell server-side engine.io and socket.io implementation. Avoids real-time at all cost!
Haskell
1
star
87

ghc-control-monad-trans-unlift-stack-overflow

Reproduction for GHC 8.0 stack overflow
Haskell
1
star
88

thinkpadlight-client

A simple library use thinkpadlightd
Python
1
star
89

ghc-bug-th-loading

Test case for a GHC bug concerning the unnecessary loading packages when TH is used
Haskell
1
star
90

parallel-map-experiments

Haskell experiments around monad-par, parallel, parMap and spark scheduling
Haskell
1
star
91

ghc-omit-interface-pragmas-dsImpSpecs-bug

Repro for GHC 7.8.4 panic: dsImpSpecs on SPECIALISE pragma with -fhpc enabled
Haskell
1
star
92

futhark-featurematch-2nn

Futhark implementation of two-nearest-neighbour brute-force quadratic feature matching.
Futhark
1
star
93

number-streams

Haskell library for calculating properties on streams of numbers, e.g. moving sums and averages
Haskell
1
star
94

getDirectoryContents-benchmarks

Benchmarking Haskell's getDirectoryContents function and alternatives
Haskell
1
star
95

onezerocat

Tools for translating binary files into 1-0-sequences and vice versa
Python
1
star
96

jquery-doublepostpreventer

Disabling submit buttons after submit
JavaScript
1
star
97

thinkpadlightd

A server for your ThinkPad's enlightenment
Python
1
star
98

u51

Web password manager written in Python/Django
JavaScript
1
star
99

th-recomp-test

Small test project for GHC issues related to the `[TH]` recompilation reason
Haskell
1
star
100

ghc-socket-test

Test case for socket functionality in https://ghc.haskell.org/trac/ghc/ticket/13497
Haskell
1
star