The configuration is working without any issues on my server. Here is a log for when the active response is triggered:
2023/04/17 18:44:46 wazuh-execd[25140] execd.c:256 at ExecdRun(): DEBUG: Executing command 'active-response/bin/custom-script.py {"version":1,"origin":{"name":"node01","module":"wazuh-execd"},"command":"add","parameters":{"extra_args":[],"alert":{"timestamp":"2023-04-17T18:44:46.423+0300","rule":{"level":3,"description":"sshd: authentication success.","id":"5715","mitre":{"id":["T1078","T1021"],"tactic":["Defense Evasion","Persistence","Privilege Escalation","Initial Access","Lateral Movement"],"technique":["Valid Accounts","Remote Services"]},"firedtimes":1,"mail":false,"groups":["syslog","sshd","authentication_success"],"gdpr":["IV_32.2"],"gpg13":["7.1","7.2"],"hipaa":["164.312.b"],"nist_800_53":["AU.14","AC.7"],"pci_dss":["10.2.5"],"tsc":["CC6.8","CC7.2","CC7.3"]},"agent":{"id":"000","name":"localhost.localdomain"},"manager":{"name":"localhost.localdomain"},"id":"1681746286.1728705","full_log":"Apr 17 18:44:45 localhost sshd[30665]: Accepted password for root from 192.168.56.1 port 56773 ssh2","predecoder":{"program_name":"sshd","timestamp":"Apr 17 18:44:45","hostname":"localhost"},"decoder":{"parent":"sshd","name":"sshd"},"data":{"srcip":"192.168.56.1","srcport":"56773","dstuser":"root"},"location":"/var/log/secure"},"program":"active-response/bin/custom-script.py"}}'To troubleshoot what the issue might be on your end, please add the line execd.debug=1 to your /var/ossec/etc/local_internal_options.conf file. Next, restart your Wazuh manager and simulate the event. Then, check your ossec.log file for any event that is similar to the above. If you see that event, then it means the script is being executed. Check the /var/ossec/ directory for the test_output.txt file which should contain 1 for every time the script runs. If you do not see the result, then the issue is with the script.
If you do not see this line at all, then change the rule ID to 5715 in your configuration, connect via SSH to the Wazuh server, and then repeat the process of looking for the log.
Okay, it seems the line #!/usr/bin/env python is missing from the first line of your script. Can you add that line in line 1, restart the Wazuh manager and try again?
Okay.
That log is expected and it is mostly informational. Please show me the content of your /var/ossec/ directory.
Okay. That shows that the script execution is not working.
Show me the output of the following command: ls -al /var/ossec/active-response/bin/custom-script.py
Okay. Your file seems to contain more characters than mine.
Mine: -rwxr-x---. 1 root wazuh 686 Apr 17 21:37 /var/ossec/active-response/bin/custom-script.py
While yours contain 719. I have attached a new file. Please add it to the directory and change the permissions as required. Then, restart your manager and test again.