Wazuh Integration With OsTicket
Wazuh Integration With OsTicket
Table of Contents
1. Introduction
1. Overview of osTicket
2. Benefits of osTicket
3. Why Integrate with Wazuh?
2. Installing osTicket
1. Prerequisites
2. Installation Steps
3. Integrating Wazuh with osTicket
1. Prerequisites
2. Step 1: Configure osTicket API
3. Step 2: Create Integration Scripts
4. Step 3: Configure Wazuh
5. Step 4: Test the Integration
6. Step 5: Troubleshooting
4. Conclusion
5. References
1. Introduction
1.1 Overview of osTicket
osTicket is a robust, open-source helpdesk and ticketing system designed to streamline the
management of support requests and internal issues. Its intuitive web-based interface
enables efficient ticket submission and management, making it ideal for IT support,
customer service, and incident response.
2. Installing osTicket
This section provides a step-by-step guide to installing osTicket on an Ubuntu 22.04/24.04
server at http://10.10.11.195. Adjust commands for other distributions as needed.
2.1 Prerequisites
Requirement Details
Server Ubuntu 22.04/24.04, 2GB RAM, 2 CPUs, 20GB disk space
Network Reachable at 10.10.11.195:80 (your IP here)
Root Access Required for installation
Dependencies Apache/Nginx, PHP, MySQL/MariaDB
2. Install Dependencies:
3. Configure MySQL/MariaDB:
4. Download osTicket:
cd /tmp
wget https://github.com/osTicket/osTicket/releases/download/v1.18/osTic
ket-v1.18.zip
unzip osTicket-v1.18.zip
sudo mv upload /var/www/html/osticket
5. Set Permissions:
sudo chown -R www-data:www-data /var/www/html/osticket
sudo chmod -R 755 /var/www/html/osticket
6. Configure Apache:
Add:
<VirtualHost *:80>
ServerName 10.10.11.195
DocumentRoot /var/www/html/osticket
<Directory /var/www/html/osticket>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/osticket_error.log
CustomLog ${APACHE_LOG_DIR}/osticket_access.log combined
</VirtualHost>
9. Access osTicket:
– Admin Panel: http://10.10.11.195/scp
– User Portal: http://10.10.11.195
– Use admin credentials set during installation.
– Verify MySQL:
3.1 Prerequisites
Requirement Details
osTicket Installed at http://10.10.11.195 with API key
7FF72F0C79A3D691128555D105F61793
Wazuh Running manager at 10.10.110.100(your Wazuh server IP Here)
Network Wazuh Manager must reach http://10.10.11.195:80
Requirement Details
Permissions Root or wazuh group access on Wazuh server
3. Notes:
nano /var/ossec/integrations/custom-osticket.sh
Add:
#!/bin/sh
WPYTHON_BIN="/var/ossec/framework/python/bin/python3"
WAZUH_PATH="/var/ossec"
PYTHON_SCRIPT="/var/ossec/integrations/custom-osticket.py"
2. Set permissions:
nano /var/ossec/integrations/custom-osticket.py
Add:
import json
import os
import sys
import requests
# Global vars
debug_enabled = False
pwd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
json_alert = {}
LOG_FILE = f'{pwd}/logs/integrations.log'
def main(args):
global debug_enabled
if len(args) < 4:
print('# ERROR: Wrong arguments')
sys.exit(2)
debug_enabled = len(args) > 4 and args[4] == 'debug'
process_args(args)
def process_args(args):
alert_file_location, api_key, hook_url = args[1], args[2], args[3]
if not is_valid_url(hook_url):
debug(f"# ERROR: Invalid Hook URL: {hook_url}")
sys.exit(5)
json_alert = load_alert(alert_file_location)
ticket_data = generate_ticket_data(json_alert)
send_ticket(ticket_data, api_key, hook_url)
def generate_ticket_data(alert):
subject = f"Alert: {alert['rule'].get('description', 'No descriptio
n')}"
message = alert.get('full_log', 'No log available')
ticket_data = {
"alert": True,
"autorespond": False,
"source": "API",
"name": "Wazuh Integration",
"email": "alert@wazuh.com",
"phone": "123456789",
"subject": subject,
"message": f"data:text/html,MESSAGE <b>{message}</b>",
"ip": "Your Wazuh Manager IP"
}
return ticket_data
def load_alert(file_path):
try:
with open(file_path) as alert_file:
return json.load(alert_file)
except FileNotFoundError:
debug(f"# ERROR: Alert file {file_path} doesn't exist")
sys.exit(6)
except json.decoder.JSONDecodeError as e:
debug(f"Failed to parse JSON alert: {e}")
sys.exit(7)
def is_valid_url(url):
from urllib.parse import urlparse
parsed_url = urlparse(url)
return all([parsed_url.scheme, parsed_url.netloc])
def debug(msg):
if debug_enabled:
print(msg)
with open(LOG_FILE, "a") as f:
f.write(msg + '\n')
if __name__ == "__main__":
main(sys.argv)
2. Set permissions:
chmod 750 /var/ossec/integrations/custom-osticket.py
chown root:wazuh /var/ossec/integrations/custom-osticket.py
nano /var/ossec/etc/ossec.conf
2. Verify local_rules.xml:
Should match:
<!-- Local rules -->
<!-- Modify it at your will. -->
<!-- Copyright (C) 2015, Wazuh Inc. -->
<group name="local,syslog,sshd,">
<rule id="100001" level="5">
<if_sid>5716</if_sid>
<srcip>1.1.1.1</srcip>
<description>sshd: authentication failed from IP 1.1.1.1.</de
scription>
<group>authentication_failed,pci_dss_10.2.4,pci_dss_10.2.5,</
group>
</rule>
</group>
– Set permissions:
3. Validate Configuration:
/var/ossec/bin/verify-agent-conf
Verify:
systemctl status wazuh-manager
/var/ossec/integrations/custom-osticket.sh /tmp/test_alert.json 7
FF72F0C79A3D691128555D105F61793 http://10.10.110.195/api/tickets.
json debug
ssh Wazuh@10.10.11.100
ssh invaliduser@10.10.110.100
– Check alerts:
3. Monitor Logs:
tail -f /var/ossec/logs/integrations.log
tail -f /var/ossec/logs/ossec.log
– Check:
• No Tickets Generated:
– Verify wazuh-execd:
tail -f /var/ossec/logs/integrations.log
– Use logtest:
/var/ossec/bin/wazuh-logtest
• ossec.conf Error:
Note: If automatic ticket generation fails, ensure wazuh-execd is running and the
API key is correctly configured. Contact DIAMATIX support for persistent issues.
4. Conclusion
This guide enables seamless integration of Wazuh with osTicket, security incident ticketing
as demonstrated by ticket. By following the osTicket installation, active response
configuration for rules 5715 and 5716, and troubleshooting steps, organizations can
enhance incident response efficiency.