Hi Victor,
After spending days on this I came across a blog
here. This takes the json as parent decoder as was observed and then uses child decoder to decode it further. I got logs from web app, but I was not able to working parser for mod-security logs. As mentioned before I'm using a reverse proxy docker and I wish to parse web and mod security logs.
I will give the mod security log and can you help me create a working decoder?
Log:
{"log":"{\"transaction\":{\"client_ip\":\"198.199.105.84\",\"time_stamp\":\"Tue Aug 22 12:24:05 2023\",\"server_id\":\"08009b29418b10ad42d8757275cce1b4df950f9a\",\"client_port\":39564,\"host_ip\":\"192.168.0.6\",\"host_port\":443,\"unique_id\":\"169270704533.140418\",\"request\":{\"method\":\"GET\",\"http_version\":1.1,\"uri\":\"/ecp/Current/exporttool/microsoft.exchange.ediscovery.exporttool.application\",\"headers\":{\"Host\":\"18.235.43.100\",\"User-Agent\":\"Mozilla/5.0 zgrab/0.x\",\"Accept\":\"*/*\",\"Accept-Encoding\":\"gzip\"}},\"response\":{\"body\":\"\u003chtml\u003e\\r\\n\u003chead\u003e\u003ctitle\u003e403 Forbidden\u003c/title\u003e\u003c/head\u003e\\r\\n\u003cbody\u003e\\r\\n\u003ccenter\u003e\u003ch1\u003e403 Forbidden\u003c/h1\u003e\u003c/center\u003e\\r\\n\u003chr\u003e\u003ccenter\u003enginx/1.22.1\u003c/center\u003e\\r\\n\u003c/body\u003e\\r\\n\u003c/html\u003e\\r\\n\",\"http_code\":403,\"headers\":{\"Server\":\"nginx/1.22.1\",\"Date\":\"Tue, 22 Aug 2023 12:24:05 GMT\",\"Content-Length\":\"153\",\"Content-Type\":\"text/html\",\"Connection\":\"keep-alive\"}},\"producer\":{\"modsecurity\":\"ModSecurity v3.0.8 (Linux)\",\"connector\":\"ModSecurity-nginx v1.0.3\",\"secrules_engine\":\"Enabled\",\"components\":[\"OWASP_CRS/3.3.4\\\"\"]},\"messages\":[{\"message\":\"Found User-Agent associated with security scanner\",\"details\":{\"match\":\"Matched \\\"Operator `PmFromFile' with parameter `scanners-user-agents.data' against variable `REQUEST_HEADERS:User-Agent' (Value: `Mozilla/5.0 zgrab/0.x' )\",\"reference\":\"o12,5v122,21t:lowercase\",\"ruleId\":\"913100\",\"file\":\"/etc/modsecurity.d/owasp-crs/rules/REQUEST-913-SCANNER-DETECTION.conf\",\"lineNumber\":\"34\",\"data\":\"Matched Data: zgrab found within REQUEST_HEADERS:User-Agent: mozilla/5.0 zgrab/0.x\",\"severity\":\"2\",\"ver\":\"OWASP_CRS/3.3.4\",\"rev\":\"\",\"tags\":[\"modsecurity\",\"application-multi\",\"language-multi\",\"platform-multi\",\"attack-reputation-scanner\",\"paranoia-level/1\",\"OWASP_CRS\",\"capec/1000/118/224/541/310\",\"PCI/6.5.10\"],\"maturity\":\"0\",\"accuracy\":\"0\"}},{\"message\":\"Host header is a numeric IP address\",\"details\":{\"match\":\"Matched \\\"Operator `Rx' with parameter `^[\\\\d.:]+$' against variable `REQUEST_HEADERS:Host' (Value: `18.235.43.100' )\",\"reference\":\"o0,13v96,13\",\"ruleId\":\"920350\",\"file\":\"/etc/modsecurity.d/owasp-crs/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf\",\"lineNumber\":\"719\",\"data\":\"18.235.43.100\",\"severity\":\"4\",\"ver\":\"OWASP_CRS/3.3.4\",\"rev\":\"\",\"tags\":[\"modsecurity\",\"application-multi\",\"language-multi\",\"platform-multi\",\"attack-protocol\",\"paranoia-level/1\",\"OWASP_CRS\",\"capec/100
0/210/272\",\"PCI/6.5.10\"],\"maturity\":\"0\",\"accuracy\":\"0\"}},{\"message\":\"Inbound Anomaly Score Exceeded (Total Score: 8)\",\"details\":{\"match\":\"Matched \\\"Operator `Ge' with parameter `5' against variable `TX:ANOMALY_SCORE' (Value: `8' )\",\"reference\":\"\",\"ruleId\":\"949110\",\"file\":\"/etc/modsecurity.d/owasp-crs/rules/REQUEST-949-BLOCKING-EVALUATION.conf\",\"lineNumber\":\"81\",\"data\":\"\",\"severity\":\"2\",\"ver\":\"OWASP_CRS/3.3.4\",\"rev\":\"\",\"tags\":[\"modsecurity\",\"application-multi\",\"language-multi\",\"platform-multi\",\"attack-generic\"],\"maturity\":\"0\",\"accuracy\":\"0\"}}]}}\n","stream":"stdout","time":"2023-08-22T12:24:05.085059395Z"}
I will try to make parser in meantime and if I'm successful I'll paste my decoder and rule here.