compiled with afl-gcc - No instrumentation detected

4.7k Views Asked by At

I want to fuzz my application with afl, but after replacing gcc with afl-gcc I still get the error: [-] PROGRAM ABORT : No instrumentation detected.

I have created a simple C program to debug the issue:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static int do_stuff(int fd) {
    char buffer[3];
    read(fd, buffer, sizeof(buffer));

    int size = atoi(buffer);

    char* str = malloc(size);

    read(fd, str, size);

    printf("'%s'\n", str);

    free(str);

    return 0;
}

int main(int argc, char** argv) {
    if (argc < 2)
        return 1;

    int fd = open(argv[1], O_RDONLY);

    if (fd < 0)
        return 2;

    int ret = do_stuff(fd);

    close(fd);

    return ret;
}

I compile it with afl-gcc main.c -o main. As input file I use echo "12 Hello World.foobar" > foo.txt

When I now run afl-analyze -i foo.txt ./main I get

afl-analyze 2.52b by <[email protected]>

[+] Read 22 bytes from 'foo.txt'.
[*] Performing dry run (mem limit = 50 MB, timeout = 1000 ms)...

[-] PROGRAM ABORT : No instrumentation detected.
         Location : main(), afl-analyze.c:1068

Am I missing something? I installed afl (2.52b-2) straight from the Ubuntu repositories (18.04).

1

There are 1 best solutions below

0
On

Probably the Memory Limit is too low. Try to set more memory size or set it as none.

afl-analyze -m none -i foo.txt ./main