Code Monkey home page Code Monkey logo

cpytraceafl's People

Contributors

risicle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cpytraceafl's Issues

Lack of Demonstration/Fuzzing Example

Hello! This project looks very interesting. I was looking for something just like this. I am looking to test this to see if it could potentially be used for fuzzing some python code that I am auditing. Is there any way that you could show a quick example of the commands that are typically used to launch a fuzzing instance with cpytraceafl? For example, I would find a short tutorial describing how to install and run your existing examples to be perfect for this.

When I attempt to run the examples, I get KeyError: __AFL_SHM_ID I believe that everything is installed correctly, but I am just attempting to run the examples in the incorrect way. However, I am unclear as to whether this is to be run installed with cpython that has already been instrumented by AFL, standard cpython (without instrumentation), or something else so it is possible that I messed up the install as well. Thank you
`

when and how 'rewriting_compile' function is called?

i read "rewriter.py" source code, "builtins.compile" confused me

@functools.wraps(original_compile)
    def rewriting_compile(*args, **kwargs):
        ...
builtins.compile = rewriting_compile

what i understand at first is "compile function has been hooked, when run 'python xxxx.py' and compile the code, builtins.compile will be called first, so rewriting_compile function will be called".

but after i run test code as below, i am confused.

import dis
import functools
import random
import os
import _frozen_importlib_external
import builtins
from sys import version_info
from ast import PyCF_ONLY_AST

original_compile = builtins.compile

@functools.wraps(original_compile)
def rewriting_compile(*args, **kwargs):
    flags = (len(args) >= 4 and args[3]) or kwargs.get("flags") or 0
    print("rewriting_compile")
    return False

builtins.compile = rewriting_compile

print("end")

"rewriting_compile" will not be printed.

so my question is " when and how 'rewriting_compile' function is called".

How to use this tool?

Is there any steps to install or setup the tool. When I run the examples there are some error"ModuleNotFoundError: No module named 'cpytraceafl'" ,but I can't pip install cpyctraceafl.
And I want to know how to use this with AFL. Thanks very much!

Instrumentation could be faster

I was looking at tracehook_line_trace_hook in _tracehookmodule.c - the instrumentation you are doing is overly complex and therefore is very, very time consuming.

if the bytecode offset is something that does not change during fuzzing, why not solely use this information? maybe do some assessment of the value and e.g. if its always of minimum increments of 8 then do a (bytecode_offset >> 3) % MAP_SIZE and be done with it.
and if it is important that a lineno exits just check that it exists?
IMHO the multiplication just decreases speed and mixing the different values gives no benefit.

Try to remove everything that is not absolutely needed or can be precomputed somewhere else.

also this is useless:

uint32_t this_loc = state >> (32-afl_map_size_bits);

if the map size would change during a run, afl would not know about it anyway.

Expected Performance

Are there any expected performance metrics when fuzzing mixed python/c code? I attempted to run the pillow_pcx_example.py. In order to do that, I downloaded Pillow and built it with CC=afl-gcc and CXX=afl-g++ and then installed it.

When running the fuzzer, a single instance of the fuzzer seems to always execute at 3-4 execs/second. That seems slower than what I expected, is their any numbers that you can provide as to what you see there?

Additionally, is there a way to verify that the instrumentation is working? I provided in my input directory multiple files that should cause the code to go down different paths within the C portion of the Pillow code, however the when starting the fuzzer I received a message that no new instrumentation was detected with the additional test cases. Is there something that I could be doing wrong to cause that?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.