gpt4 book ai didi

clang - 如何使用 libfuzzers 自定义修改器 API?

转载 作者:行者123 更新时间:2023-12-04 17:26:47 27 4
gpt4 key购买 nike

Libfuzzer 提供了两个 API 来开发自定义修改器。

size_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed)
size_t LLVMFuzzerCustomCrossOver(const uint8_t *Data1, size_t Size1, const uint8_t *Data2, size_t Size2, uint8_t *Out, size_t MaxOutSize, unsigned int Seed)
这些 API 应该如何使用?
模糊器必须是确定性的。我如何确保使用自定义突变器?

最佳答案

您只需要在您的 LLVMFuzzerTestOneInput 旁边实现这些功能。 .
google/fuzzing repository has a tutorial on how to implement structure-aware fuzzing .
此外,您可以从 CustomMutatorTest.cpp 中获得灵感。 , 和 CustomCrossOverTest.cpp , 来自 LLVM 存储库。

The fuzzer is required to be deterministic.


是的,但是在这里您将编写不同的变异函数;突变将在您的 LLVMFuzzerTestOneInput 之前发生叫做。
但是,它们也有类似的要求。
source code 中所述, 旁边 LLVMFuzzerCustomMutator , 和 LLVMFuzzerCustomCrossOver分别:

Optional user-provided custom mutator.Mutates raw data in [Data, Data+Size) inplace.Returns the new size, which is not greater than MaxSize.Given the same Seed produces the same mutation.


Optional user-provided custom cross-over function.Combines pieces of Data1 & Data2 together into Out.Returns the new size, which is not greater than MaxOutSize.Should produce the same mutation given the same Seed.


两次调用相同的变异函数 Dataseed应该产生相同的结果。
最后一件事:您不需要同时实现这两个功能; LLVMFuzzerCustomMutator大多数情况下应该足够了。

关于clang - 如何使用 libfuzzers 自定义修改器 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62706527/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com