Hi Puzzor, Michal
On 17/03/16 16:36, Sj Puzzor wrote:
> I previously fuzzed cgi with afl.
> You need to disable forkserver indeed, or there won't be more path in
> the true target. I didn't see your code.
> I used a wrapper too but I disabled forkserver.
> The problem is caused by setenv in my understand. Qemu has an option to
> set env with -E, and it will process it to apply an environment for the
> target, but with forkserver, you cant change that env after the first
> run even if you secondly run qemu with a different option of -E. You can
> experiment it with a cgi program you write it yourself.
@Puzzor: Your right, setenv doesn't seem to work with -Q.
I actually started to write simple cgis for debugging. The open source
case where I compile the cgi with afl-clang and use the wrapper I wrote
(see closed-source-afl-showmap.sh in [1]) works fine. Now I need to
figure out the "closed source" part. So far nothing worked for me.
You mentioned the -E option of QEMU. How did you set that one?
On 17/03/16 17:04, Michal Zalewski wrote:
> Here's an idea: modify afl_forkserver() in afl-qemu-cpu-inl.h.
> Specifically, look for this:
>
> if (!child_pid) {
>
> /* Child process. Close descriptors and run free. */
>
> afl_fork_child = 1;
> close(FORKSRV_FD);
> close(FORKSRV_FD + 1);
> close(t_fd[0]);
> return;
>
> }
>
> ...and just before "return;", read stuff from stdin or input file and
> put it into env variables. That may give you just what you're looking
> for.
@Michal: I tried adding a simple setenv("HTTP_HOST", "TESTTESTTEST", 1);
in afl-qemu-cpu-inl.h where you said (and cleaned and newly build qemu
support), however, the variable doesn't get set (tested with
closed-source-afl-showmap.sh in [1]) and the example child process won't
print it. Any other ideas?
[1]
https://github.com/floyd-fuh/afl-cgi-wrapper
cheers,
floyd