-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some delay params to simulate slow responding apps
fuzzer script example /api/jwt/items/{id} route that throws a 500 for fuzzer script testing
- Loading branch information
Showing
15 changed files
with
284 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import com.github.javafaker.Faker | ||
import com.stackhawk.hste.extension.script.ScriptVars | ||
import com.stackhawk.hste.extension.scripts.scanrules.ScriptsActiveScanner | ||
import org.apache.log4j.LogManager | ||
import org.parosproxy.paros.network.HttpMessage | ||
|
||
val logger = LogManager.getLogger("fuzzer") | ||
|
||
val faker = Faker() | ||
val scriptVars = ScriptVars.getScriptVars("fuzzer.kts") | ||
|
||
fun alert(activeScanner: ScriptsActiveScanner, msg: HttpMessage, evidence: String, param: String, fuzzedParam: String) { | ||
val risk = 2 // 0: info, 1: low, 2: medium, 3: high | ||
val confidence = 3 // 0: falsePositive, 1: low, 2: medium, 3: high, 4: confirmed | ||
val title = "Fuzzer found a 5xx error" | ||
val description = "Fuzzer was able to find a 5xx error" | ||
val solution = "Handle bad input and never throw a 5xx error" | ||
val reference = "" | ||
val otherInfo = "fuzzed param: $param=$fuzzedParam" | ||
val pluginId = 10_00_063; //Custom Plugin ID | ||
|
||
activeScanner.newAlert() | ||
.setPluginId(pluginId) | ||
.setRisk(risk) | ||
.setConfidence(confidence) | ||
.setName(title) | ||
.setDescription(description) | ||
.setEvidence(evidence) | ||
.setOtherInfo(otherInfo) | ||
.setSolution(solution) | ||
.setReference(reference) | ||
.setMessage(msg) | ||
.raise(); | ||
} | ||
|
||
fun scanNode(activeScanner: ScriptsActiveScanner, origMessage: HttpMessage) { | ||
logger.debug("scanNode fuzzer hook: ${origMessage.requestHeader.uri}") | ||
return | ||
} | ||
|
||
fun scan(activeScanner: ScriptsActiveScanner, origMessage: HttpMessage, param: String, value: String) { | ||
logger.debug("scan fuzzer hook: ${origMessage.requestHeader.uri} | ${param}=${value}") | ||
val iterations = scriptVars["iterations"]?.toInt() ?: 1 | ||
val stringStartLength = scriptVars["stringStartLength"]?.toInt() ?: 1 | ||
val stringEndLength = scriptVars["stringEndLength"]?.toInt() ?: 100 | ||
(1..iterations).forEach { i -> | ||
val msg = origMessage.cloneRequest() | ||
val fuzzedParamValue = if (i % 2 == 0) { | ||
faker.lorem().characters(stringStartLength, stringEndLength) | ||
} else { | ||
faker.harryPotter().spell() | ||
} | ||
|
||
if (param.isNotBlank()) { | ||
activeScanner.setParam(msg, param, fuzzedParamValue) | ||
} | ||
try { | ||
activeScanner.sendAndReceive(msg, false, false) | ||
if (msg.responseHeader.statusCode >= 500) { | ||
logger.debug("request: ${msg.requestHeader}${msg.requestBody}") | ||
alert(activeScanner, msg, msg.responseHeader.primeHeader, param, fuzzedParamValue) | ||
logger.debug("response: ${msg.responseHeader.statusCode} ${msg.responseHeader}${msg.responseBody}") | ||
} | ||
} catch (e: Exception) { | ||
logger.error("Error sending request: ${e.message}") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://localhost:9000","description":"Generated server url"}],"paths":{"/api/token/items/search/":{"get":{"tags":["token-item-controller"],"operationId":"search","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/{text}":{"get":{"tags":["token-item-controller"],"operationId":"search_1","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/auth/signin":{"post":{"tags":["jwt-auth-controller"],"operationId":"signin","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationRequest"}}}},"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search":{"post":{"tags":["jwt-item-controller"],"operationId":"search_2","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}}}},"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/{text}":{"get":{"tags":["jwt-item-controller"],"operationId":"search_3","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/":{"get":{"tags":["jwt-item-controller"],"operationId":"searchAll","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/{text}":{"get":{"tags":["jwt-user-controller"],"operationId":"search_4","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/bad/{text}":{"get":{"tags":["jwt-user-controller"],"operationId":"searchCrappy","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/":{"get":{"tags":["jwt-user-controller"],"operationId":"searchAll_1","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_5","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/{text}":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_6","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"AuthenticationRequest":{"type":"object","properties":{"username":{"type":"string"},"password":{"type":"string"},"tenant":{"type":"string"}}},"Search":{"type":"object","properties":{"searchText":{"type":"string"}}}}}} | ||
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://localhost:9000","description":"Generated server url"}],"paths":{"/api/jwt/items/search":{"post":{"tags":["jwt-item-controller"],"operationId":"search","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/auth/signin":{"post":{"tags":["jwt-auth-controller"],"operationId":"signin","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/":{"get":{"tags":["token-item-controller"],"operationId":"search_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/{text}":{"get":{"tags":["token-item-controller"],"operationId":"search_2","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/okta/me/token":{"get":{"tags":["okta-controller"],"operationId":"me","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/OktaIdInfo"}}}}}}},"/api/jwt/users/search/":{"get":{"tags":["jwt-user-controller"],"operationId":"searchAll","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}}}}}},"/api/jwt/users/search/{text}":{"get":{"tags":["jwt-user-controller"],"operationId":"search_3","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/bad/{text}":{"get":{"tags":["jwt-user-controller"],"operationId":"searchCrappy","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/{id}":{"get":{"tags":["jwt-item-controller"],"operationId":"getById","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/":{"get":{"tags":["jwt-item-controller"],"operationId":"searchAll_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/{text}":{"get":{"tags":["jwt-item-controller"],"operationId":"search_4","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_5","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/{text}":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_6","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"Search":{"type":"object","properties":{"searchText":{"type":"string"}}},"AuthenticationRequest":{"type":"object","properties":{"username":{"type":"string"},"password":{"type":"string"},"tenant":{"type":"string"}}},"OktaIdInfo":{"type":"object","properties":{"token":{"type":"string"}}},"User":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"description":{"type":"string"},"tenantId":{"type":"string"}}}}}} |
Oops, something went wrong.