模糊测试基本概念FuzzTest

1. what is FUZZ TESTing?

Fuzz Testing is an automated software testing technology, originally developed by Barton Miller of the University of Wisconsin in 1989, which is usually used to identify potential vulnerabilities in programs. The core of Fuzz Testing is to automatically or semi automatically generate random data and input it into the application, while monitoring program exceptions, such as crashes and code assertion failures, to find possible program errors, such as memory leaks.

Fuzzification refers to the automatic generation and execution of tests. The random data input in the fuzzy test is called “Fuzzy”. The types of random data include: super long strings; Random numbers such as negative numbers, floating point numbers, super large numbers, and special characters such as~! @ # $% Such characters with special meanings as input may cause error; Unicode coding, because some programs do not support unicode.

Fuzzy testers for fuzzy testing are divided into two categories:

  • One is a fuzzy tester based on mutation, which creates test cases by mutation of existing data samples
  • The other is the generation based fuzzy tester, which models the protocol or file format used by the system under test, generates inputs based on the model and creates test cases accordingly.

Fuzzy test process🌟🌟🌟

Fuzzy testing usually includes the following basic stages:

  1. Determine the test objectives: determine the nature, function, operating conditions and environment of the target program, the language for writing the program, the vulnerability information found by the software in the past, and the interface for external interaction, etc
  2. Determine input vectors, such as file data, network data, and environment variables.

  3. Generating fuzzy test data: after determining the input vector, design the method of fuzzy test and test data generation algorithm, etc

  4. Execute fuzzy test data: automatically complete the process of sending a large amount of test data to the test target, including starting the target process, sending test data, opening files, etc
  5. Monitoring exceptions: monitor whether the target program generates exceptions, and record the test data and exception related information that cause the program to generate exceptions
  6. Determine whether the discovered vulnerabilities can be used: by resending the data generating exceptions to the target program, track the processing flow related to the program before and after the exception is generated, analyze the cause of the exception, and determine whether it can be used.

  7. Output the test log.

模糊测试基本概念FuzzTest

Basic Requirements

To achieve efficient fuzzy testing, the following requirements are usually required:

  1. Reproducibility: The tester must be able to know what the test data corresponding to the state change of the target program is. If the tester does not have the ability to reproduce the test results, the whole process will lose its significance. One way to achieve reproducibility is to record the status of the test data and the target program while sending the test data
  2. Reusability: Carry out modular development, so that there is no need to re develop a fuzzy tester for a new target program
  3. Code coverage: refers to the number of all codes and process states that the fuzzy tester can make the target program reach or execute
  4. Exception monitoring: it is very important to accurately determine whether an exception occurs to the target program

Existing problems

  1. Strong blindness: even if you are familiar with the protocol format, you still haven’t solved the problem of duplicate test case paths, resulting in low efficiency
  2. Large redundancy of test cases: many test cases are generated through random strategies, resulting in repeated or similar test cases
  3. The pertinence of the associated fields is not strong: most of the time, it is just a random generation or variation of data for multiple elements, lacking the pertinence of the protocol associated fields

Method implementation

Association analysis of input data

Normally, the application will check the format of the input data object. It is an important step to improve the success rate of fuzzy testing by analyzing the structure of data objects input to the program and the dependency between its constituent elements, and constructing test cases that meet the format requirements so as to bypass the program format check.

The input data of an application usually follows certain specifications and has a fixed structure. For example, network packets usually conform to a specific network protocol specification, and file data usually conforms to a specific file format specification. Input data structure analysis is to analyze the structure of these network data packets or file formats, identify specific fields that may cause application parsing errors, and build test cases through mutation or generation. Usually focus on the following fields: fields representing length, fields representing offset, fields that may cause applications to execute different logic, variable length data, etc

The data objects that an application can handle are very complex. For example, MS Office files are composite files stored based on object embedding and linking. They can not only embed files in other formats, but also contain various types of metadata. This complexity leads to the fact that the vast majority of test data generated in the process of fuzzy testing cannot be accepted by applications. The data block association model is an effective way to solve this problem. The model takes data blocks as the basic element, and uses the correlation between data blocks as the link to generate deformity test data. Among them, the data block is the basis of the data block association model. Usually, a data object can be divided into several data blocks, and the dependency between data blocks is called data association

The division of data blocks generally follows three basic principles:

  1. Keep the correlation between data blocks as small as possible
  2. Divide data with specific meaning into a data block
  3. Divide a continuous and fixed data into the same data block

