Tuesday, October 27, 2020

libprotobuf&libfuzz Part 1.

0x1.Introduction


Protocol Buffers   

    Is a protocol that serializes data structures.It was developed by Google, and it is a language-independent, platform-independent extensible mechanism for serializing structured data (e.g. XML), but smaller, faster, and simpler.You define how you want to construct the data ,and then you can easily write and read structured data in a variety of data streams in a variety of languages using the generated special source code.


    LibProtoBuff-mutator
    
        Libprotobuf-mutator is a library to randomly mutate protobuffers.It could be used toghether with guided fuzzing engines,such as libfuzzer.

0x2.Compilation
    The official README wrote very clearly hwo ti compile it and install it,first have to install clang,this directly with ubuntu apt or download their own compilation or directly download the bin file.

Here is a paste from the official compilation process of github page:






This compilation has a pitfall,the fact is not an error when compiling,is the last test is included in the compilation, so it should not affect the use,but this problem can also be solved

Two Tests actually failed in LibFuzzerExampleTest, according to issues:https://github.com/google/libprotobuf-mutator/issues/108, is to compile the test did not open ASAN, resulting in the test sample may not crash output, resulting in the test failed,so the compilation failed

adaugi imagine

So dende gives the solution

0x3.Example using protobuf

Examples will be based on https://github.com/bruce30262/libprotobuf-mutator_fuzzing_learning

Let's dig in.
        0x3/0x1: Protobuf file analysis
            syntax = proto2.There are two versions of the protocol buffers language, namely proto2 and proto3. This specification is written using proto2.
            messagealthough not explicitly defined iiuc, seems to be the smallest unit of a message description. It is a named field. For example message TEXT { defines a message format called TEST.
              field rule, type, name, number: A field is a portion of a message.

                -field rule: specifies if the field under consideration is required, optional, or repeated. They mean just that.

                -field type: specifies the data type of the field e.g., number uint32,string etc.

                -field name: name of the field

                -field number: unique identifier for said field. It is a good practice to start numbering from 1 since smaller integers require lesser storage.

    0x4.Compile protoc
        mkdir genfiles
        protoc ./test.proto --cpp_out=./genfiles

This will create test.pb.cc and test.pb.h in the genfiles directory


Than we simply write a program to test protobuf








we simply instantiate a class  namely test which protobuf exposes for us some methods 


And we compile it and run it

1 comment:

  1. Hi

    How does the given function relate to research essay and given task of continuous assessment work 1? Please follow the research essay requirements and guideline of essay (via assessment brief 1) to score more in the assessments.
    Please do not forget to link it to your major project to show context.

    Many thanks
    Chirag

    ReplyDelete

libprotobuf&libfuzz Part 2.

 We just dissect the source code from this guy's repo:https://github.com/bruce30262/libprotobuf-mutator_fuzzing_learning we will use sam...