• Proj THUDBFuzz Paper Reading: PULSAR: Stateful Black-Box Fuzzing of Proprietary Network Protocols


    Abstract

    协议安全重要性
    当协议规范和程序代码都难以获得时,找bug有困难
    本文: 自动协议逆向工程+fuzz testing
    主要步骤:观察协议流量,推测生成模型
    效果:能有效地探索协议状态空间
    实验:两个case studies

    1. Intro

    P1: 协议安全重要性
    P2: 已有工作

    1. 能获取代码的-百合Fuzzing,动态taint tracking, 符号执行,静态代码分析
    2. 不能获取代码也没有规格的时候-1. 读取固件镜像firmware image 2. 逆向二进制等
      P3:
    3. Automated network protocol fuzzing framework.
    4. A model-based approach to security flaw detection of network protocol implementations
      这两项工作都能够自动推测协议状态,但是在协议中的深层状态相关的bug难以被触及
      P4:
      本文: PULSAR, stateful black-box fuzzing of proprietary network protocols
      基本方法: observe the network traffic and infer a generative model for message formats
      本文特点:guided fuzzing能够探索deep vulnerabilities
      P5:
      两个case,FTP和OSCAR

    2. Methodology

    1. Model Inference
      a) a Markov model representing the state machine
      b) templates that identify the format of the messages
      c) rules that track the data flow
    2. Test case generation
      a) Model inference这一步抽取到的模板和规则定义能够在communication特定阶段中定义的fuzzing primitives
    3. Model Coverage
      a) 尽量将fuzzer引导到被检测很少的state machines

    2.1 Model Inference

    本文的模型推断建立在PRISMA(a probabilistic approach to model both the message content and the state machine if an unknown protocol solely relying on standard captures of network traffic)的基础上,该方法无需二进制文件。

    Data Acquisition

    在真实场景中,软件程序需要和网络中多个实体建立联系,并可能使用多个协议。PULSAR的单个fuzzing会话聚焦于单个服务。首先,我们捕获一对特定客户端IP端口-服务器IP端口之间的全部流量,把这些流量重构为packages没送入session extractor。每个stream会得到一个session identifier,而如果一段时间内都没有packet,我们就认为session已经停止,新的packet即使是同一个连接也将被视为新session的。
    注意,没有出现在会话中的功能将不会被测到

    Message Clustering

    首先将每条消息建模为字节流,接着,为了推测出这些信息的公共结构,我们将字节流映射到有限维向量空间。对于基于文本的协议,信息一般是通过特定字符,比如空格,分割的tokens。对于基于二进制的协议,我们一般将n个byte分割为一个单元。
    然后,我们有一个降维的工序(dimensionality reduction phase),再然后,我们用PRISMA算法,最后,我们使用简单的基于统计的测试来除去易变的特征volatile features,例如cookies,random strings,每条信息中都会出现的constant elements等。
    每条消息被表示为特征向量之后,为了抽取common message structures,本文还会使用欧几里得距离作为相似性度量来聚类。本文中使用了part-based clustering+ NMF。

    Protocol State Machine

    首先,需要标注每条信息来自客户端还是服务端,接着,通过计算traces的概率,我们能够得到一个对真实状态机概率抽象的二阶马尔可夫模型。最后,我们使用DFA最小化算法。

    Message Format

    每条消息将对应Markov模型中的一个状态。如果某个状态组中全部的消息在特定位置上都有相同的token,那么这个token就将被作为constant,否则,就作为field。

    Data Flow

    本文定义一系列规则,让不同域之间的消息能够形成dependency,这样就能互相补充。

    2.2 Test case generation

    当消息被接受时,会与存在valid transition的状态模板进行匹配。对于transition A:B:C来说,如果A,B都曾经被观察到,那么系统会尝试匹配C。
    有时接收到的消息可能与训练数据不同,这时系统会使用Levenshtein string distance来尽量选择最近的模板。
    This type of semi-valid transition has two effects. In the first place, the probability of reaching a “fuzzable” state is increased and second, if the semantics from the similarity matched template are too far from the semantics of the correct message, the response can be understood as a faulty input in itself. From the fuzzing perspective this is equivalent to a jump to an erroneous state in the real state model of the protocol. This situation may also led to errors in implementations where the network service is not able to handle a wrong sequence of messages during a session or a message from a different session.
    这种类型的半有效转换有两个效果。首先,达到“可模糊”状态的概率增加,其次,如果相似性匹配模板的语义与正确消息的语义相差太远,则响应本身可以理解为错误输入。从模糊测试的角度来看,这相当于在协议的真实状态模型中跳转到错误状态。这种情况还可能导致网络服务无法在会话期间处理错误的消息序列或来自不同会话的消息的实现中的错误。
    在选择模板D后,我们使用B:C:D这个transtion来创建下一个message

  • 相关阅读:
    【JVM基础】JVM垃圾回收机制算法
    【java基础】- java双亲委派机制
    Java基础(一)
    JVM
    冷知识: 不会出现OutOfMemoryError的内存区域
    疯狂Java:突破程序员基本功的16课-李刚编著 学习笔记(未完待续)
    nor flash之写保护
    spinor/spinand flash之高频通信延迟采样
    nor flash之频率限制
    使用littlefs-fuse在PC端调试littlefs文件系统
  • 原文地址:https://www.cnblogs.com/xuesu/p/15257099.html
Copyright © 2020-2023  润新知