Skip to main content
变量可用于声明在整个模板中保持不变的值。变量一旦计算,其值就不会改变。变量可以是简单的字符串或 DSL 辅助函数。如果变量是辅助函数,它将被包含在双大括号 {{<expression>}} 中。变量在模板级别声明。 变量示例 -
variables:
  a1: "test" # 字符串变量
  a2: "{{to_lower(rand_base(5))}}" # DSL 函数变量
目前,dnshttpheadlessnetwork 协议支持变量。 使用变量的模板示例 -
# 使用 HTTP 请求的变量示例
id: variables-example

info:
  name: Variables Example
  author: pdteam
  severity: info

variables:
  a1: "value"
  a2: "{{base64('hello')}}"

http:
  - raw:
      - |
        GET / HTTP/1.1
        Host: {{FQDN}}
        Test: {{a1}}
        Another: {{a2}}
    stop-at-first-match: true
    matchers-condition: or
    matchers:
      - type: word
        words: 
          - "value"
          - "aGVsbG8="
# 网络请求的变量示例
id: variables-example

info:
  name: Variables Example
  author: pdteam
  severity: info

variables:
  a1: "PING"
  a2: "{{base64('hello')}}"

tcp:
  - host: 
      - "{{Hostname}}"
    inputs:
      - data: "{{a1}}"
    read-size: 8
    matchers:
      - type: word
        part: data
        words:
          - "{{a2}}"