Skip to content

Relic 1.2.0

Choose a tag to compare

@github-actions github-actions released this 09 Nov 16:20
e3481f7

Relic 1.2.0

This release adds binary diffing. relic diff OLD NEW matches the functions of two builds of a
program, the way BinDiff and Diaphora do, and tells you which functions changed, which were
added and which were removed. That's where you start when you want to know what a vendor's
patch fixed, or when you want to carry your work over to a new build.

Download

System File
Windows (x86-64) relic-1.2.0-windows-x86_64.exe
Linux (x86-64) relic-1.2.0-linux-x86_64.tar.gz: one file, relic
macOS, Apple silicon relic-1.2.0-macos-arm64.zip: Relic.app
macOS, Intel relic-1.2.0-macos-x86_64.zip: Relic.app

The macOS app isn't signed, so right-click it and choose Open the first time. The wheel is
attached too, for pip (Python 3.10+).

relic diff

Take tests/src/vuln.c, replace its gets with fgets, add a function, and build both versions
stripped:

$ relic diff chall chall_fixed
17 matched (16 identical, 1 changed), 1 added, 0 removed

similar         old         new  how      name
  92.0%      40160c      40160c  calls    sub_40160c

added:
      401708  sub_401708  (25 bytes)

-f shows how one function changed. Add -d to compare the pseudocode instead of the
instructions:

$ relic diff chall chall_fixed -f sub_40160c -d
sub_40160c: 0x40160c -> 0x40160c, 92% alike (matched by calls)
--- old:sub_40160c @ 0x40160c
+++ new:sub_40160c @ 0x40160c
@@ -1,8 +1,8 @@
 void sub_40160c(void)
 {
-    char buf_48[64];  // ret-0x48
+    char line[64];  // ret-0x48
 
     puts("name?");
-    gets(buf_48);
-    printf("hello %s (%d)\n", buf_48, sub_401539(buf_48));
+    fgets(line, 64, stdin);
+    printf("hello %s (%d)\n", line, sub_401539(line));
 }

How it works:

  • Comparing. Functions are compared by their code with everything that depends on where
    they're linked taken out (the same normalization as the Lumina fingerprints). Calls to imported
    and library functions are kept by name. A function that only moved, or lost its symbol, counts
    as identical.
  • Matching. Matches are found from the surest evidence to the weakest: code that appears
    once in each build and is identical in both, then a name that appears once in each build (a
    symbol, a library signature's name or your own, never a generated sub_...), then the call
    graph (the callees and callers of functions already matched), and last, whatever is left that
    is clearly the same function.
  • Output. Changed functions are listed most changed first. --all lists the unchanged ones
    too, and --json gives a script the whole result. From Python, use
    relic.analysis.bindiff.diff(old_analysis, new_analysis).

It's quick enough for real programs: diffing bash against itself takes 9 seconds, and diffing
two unrelated programs of that size takes about 17.

Under the hood

  • The decompiler's prepare step was a single 140-line function. It's now split into named
    stages: joining values the ABI splits, the result, the parameters, the result's width, and
    the clean-up passes. The pseudocode for every test binary comes out byte-for-byte the same.
  • The Lumina fingerprint's normalization is now a function of its own, which relic diff uses
    too. Fingerprints haven't changed, so existing stores still match.

SHA-256

Check a download with sha256sum -c SHA256SUMS --ignore-missing (macOS: shasum -a 256 -c).

1123c7d6cfa27e239a5a37168799b133cb17913814726ae07a18993acdaebb0c  relic-1.2.0-linux-x86_64.tar.gz
985600a4a2da66e16cbf3c45d380e2abc32ff38daa86d8cdeae2116fa3d8a688  relic-1.2.0-macos-arm64.zip
45171c07f23c9d12a386bf76ec2eb1dce5e888850074e542d937c6a31280579f  relic-1.2.0-macos-x86_64.zip
a12222c9234edb9ed126a1203561d041909a7587b230d19c6e228af52f9f43d7  relic-1.2.0-windows-x86_64.exe
87884a62f0ac729fe883339cedd735b8a813c6268eeb4b8093ee7e971b81b3e7  relic_re-1.2.0-py3-none-any.whl
5b9d1fe99d4c22094ea14ad9ffc60f796fb087d8e90b935626c0174e662dc9a5  relic_re-1.2.0.tar.gz