Division of data block association model:

  • Association method
  • Internal Association: refers to the association between different data blocks in the same data object.

    • Length association: one or several data blocks in a data object represent the length of another data block. It is the most common data association method in file format, network protocol and ActiveX control fuzzy testing.
  • External association: refers to the association between multiple different data blocks belonging to multiple different data objects

    • Content association: A data block of a data object represents the value of another data block of another (or the same) data object. It often appears in network protocol applications requiring user authentication.
  • Correlation strength

  • Strong Association: the number of associated data blocks is greater than or equal to the number of non associated data blocks.

  • Weak association: the number of associated data blocks is less than the number of non associated data blocks.

  • evaluation criterion
    Effective data object efficiency: the ratio of the number of malformed data objects constructed to the number of data objects that can be accepted and processed by the application.

Construction method of test case set

Common construction methods are as follows:

  1. Random method: simply generate a large number of pseudo random data to the target program.

  2. Mandatory test: The fuzzy tester starts from a valid protocol or data format sample, and continuously scrambles every byte, word, doubleword or string in the data package or file.

  3. Pre generation of test cases: study a special specification to understand all supported data formats and the acceptable value range of each data format, and then generate hard coded data packages or files used to test boundary conditions or force violations of the specification.

  4. Genetic algorithm: the test case generation process is transformed into a numerical optimization problem using genetic algorithm. The search space of the algorithm is the input domain of the software to be tested, and the optimal solution is the test case that meets the test objectives. First, use the initial data and seeds to generate data, then test and evaluate the data, and monitor the test process. If the conditions for test termination are met, output the test results, otherwise generate new data through selection, hybridization, and mutation

  5. Error injection and fuzzy heuristic
  6. Error injection: It refers to generating faults artificially and consciously according to specific fault models, and applying specific faults to the software system to be tested to accelerate the occurrence of system errors and failures.

    • Error types that can be injected generally: memory error, processor error, communication error, process error, message error, network error, program code error, etc
    • Fuzzy Heuristics: The specific potential danger values contained in the fuzzy string or fuzzy value list are called fuzzy heuristics.
    • Boundary integer value: integer value overflow, underflow, symbol overflow, etc.

    • String duplication: stack overflow, etc.

    • Field separator: Randomly include non alphanumeric characters such as spaces, tabs, etc. into the fuzzy test string.

    • Format string: it is better to select “% s”, “% n”, etc. to be included in the string.

    • Character conversion and translation: Special attention is paid to the processing of extended characters.

    • Directory traversal: appending symbols such as “../” to the URL will cause attackers to access unauthorized directories.

    • Command injection: pass unfiltered user data to API calls such as “exec()” and “system()”.

Test exception analysis

In the process of program dynamic analysis, there are several ways to obtain relevant information:

  • Get information through the normal output of the program
  • Get information through static code pegging
  • Get information through dynamic binary instrumentation
  • Get information through virtual machine
  • Get information through *the debugging interface or debugger

Fuzzy testing framework

The fuzzy testing framework is a general fuzzier, which can perform fuzzy testing on different types of targets. It abstracts some monotonous work and reduces these work to a minimum. Generally, the fuzzy testing framework includes the following parts:

  • Fuzzy test data generation module
  • Raw data generation module: it can directly read some manually constructed normal data, or automatically generate normal test data according to the structure definition
  • Deformity data generation module: make some modifications and deformation on the basis of the original data to generate the final deformity data
  • Dynamic debugging module: use the debugging interface provided by the operating system to realize the dynamic debugging function to capture the abnormal information generated by the debugged program
  • Execution monitoring module: on the basis of dynamic debugging module, it can monitor the execution status of the debugged program during the running process of the debugged program, so as to decide when to terminate the running of the debugged program
  • Automatic script module: provides more complex monitoring functions on the basis of executing the monitoring module
  • Exception filtering module: based on the dynamic debugging module, it can filter the results of exceptions in real time
  • Test result management module: in addition to the abnormal information in the test result database, the abnormal data will also be saved. Regression testing can be realized by using the test result database.

