🔗 Correlation
Ddosify enables you to capture variables from steps using json_path, xpath, xpath_html, or regular expressions. Later, in the subsequent steps, you can inject both the captured variables and the scenario-scoped global variables.
Please keep in mind that:
- You must specify 'header_key' when capturing from header.
- For json_path syntax, please take a look at gjson syntax doc.
- Regular expression are expected in 'Golang' style regex. For converting your existing regular expressions, you can use regex101.
- You can extract values from headers, body, and cookies.
You can use debug parameter to validate your config.
ddosify -config ddosify_config_correlation.json -debug
Capture with json_path
{
"steps": [
{
"capture_env": {
"NUM": { "from": "body", "json_path": "num" },
"NAME": { "from": "body", "json_path": "name" },
"SQUAD": { "from": "body", "json_path": "squad" },
"PLAYERS": { "from": "body", "json_path": "squad.players" },
"MESSI": { "from": "body", "json_path": "squad.players.0" }
}
}
]
}
Capture with XPath on XML
{
"steps": [
{
"capture_env": {
"TITLE": { "from": "body", "xpath": "//item/title" }
}
}
]
}
Capture with XPath on HTML
{
"steps": [
{
"capture_env": {
"TITLE": { "from": "body", "xpath_html": "//body/h1" }
}
}
]
}
Capture with Regular Expressions
{
"steps": [
{
"capture_env": {
"CONTENT_TYPE": {
"from": "header",
"header_key": "Content-Type",
"regexp": { "exp": "application/(\\w)+", "matchNo": 0 }
},
"REGEX_MATCH_ENV": {
"from": "body",
"regexp": { "exp": "[a-z]+_[0-9]+", "matchNo": 1 }
}
}
}
]
}
Capture Header Value
{
"steps": [
{
"capture_env": {
"TOKEN": { "from": "header", "header_key": "Authorization" }
}
}
]
}
Scenario-Scoped Variables
{
"env": {
"TARGET_URL": "http://localhost:8084/hello",
"USER_KEY": "ABC",
"COMPANY_NAME": "Ddosify",
"RANDOM_COUNTRY": "{{_randomCountry}}",
"NUMBERS": [22, 33, 10, 52]
}
}
Overall Config and Injection
On array-like captured variables or environment vars, the rand( ) function can be utilized.
// ddosify_config_correlation.json
{
"iteration_count": 100,
"load_type": "linear",
"duration": 10,
"steps": [
{
"id": 1,
"url": "{{TARGET_URL}}",
"method": "POST",
"headers": {
"User-Key": "{{USER_KEY}}",
"Rand-Selected-Num": "{{rand(NUMBERS)}}"
},
"payload": "{{COMPANY_NAME}}",
"capture_env": {
"NUM": { "from": "body", "json_path": "num" },
"NAME": { "from": "body", "json_path": "name" },
"SQUAD": { "from": "body", "json_path": "squad" },
"PLAYERS": { "from": "body", "json_path": "squad.players" },
"MESSI": { "from": "body", "json_path": "squad.players.0" },
"TOKEN": { "from": "header", "header_key": "Authorization" },
"CONTENT_TYPE": {
"from": "header",
"header_key": "Content-Type",
"regexp": { "exp": "application/(\\w)+", "matchNo": 0 }
}
}
},
{
"id": 2,
"url": "{{TARGET_URL}}",
"method": "POST",
"headers": {
"User-Key": "{{USER_KEY}}",
"Authorization": "{{TOKEN}}",
"Content-Type": "{{CONTENT_TYPE}}"
},
"payload_file": "payload.json",
"capture_env": {
"TITLE": { "from": "body", "xpath": "//item/title" },
"REGEX_MATCH_ENV": {
"from": "body",
"regexp": { "exp": "[a-z]+_[0-9]+", "matchNo": 1 }
}
}
}
],
"env": {
"TARGET_URL": "http://localhost:8084/hello",
"USER_KEY": "ABC",
"COMPANY_NAME": "Ddosify",
"RANDOM_COUNTRY": "{{_randomCountry}}",
"NUMBERS": [22, 33, 10, 52]
}
}
// payload.json
{
"boolField": "{{_randomBoolean}}",
"numField": "{{NUM}}",
"strField": "{{NAME}}",
"numArrayField": ["{{NUM}}", 34],
"strArrayField": ["{{NAME}}", "hello"],
"mixedArrayField": ["{{NUM}}", 34, "{{NAME}}", "{{SQUAD}}"],
"{{NAME}}": "messi",
"obj": {
"numField": "{{NUM}}",
"objectField": "{{SQUAD}}",
"arrayField": "{{PLAYERS}}"
}
}