Hello Massimiliano,
The Wazuh agent is able to monitor the Windows Event Channel and all the activities in Windows pass through this channel, so we would need to know the eventID that is generated every time you send a document to be printed and with that, you will be able to see the details in the event to trigger the alert in the manager.
The good thing here is that you will not need a decoder, since the Windows Event Channel goes to the manager in a JSON format, it will be decoded automatically on the manager with the stock settings.
I will need to replicate this in my lab to give the details of the configuration, but the general workflow would be the one explained above.
I will send you more details once I finish the lab test.
Regards,
John.-
Hello Massimiliano,
Here are the guidelines on how to achieve what you need.
Firstly, I googled the eventID in which Microsoft logs the printing event. I found that the event ID is 307 and it is located in the Microsoft-Windows-PrintService/Operational channel, so we need to add this configuration on the agent:
<!-- Logs from PrintService--> <localfile> <location>Microsoft-Windows-PrintService/Operational</location> <log_format>eventchannel</log_format> </localfile>Secondly, since Microsoft doesn’t log these events by default, I had to enable the logging on that channel:
Thirdly, I triggered a print event on the Windows machine to track it down in the Event Viewer to make sure it was generated. I was there! So far, so good!
Fourthly, I checked in the archives (logall_json) on the manager, to see if the event arrived properly. And I found it!
{"timestamp":"2023-08-26T17:13:12.960-0300","agent":{"id":"010","name":"Win10-1","ip":"192.168.11.210"},"manager":{"name":"C7-AIO-444_40"},"id":"1693080792.254161","cluster":{"name":"wazuh","node":"node01"},"full_log":"{\"win\":{\"system\":{\"providerName\":\"Microsoft-Windows-PrintService\",\"providerGuid\":\"{747ef6fd-e535-4d16-b510-42c90f6873a1}\",\"eventID\":\"307\",\"version\":\"0\",\"level\":\"4\",\"task\":\"26\",\"opcode\":\"11\",\"keywords\":\"0x4000000000000840\",\"systemTime\":\"2023-09-01T12:43:26.0289992Z\",\"eventRecordID\":\"10\",\"processID\":\"1984\",\"threadID\":\"3940\",\"channel\":\"Microsoft-Windows-PrintService/Operational\",\"computer\":\"Win10-1\",\"severityValue\":\"INFORMATION\",\"message\":\"\\\"El documento 4, Imprimir documento propiedad de admin en \\\\\\\\WIN10-1 se imprimió en Microsoft Print to PDF mediante el puerto C:\\\\Users\\\\admin\\\\Desktop\\\\dsa.pdf. Tamaño en bytes: 38052. Páginas imprimidas: 1. No se requiere ninguna acción por parte del usuario.\\\"\"},\"documentPrinted\":{\"param1\":\"4\",\"param2\":\"Imprimir documento\",\"param3\":\"admin\",\"param4\":\"\\\\\\\\\\\\\\\\WIN10-1\",\"param5\":\"Microsoft Print to PDF\",\"param6\":\"C:\\\\\\\\Users\\\\\\\\admin\\\\\\\\Desktop\\\\\\\\dsa.pdf\",\"param7\":\"38052\",\"param8\":\"1\"}}}","decoder":{"name":"windows_eventchannel"},"data":{"win":{"system":{"providerName":"Microsoft-Windows-PrintService","providerGuid":"{747ef6fd-e535-4d16-b510-42c90f6873a1}","eventID":"307","version":"0","level":"4","task":"26","opcode":"11","keywords":"0x4000000000000840","systemTime":"2023-09-01T12:43:26.0289992Z","eventRecordID":"10","processID":"1984","threadID":"3940","channel":"Microsoft-Windows-PrintService/Operational","computer":"Win10-1","severityValue":"INFORMATION","message":"\"El documento 4, Imprimir documento propiedad de admin en \\\\WIN10-1 se imprimió en Microsoft Print to PDF mediante el puerto C:\\Users\\admin\\Desktop\\dsa.pdf. Tamaño en bytes: 38052. Páginas imprimidas: 1. No se requiere ninguna acción por parte del usuario.\""},"documentPrinted":{"param1":"4","param2":"Imprimir documento","param3":"admin","param4":"\\\\\\\\WIN10-1","param5":"Microsoft Print to PDF","param6":"C:\\\\Users\\\\admin\\\\Desktop\\\\dsa.pdf","param7":"38052","param8":"1"}}},"location":"EventChannel"}We can see that it did not trigger any alert. So we will not see it in the GUI yet. Let’s create a rule to track these actions. Before, let’s see how it reacts to the event. I cleaned the full_log field to make it a valid JSON log, it turned out to be this log:
{"win":{"system":{"providerName":"Microsoft-Windows-PrintService","providerGuid":"{747ef6fd-e535-4d16-b510-42c90f6873a1}","eventID":"307","version":"0","level":"4","task":"26","opcode":"11","keywords":"0x4000000000000840","systemTime":"2023-09-01T12:43:26.0289992Z","eventRecordID":"10","processID":"1984","threadID":"3940","channel":"Microsoft-Windows-PrintService/Operational","computer":"Win10-1","severityValue":"INFORMATION","message":"El documento 4, Imprimir documento propiedad de admin en \\\\\\\\WIN10-1 se imprimió en Microsoft Print to PDF mediante el puerto C:\\\\Users\\\\admin\\\\Desktop\\\\dsa.pdf. Tamaño en bytes: 38052. Páginas imprimidas: 1. No se requiere ninguna acción por parte del usuario."},"documentPrinted":{"param1":"4","param2":"Imprimir documento","param3":"admin","param4":"\\\\\\\\\\\\\\\\WIN10-1","param5":"Microsoft Print to PDF","param6":"C:\\\\\\\\Users\\\\\\\\admin\\\\\\\\Desktop\\\\\\\\dsa.pdf","param7":"38052","param8":"1"}}}The logtest tool showed this result when I tested it:
**Phase 1: Completed pre-decoding. **Phase 2: Completed decoding. name: 'json' win.documentPrinted.param1: '4' win.documentPrinted.param2: 'Imprimir documento' win.documentPrinted.param3: 'admin' win.documentPrinted.param4: '\\\\\\\\WIN10-1' win.documentPrinted.param5: 'Microsoft Print to PDF' win.documentPrinted.param6: 'C:\\\\Users\\\\admin\\\\Desktop\\\\dsa.pdf' win.documentPrinted.param7: '38052' win.documentPrinted.param8: '1' win.system.channel: 'Microsoft-Windows-PrintService/Operational' win.system.computer: 'Win10-1' win.system.eventID: '307' win.system.eventRecordID: '10' win.system.keywords: '0x4000000000000840' win.system.level: '4' win.system.message: 'El documento 4, Imprimir documento propiedad de admin en \\\\WIN10-1 se imprimió en Microsoft Print to PDF mediante el puerto C:\\Users\\admin\\Desktop\\dsa.pdf. Tamaño en bytes: 38052. Páginas imprimidas: 1. No se requiere ninguna acción por parte del usuario.' win.system.opcode: '11' win.system.processID: '1984' win.system.providerGuid: '{747ef6fd-e535-4d16-b510-42c90f6873a1}' win.system.providerName: 'Microsoft-Windows-PrintService' win.system.severityValue: 'INFORMATION' win.system.systemTime: '2023-09-01T12:43:26.0289992Z' win.system.task: '26' win.system.threadID: '3940' win.system.version: '0' **Phase 3: Completed filtering (rules). id: '60009' level: '0' description: 'Windows informational event.' groups: '['windows']' firedtimes: '1' mail: 'False'No alert was triggered, as we saw in the archives, the parent rule is a level 0 alert, which makes sense! Now, we can create our custom rule continuing from the ruleID 60009!
Lastly, let’s add this rule in the local_rules.xml file on the manager and restart it to apply the change:
<group name="printing,"> <rule id="160009" level="5"> <if_sid>60009</if_sid> <field name="win.system.eventID">^307$</field> <options>no_full_log</options> <description>A document was printed.</description> </rule> </group>Now, it’s the moment of the truth, let’s print a document and see what happens! I will print any document to the PDF printer I have in my lab machine. (file attached alert-listed)
There it is! Let’s see its content! (file attached alert-details)
We have:
1) agent name
2) Action
3) user name
4) printer name
5) printing destination
6) event-channel name
7) computer name
AND MORE!
You can now use those fields to track specific activities if you need to.
Hope this was helpful.
John.-
Then what I do is little bit risky, i modify the default rule file with rule id 60009, change the rule level to 10.
Thanks for the response.
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh | Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/zUAe2529fnU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/ff9753eb-e0d1-457a-a558-592e5622807en%40googlegroups.com.