Original: https://www.cnblogs.com/ivanlee717/p/16750657.html
Author: ivanlee717
Title: 模糊测试基本概念FuzzTest

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/582549/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 如何设置redis中hash的field的expire ?

    redis 127.0.0.1:6379> hset expire:me name tom (integer) 0 redis 127.0.0.1:6379> hget…

    Linux 2023年5月28日
    0134
  • Zookeeper集群搭建及原理

    1 概述 1.1 简介 ZooKeeper 是 Apache 的一个顶级项目,为分布式应用提供高效、高可用的分布式协调服务,提供了诸如数据发布/订阅、负载均衡、命名服务、分布式协调…

    Linux 2023年6月13日
    0101
  • Linux 下 SVN 的安装和配置

    SVN 是一个自由开源的版本管理系统,它可以按照时间的顺序去管理文件、目录以及对其进行的修改。于今,它被广泛的用于互联网公司的项目版本管理中 工作原理 它的工作原理如下图所示 它是…

    Linux 2023年6月13日
    0107
  • MySQL之外键、表关系及SQL查询关键字

    一、外键 假设现在我们有一张员工信息表,表的字段如下: id # 主键 name # 姓名 age # 年龄 dep_name # 部门名称 dep_desc # 部门描述 单从数…

    Linux 2023年6月14日
    086
  • Go-interface基本概念

    interface类型可以定义一组方法,但是这些不需要实现。并且interface不能包含任何变量。到某个自定义类型要使用的时候,再根据具体情况把这些方法写出来。 定义一个接口: …

    Linux 2023年6月8日
    0117
  • Docker常用命令

    配置相关 docker version 查看版本 docker ps 查看当前运行的container docker exec -it php-fpm bash 进入cantain…

    Linux 2023年6月13日
    089
  • CentOS7安装MYSQL8.X详细教程

    1-首先查看系统是否存在mysql,无则不返回 rpm -qa|grep mysql 2-安装wget yum -y install wget 3-抓取mariadb并删除包,无则…

    Linux 2023年5月27日
    096
  • html2canvas生成并下载图片

    html <div id="downChart"> div> jq new html2canvas(document.getElementBy…

    Linux 2023年6月7日
    096
  • 机器学习:正态方程 python实现

    前言 一、算法介绍 二、核心算法 1. 公式 2.python实现 总结 前言 使用python简单实现机器学习中正态方程算法。 一、算法介绍 与梯度下降算法相比,正态方程同样用于…

    Linux 2023年6月7日
    0103
  • 用动态端口,增强winrm,open sshd的,服务器安全

    前言 我开发了一套开源,免费,跨平台的devops脚本批量运维工具。【kaiiit家的饭店】是软件的正式名字。【卡死你3000】是第一版开发代号。 想要增强win被控机密码安全。可…

    Linux 2023年6月14日
    088
  • 我的第一个博客

    我就是想试一试 .阿西吧 段狗是傻逼,段狗请看右边的看板娘 posted @2020-06-22 18:56 xiao-c 阅读(17 ) 评论() 编辑 Original: ht…

    Linux 2023年6月7日
    0145
  • 【Example】C++运算符重载

    首先,阅读之前要先搞清楚什么是运算符、函数重载。函数重载就是在一个范围内为一个函数声明多个实现方式,函数名必须一致。 那么C++运算符是否可以重载呢?可以!先弄清什么时候需要进行运…

    Linux 2023年6月13日
    0113
  • 用华为云cli(命令行程序),管理华为云服务器的,安全组端口

    关键字 hcloud 华为 命令行 linux windows powershell 前些天,大家因为华为云,是否应该默认开启端口,大家吵起来了,所以我抽空写了此文。解决问题,缓解…

    Linux 2023年6月14日
    096
  • Redis-firewall使用命令

    Redis-firewall使用命令 一、iptables防火墙 1、基本操作 查看防火墙状态 service iptables status 停止防火墙 service ipta…

    Linux 2023年6月14日
    0106
  • redis缓存数据库简单使用

    1、在Linux上安装与配置 -最新:7.0 -最稳定版本:6.x-讲课:5.x-企业里:3.x,4.x,5.x 6.x(极少数公司在用)-windows:3.x,5.x 1 速度…

    Linux 2023年6月14日
    0106
  • WPF 修复 ContextMenu 在开启 PerMonitorV2 后所用 DPI 错误

    本文告诉大家如何修复 WPF 的 ContextMenu 在开启 PerMonitorV2 之后,在双屏不同的 DPI 的设备上,在副屏弹出的 ContextMenu 使用了主屏的…

    Linux 2023年6月6日
    094
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球