#!/usr/bin/env python3 # # basic example showing how to use noawareness data # # - set up webhook as you see fit # - configure your logging search engine to ingest noawareness.log # - point noawareness agents at this host to collect logs centrally # import socket import json import logging import requests # Configuration UDP_PORT = 55555 LOG_FILE = "noawareness.log" DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks/your/webhook/url" TRIGGER_MD5 = "foo" # Setup logging to just log raw messages logging.basicConfig(filename=LOG_FILE, level=logging.INFO, format="%(message)s") # Create UDP socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(("0.0.0.0", UDP_PORT)) print(f"Listening on UDP port {UDP_PORT}...") def send_discord_alert(message): payload = {"content": message} try: requests.post(DISCORD_WEBHOOK_URL, json=payload) except requests.RequestException: pass while True: try: data, _ = sock.recvfrom(65535) message = data.decode("utf-8", errors="ignore").strip() logging.info(message) try: parsed = json.loads(message) if parsed.get("md5") == TRIGGER_MD5: send_discord_alert(f"Trigger match: md5 == {TRIGGER_MD5}") except json.JSONDecodeError: pass except KeyboardInterrupt: break