diff options
| author | Shulhan <ms@kilabit.info> | 2021-08-07 00:32:30 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-08-07 00:32:30 +0700 |
| commit | c8cd99180e391b009413c148e26157c6b0ee3233 (patch) | |
| tree | 9df5ff44d33c6383207d3dfc3891e5b6597e80c7 | |
| parent | d3fc1e5cbaaefd0f3bbaa2a514c4e265f414f429 (diff) | |
| download | gorankusu-c8cd99180e391b009413c148e26157c6b0ee3233.tar.xz | |
_www: only show Attack button if AllowAttack is true
Previously, the Attack button always showed even for HTTP target that
have AllowAttack false. This can be misleading for user.
This changes, show the Attack button only if AllowAttack is true.
While at it, reformat the JavaScript file with prettier.
| -rw-r--r-- | _www/index.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/_www/index.js b/_www/index.js index 3f82f56..a6d2175 100644 --- a/_www/index.js +++ b/_www/index.js @@ -86,10 +86,7 @@ async function environmentGet() { _env = res.data if (_env.AttackRunning) { - updateStateAttack( - _env.AttackRunning.Target, - _env.AttackRunning.HttpTarget, - ) + updateStateAttack(_env.AttackRunning.Target, _env.AttackRunning.HttpTarget) } } @@ -103,9 +100,7 @@ async function renderEnvironment() { </div> <div class="input"> <label for="MaxAttackDuration"> Max. attack duration (seconds) </label>: - <input id="MaxAttackDuration" readonly="" value="${ - _env.MaxAttackDuration / 1e9 - }"></input> + <input id="MaxAttackDuration" readonly="" value="${_env.MaxAttackDuration / 1e9}"></input> </div> <div class="input"> <label for="MaxAttackRate"> Max. attack rate </label>: @@ -217,9 +212,17 @@ function renderHttpTargets(target) { <button onclick="run('${target.ID}', '${http.ID}')"> Run </button> + ` + + if (http.AllowAttack) { + w += ` <button onclick="attack('${target.ID}', '${http.ID}')"> Attack </button> + ` + } + + w += ` </span> </h3> @@ -341,13 +344,13 @@ function renderWebSocketTargets(target) { } function clearHttpOutput(httpId) { - document.getElementById(httpId +'_request').innerHTML = ''; - document.getElementById(httpId +'_response').innerHTML = ''; - document.getElementById(httpId +'_response_body').innerHTML = ''; + document.getElementById(httpId + "_request").innerHTML = "" + document.getElementById(httpId + "_response").innerHTML = "" + document.getElementById(httpId + "_response_body").innerHTML = "" } function clearWebsocketOutput(wstId) { - document.getElementById(wstId +'_response').innerHTML = ''; + document.getElementById(wstId + "_response").innerHTML = "" } function renderHttpTargetHeaders(target, http) { @@ -486,12 +489,8 @@ async function run(targetID, httpTargetID) { return } - document.getElementById(httpTargetID + "_request").innerHTML = atob( - res.data.DumpRequest, - ) - document.getElementById(httpTargetID + "_response").innerHTML = atob( - res.data.DumpResponse, - ) + document.getElementById(httpTargetID + "_request").innerHTML = atob(res.data.DumpRequest) + document.getElementById(httpTargetID + "_response").innerHTML = atob(res.data.DumpResponse) let body = atob(res.data.ResponseBody) let elBody = document.getElementById(httpTargetID + "_response_body") |
