Code Monkey home page Code Monkey logo

Comments (5)

mgayanov avatar mgayanov commented on May 23, 2024 1

I found out that instrumenting bin/Debug/net6.0/Jil.dll solves the issue.

Instrumenting ./jil.2.16.0/lib/netstandard2.0/Jil.dll, putting it to the root of the project and adding <ItemGroup>...</ItemGroup> doesn't work in my case.

dotnet build downloads fresh dll to bin/Debug/net6.0/Jil.dll.

from sharpfuzz.

jnyrup avatar jnyrup commented on May 23, 2024

Did you see the part in https://github.com/Metalnem/sharpfuzz#installation about patching afl-fuzz?

I use export AFL_SKIP_BIN_CHECK=1

from sharpfuzz.

mgayanov avatar mgayanov commented on May 23, 2024

Did you see the part in https://github.com/Metalnem/sharpfuzz#installation about patching afl-fuzz?

I use export AFL_SKIP_BIN_CHECK=1

Hello! Yes, I followed the instruction and patched AFL.

export AFL_SKIP_BIN_CHECK=1 didn't help.

from sharpfuzz.

mgayanov avatar mgayanov commented on May 23, 2024

Here is my container:

FROM ubuntu:22.04

RUN apt update && apt dist-upgrade -y

RUN DEBIAN_FRONTEND="noninteractive" apt -y install \
        build-essential \
        clang \
        git \
        libtool \
        m4 \
        cmake \
        automake \
        llvm \
        gcc-9-plugin-dev \
        golang \
        python3-pip 

# sharpfuzz
RUN apt install -y \
        dotnet6 \
        unzip  \
        wget && \
    cd /opt && \
    wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz && \
    tar -xvf afl-latest.tgz && \
    rm afl-latest.tgz && \
    cd afl-2.52b && \
    wget https://github.com/Metalnem/sharpfuzz/raw/master/patches/RemoveInstrumentationCheck.diff && \
    patch < RemoveInstrumentationCheck.diff && \
    make install && \
    cd .. && rm -rf afl-2.52b/ && \
    dotnet tool install --global SharpFuzz.CommandLine

ENV PATH=$PATH:/root/.dotnet/tools

ENV JIL_ZIP=jil.2.16.0.zip

ENV JIL_DLL=jil.2.16.0/lib/netstandard2.0/Jil.dll

RUN cd /opt && \
    mkdir json-example && \
    cd json-example && \
    wget -O $JIL_ZIP  https://www.nuget.org/api/v2/package/Jil/2.16.0 && \
    unzip $JIL_ZIP -d jil.2.16.0 && \
    sharpfuzz jil.2.16.0/lib/netstandard2.0/Jil.dll && \
    cp $JIL_DLL . && \
    dotnet new console

WORKDIR /opt/json-example

RUN echo 'using System;\n\
using System.IO;\n\
using SharpFuzz;\n\
namespace Jil.Fuzz\n\
{\n\
  public class Program\n\
  {\n\
    public static void Main(string[] args)\n\
    {\n\
      Fuzzer.Run(stream =>\n\
      {\n\
        try\n\
        {\n\
          using (var reader = new StreamReader(stream))\n\
          {\n\
            JSON.DeserializeDynamic(reader);\n\
          }\n\
        }\n\
        catch (DeserializationException) { }\n\
      });\n\
    }\n\
  }\n\
}' > Program.cs

RUN echo '<Project Sdk="Microsoft.NET.Sdk">\n\
  <PropertyGroup>\n\
    <OutputType>Exe</OutputType>\n\
    <TargetFramework>net6.0</TargetFramework>\n\
    <ImplicitUsings>enable</ImplicitUsings>\n\
    <Nullable>enable</Nullable>\n\
  </PropertyGroup>\n\
  <ItemGroup>\n\
    <Reference Include="Jil">\n\
      <HintPath>Jil.dll</HintPath>\n\
    </Reference>\n\
  </ItemGroup>\n\
</Project>' > json-example.csproj

RUN dotnet add package Sigil --version 4.7.0 && \
    dotnet add package SharpFuzz && \
    dotnet build

CMD mkdir -p corpus && \
    echo '{"a": 123}' > corpus/123 && \
    AFL_SKIP_BIN_CHECK=1 \
    afl-fuzz \
        -i corpus \
        -o findings \
        -t 5000 \
        -m 10000 \
        dotnet bin/Debug/net6.0/json-example.dll

To launch:

$ docker build -t sharp .
$ echo core | sudo tee /proc/sys/kernel/core_pattern
$ echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
$ docker run sharp
afl-fuzz 2.52b by <[email protected]>
[+] Looks like we're not running on a tty, so I'll be a bit less verbose.
[+] You have 12 CPU cores and 2 runnable tasks (utilization: 17%).
[+] Try parallel jobs - see /usr/local/share/doc/afl/parallel_fuzzing.txt.
[*] Checking CPU core loadout...
[+] Found a free CPU core, binding to #0.
[*] Checking core_pattern...
[*] Checking CPU scaling governor...
[*] Setting up output directories...
[*] Scanning 'corpus'...
[+] No auto-generated dictionary tokens to reuse.
[*] Creating hard links for all input files...
[*] Validating target binary...
[*] Attempting dry run with 'id:000000,orig:123'...
[*] Spinning up the fork server...
[+] All right - fork server is up.

[-] PROGRAM ABORT : No instrumentation detected
         Location : perform_dry_run(), afl-fuzz.c:2860

from sharpfuzz.

jnyrup avatar jnyrup commented on May 23, 2024

I "solved" that by running sharpfuzz as part of the building process by adding this target to the csproj file.

<Target Name="Fuzz" AfterTargets="build">
  <Message Text="sharpfuzz $(OutDir)Jil.dll" Importance="high" />
  <Exec Command="sharpfuzz $(OutDir)Jil.dll" />
</Target>

from sharpfuzz.

Related Issues (20)

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.