{'excludeRegexs': [], 'loggedInPattern': '', 'urlParameterParserClass': 'org.zaproxy.zap.model.StandardParameterParser', 'description': '', 'includeRegexs': '[\\Qhttp://192.168.2.131/dvwa/\\E.*]', 'inScope': 'true', 'authenticationDetectionMethodId': '0', 'loggedOutPattern': '', 'postParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'name': '2019-04-17 16:43:04.283145', 'urlParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'id': '10', 'authType': 'Manual Authentication', 'postParameterParserClass': 'org.zaproxy.zap.model.StandardParameterParser'}
'[\\Qhttp://192.168.2.131/dvwa/\\E.*]'
[\Qhttp://192.168.2.131/dvwa/\E.*]
c = zap.context.context(contextname)
print(c['includeRegexs'])
Yes you are right the last bit of code does print the expected value. In the atachments I have added my code and below is the output of those scripts.
code:
c = self.zap.context.context(self.contextname)
print(c['includeRegexs'])
output:
code:
print(self.zap.context.context(self.contextname))
output:
{'excludeRegexs': [], 'loggedInPattern': '', 'urlParameterParserClass':'org.zaproxy.zap.model.StandardParameterParser', 'description': '', 'includeRegexs':'[\\Qhttp://192.168.2.131/dvwa/\\E.*]', 'inScope': 'true', 'authenticationDetectionMethodId': '0','loggedOutPattern': '', 'postParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'name': '2019-04-18 08:54:41.493082', 'urlParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'id': '4','authType': 'Manual Authentication', 'postParameterParserClass':'org.zaproxy.zap.model.StandardParameterParser'}
code:
__str__ method the owaspzap class
output:
ContextName: 2019-04-18 08:54:41.493082, ContextId: 4, UserId: 2, AuthIsSet: True, Key: change-me-1337, Zap:<zapv2.ZAPv2 object at 0x7f4919b66630>, Target: http://192.168.2.131/dvwa/, LoginUrl: http://192.168.2.131/dvwa/login.php, Username: qwer, Password: 1234, AuthMethod: formBasedAuthentication, AuthMethodConfigParams: loginUrl=http://192.168.2.131/dvwa/login.php&loginRequestData=username%3D%7B%25qwer%25%7D%26password%3D%7B%251234%25%7D, ContextRegex: \Qhttp://192.168.2.131/dvwa/\E.*, LoggedInIndicator: Ingelogd!!!, LoggedOutIndicator: Wrong username or password, Credentials: username=qwer&password=1234
So I guess that you are right and I should find a way to escape the escape character.
Greetings,
Chiel
contextregex = "\\Qhttp://192.168.2.131/dvwa/\\E.*"
...
print(self.zap.context.context(self.contextname))
{'excludeRegexs': [], 'loggedInPattern': '', 'urlParameterParserClass': 'org.zaproxy.zap.model.StandardParameterParser', 'description': '', 'includeRegexs': '[\\Qhttp://192.168.2.131/dvwa/\\E.*]', 'inScope': 'true', 'authenticationDetectionMethodId': '0', 'loggedOutPattern': '', 'postParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'name': '2019-04-18 08:54:41.493082', 'urlParameterParserConfig': {'kvps': '&', 'kvs': '=', 'struct': []}, 'id': '4', 'authType': 'Manual Authentication', 'postParameterParserClass': 'org.zaproxy.zap.model.StandardParameterParser'}