s3team / Polyglot

MIT License
104 stars 18 forks source link

Parser failed to parse 'BuiltinObjFile' directory files #9

Closed Yeaseen closed 1 year ago

Yeaseen commented 1 year ago

I came across the following issue when I tried to fuzz the gcc compiler. I compiled the gcc with afl-gcc and set the following directories properly. I just used python2 as python is no longer in Ubuntu. make on Polyglot worked fine.

Screenshot 2023-09-03 at 12 16 30 AM

But after running the fuzzing I found this error:

Screenshot 2023-09-03 at 12 24 18 AM

Parsing failed here::

Screenshot 2023-09-03 at 12 13 04 AM

Hence, the following incorrect data: It says that the target application doesn't get the correct input (syntax error!) which is because the parser failed to parse the files under initial build in files directory.

Screenshot 2023-09-03 at 12 13 43 AM

After backtracing, I found the parser in typesystem.cpp failed to parse.

Screenshot 2023-09-03 at 12 26 44 AM

Did I miss something here? Thnak you!

zr950624 commented 1 year ago

Hi Yeaseen,

Thanks for using our tool. The BuiltinObjFile refers to the path of your builtin object definition. In your case, you use the grammar path for that, so it will fail to parse.

Please look at the example in grammar/solidity_grammar/builtin to know how to set up your builtin objects.

Yeaseen commented 1 year ago

Your reply is great. But it's all the same. Configured the path and added a block:

Screenshot 2023-09-03 at 2 43 27 AM

Now there's parsing failure. But afl is still saying syntax error:

Screenshot 2023-09-03 at 2 46 17 AM

So in the seed inputs, I tried with both a main function and without any main function:

Screenshot 2023-09-03 at 2 49 08 AM

I am still uncertain whether my seed inputs are ok or not. It would be great for me if you provide me with a block sample and a test input for the gcc. Thank you again!!

Yeaseen commented 1 year ago

The error is in the AFL_Replace_Mutate/afl-fuzz.c file, where the currently mutated file is being saved with a Java extension(search for ./cur_input.java) not desired for any target application that doesn't accept a Java file. You can still use AFL's "-f" option that accepts a modified target name.