-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instrumentation output varies across runs #111
Comments
Hi Ivan, apologies for hijacking this thread but it looks like finally someone found my blog useful more or less! 😅 (your comments are more than welcome though!) Hey Mostafa, so to begin with from the attached coverage files it looks like you are running them on a 64bit version:
My environment is a 32bit version, including the compiled harness where I'm getting the following coverage:
Your coverage looks good honestly, but if you are running 64bit version run the 64bit version of drrun and afl-fuzz as well, and generally try not to mix 32bit and 64bit (maybe that's the reason you can't see any coverage with the Lighthouse plugin?) Regarding the samples, before you try to start the whole fuzzing campaign I included the 'Coprus minimisation' section, where instead of trying to throw a few hundred files, try to minimise them and then start your campaign with the minimised cases as the initial seed files. As I mentioned, I had to create this simple bash liner (running via Cygwin):
because the way that
Notice how the harness was indeed executed 10 times and I correctly hit the succeeded message.
This is a very good indication that my samples are well defined, and I can continue with the fuzzing scenario. Also, I realised that the harness is a bit buggy, as in if you provide a file that doesn't exist you'll get back Hope that helps a bit and good luck! Edit: I always to like to provide absolute paths than relative ones: From your last command, I'm assuming that both XMLValidate.exe and test.xml are located on |
Hey Mostafa, That's a nice analysis. One thing to note about drcov is that it only captures a basic block once (when that basic block is executed for the first time), unlike afl/WinAFL that have a counter. Looking at the output of showmap, it's possible some basic blocks got executed different number of times during different runs. This would explain different output of showmap and the same output of drcov. Unfortunately, it's difficult to tell more without knowing which basic blocks in which function(s) got executed different number of times and why. If you want to pursue this further, that would be an interesting information to have. Perhaps by comparing those variable blocks with what you have in the drcov logs could help you identify them. This is how WinAFL calculates the counter offset for a block: https://github.com/ivanfratric/winafl/blob/master/winafl.c#L275-L276 |
Thanks Symeonp I will try to unify to x64 or x32, by the way, the blog is awesome I am sad it only contains one tutorial :) Thanks Ivan, in case unifying the architecture didn't solve it I will try to dig deep by inspecting the bitmaps that got executed different times. |
Hi Ivan, |
In the basic block coverage mode (default), the first number is (relative virtual address of basic block)%65536, see the lines of code I linked in the previous comment. The second number is the counter (how many time have the basic blocks corresponding to the first number been executed). S If you want to get actual addresses, you can increase the MAP_SIZE in these places |
Another thing to watch for is that in windows 10 in Wow64 the stack alignment that the process starts with is not % 8 but % 4, which causes memcpy to execute different paths (AVX / SSE instruction require alignment). I start each harness by aligning the stack. |
@yoava333 what is the best way to do that? |
I use something like this: #include <iostream>
int __declspec(noinline) _main(int argc, char * argv[]) {
int a = 0;
printf("stack alignment = %d\n", ((size_t)&a) % 8);
return 1;
}
int main(int argc, char * argv[]) {
size_t a = 0;
if (((size_t)&a) % 8 != 0) {
printf("alignment != 8\n");
alloca(4);
}
else {
printf("alignment == 8\n");
}
return _main(argc, argv);
} |
Hello Ivan,
I was following the tutorial for msxml fuzzing here "https://symeonp.github.io/all_posts.html". I have followed the same steps but WinAFL always warn me because somehow it sees different paths when executing the same sample, I think this results in false positive samples being placed in the queue.
I tried to investigate the issue, I used afl-showmap to print the bitmap of the same sample twice and I compared the output it is shown in the attachments.
Also, I tried
drrun -t drcov
twice on the same sample and loaded the coverage files in IDA to compare them, I didn't see any difference.This is the code I used compiled by VS2017 optimization disabled.
I have seen a similar thread to this issue but it was marked as an issue in the application itself, and I don't think this is the case here as I am following the same steps in the tutorial.
Thanks,
Mostafa
drcov.XMLValidate.exe.11728.0000.proc.log
drcov.XMLValidate.exe.06916.0000.proc.log
The text was updated successfully, but these errors were encountered: