I used the Zap browser extension to record my authentication script.
I do enable httpSender first so that I get the accesstoken from a specific response and then declare it as a script global var "myvar" .
env:
parameters:
failOnError: true
failOnWarning: false
progressToStdout: true
contexts:
- name: mycontext
urls:
includePaths:
excludePaths:
authentication:
method: "client"
parameters:
script: /path/to/authentication.zst # String, the path to the Zest login script
scriptEngine: Mozilla Zest # The script engine used for the login script
diagnostics: true # Bool, enables the recording of diagnostic data during the authentication. Default: false.
minWaitFor: 5000 # Int, sets the minimum waitFor time in seconds to wait for each client statement, default: 0
verification:
method: poll
loggedOutRegex: HTTP/1.1 401
loggedInRegex: 200 OK
pollFrequency: 100
pollUnits: requests
sessionManagement:
method: headers
parameters:
Cookie: session_id={%script:myvar%}
users:
- name: 'myUser'
credentials:
username: 'myUser'
password: mypassword
proxy:
hostname: my_proxy_host
port: my_proxy_port
jobs:
- type: activeScan-config
parameters:
maxRuleDurationInMins: 0
maxScanDurationInMins: 0
maxAlertsPerRule: 0
handleAntiCSRFTokens: true
injectPluginIdInHeader: true
threadPerHost: 12
inputVectors:
urlQueryStringAndDataDrivenNodes:
odata: true
enabled: true
postData:
multiPartFormData: true
enabled: true
xml: true
directWebRemoting: true
json:
scanNullValues: true
enabled: true
googleWebToolkit: true
urlPath: true
httpHeaders:
allRequests: true
enabled: true
cookieData:
enabled: true
encodeCookieValues: true
scripts: true
- type: script
parameters:
action: add
type: httpsender
engine: Graal.js
name: httpsender
source: path/to/httpSender.js
- type: script
parameters:
action: enable
type: httpsender
engine: Graal.js
name: httpsender
- type: script
parameters:
action: add
type: authentication
engine: Mozilla Zest
name: authentication
source: /path/to/authentication.zst
- type: spider
name: spider
parameters:
context: mycontext
user: 'myUser'
maxDuration: 0
maxDepth: 0
maxChildren: 0
acceptCookies: false
handleODataParametersVisited: false
handleParameters: IGNORE_COMPLETELY
maxParseSizeBytes: 3000
parseComments: true
parseGit: true
parseRobotsTxt: true
parseSitemapXml: true
parseSVNEntries: true
parseDsStore: true
postForm: true
processForm: true
- type: spiderClient
parameters:
context: mycontext
user: 'myUser'
maxDuration: 300
maxCrawlDepth: 10
maxChildren: 50
numberOfBrowsers: 2
browserId: chrome
scopeCheck: Flexible
pageLoadTime: 5000
- parameters:
maxDuration: 0
type: passiveScan-wait
- name: activeScan
type: activeScan
parameters:
context: mycontext
policy: Default Policy
user: 'myUser'
maxRuleDurationInMins: 0
maxScanDurationInMins: 0
threadPerHost: 12
handleAntiCSRFTokens: true
injectPluginIdInHeader: true
scanHeadersAllRequests: true
policyDefinition:
defaultStrength: MEDIUM
defaultThreshold: MEDIUM
- type: report
name: report-traditional-pdf
parameters:
reportFile: report.pdf
reportDescription: This report contains the results of a vulnerability scan for
reportTitle: ZAP scan report
reportDir: path/to/report
displayReport: false
template: traditional-pdf
risks:
- info
- low
- medium
- high
confidences:
- low
- medium
- high
- confirmed
sections:
- alertcount
- instancecount
- alertdetails