DragonFlyBSD Kernel Audit
DF-2663 / xxtest.c
← back to finding ↓ download raw
#include <stdio.h>
#include <stdint.h>
#define XXH_STATIC_LINKING_ONLY
#include "xxhash.h"
int main(void) {
    FILE *f = fopen("/root/poc/base.img", "rb");
    static unsigned char buf[65536];
    struct { long off; int n; } cases[] = {
        {0x1800000, 1024}, {0x1800800, 1024}, {0x1800c00, 1024}, {0x1c00000, 65536}, {0x1400400, 1024}
    };
    for (unsigned i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) {
        fseek(f, cases[i].off, SEEK_SET);
        fread(buf, 1, cases[i].n, f);
        printf("xxh64(%#lx,%d) = %016llx\n", cases[i].off, cases[i].n,
            (unsigned long long)XXH64(buf, cases[i].n, 0x4d617474446c6c6eULL));
    }
    fclose(f);
    return 0;
}