diff --git a/.github/workflows/discord-commits.yml b/.github/workflows/discord-commits.yml deleted file mode 100644 index 173ce70..0000000 --- a/.github/workflows/discord-commits.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Discord - Commits - -on: - push: - branches: - - "**" - workflow_dispatch: - -jobs: - notify: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Post to Discord (embed) - env: - DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_URL }} - EVENT_JSON: ${{ toJson(github.event) }} - run: | - node - <<'NODE' - const event = JSON.parse(process.env.EVENT_JSON); - const webhook = process.env.DISCORD_WEBHOOK; - - if (!webhook) { - console.error("❌ Secret WEBHOOK_URL manquant. (Repo Settings > Secrets and variables > Actions)"); - process.exit(1); - } - - const repoName = event.repository?.full_name || "unknown/repo"; - const repoUrl = event.repository?.html_url || ""; - const branch = (event.ref || "").replace("refs/heads/", ""); - const compareUrl = event.compare || repoUrl; - const pusher = event.pusher?.name || event.sender?.login || "someone"; - - const commits = (event.commits || []).slice(0, 10).map(c => { - const sha = (c.id || "").slice(0, 7); - const msg = (c.message || "").split("\n")[0]; - const author = c.author?.name || "unknown"; - const url = c.url - ? c.url.replace("api.github.com/repos", "github.com").replace("/commits/", "/commit/") - : ""; - return { sha, msg, author, url }; - }); - - const description = commits.length - ? commits.map(c => `• **[${c.sha}](${c.url})** ${c.msg} — _${c.author}_`).join("\n") - : "• (Pas de détails de commits fournis par l'événement)"; - - // Discord embed limits: description max ~4096 chars - const safeDescription = description.length > 3900 - ? description.slice(0, 3900) + "\n…" - : description; - - const payload = { - content: null, - embeds: [ - { - title: `📌 Push sur ${repoName}`, - url: compareUrl, - description: safeDescription, - color: 0x7289DA, - author: { - name: pusher, - url: `https://github.com/${event.sender?.login || ""}` - }, - fields: [ - { name: "Branche", value: `\`${branch || "?"}\``, inline: true }, - { name: "Commits", value: `${event.commits?.length ?? commits.length}`, inline: true } - ], - footer: { text: "GitHub Actions → Discord" }, - timestamp: new Date().toISOString() - } - ] - }; - - fetch(webhook, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(payload) - }) - .then(async (res) => { - const txt = await res.text(); - if (!res.ok) { - console.error(`❌ Discord error ${res.status}: ${txt}`); - process.exit(1); - } - console.log("✅ Notification envoyée sur Discord."); - }) - .catch((err) => { - console.error("❌ Fetch error:", err); - process.exit(1); - }); - NODE diff --git a/tools/c2/core/transport.py b/tools/c2/core/transport.py index 65d141c..0c8d68c 100644 --- a/tools/c2/core/transport.py +++ b/tools/c2/core/transport.py @@ -1,7 +1,7 @@ from core.crypto import CryptoContext from core.device import Device from core.registry import DeviceRegistry -from logs.manager import LogManager +from logging.manager import LogManager from utils.display import Display from proto.c2_pb2 import Command, AgentMessage, AgentMsgType diff --git a/tools/c2/logging/manager.py b/tools/c2/logging/manager.py new file mode 100644 index 0000000..222f6a9 --- /dev/null +++ b/tools/c2/logging/manager.py @@ -0,0 +1,17 @@ +from utils.constant import _color + + +class LogManager: + def handle(self, log): + level = "INFO" + color = "GREEN" + + if log.log_error_code != 0: + level = f"ERROR:{log.log_error_code}" + color = "RED" + + print( + f"{_color(color)}" + f"[ESP:{log.id}][{log.tag}][{level}] {log.log_message}" + f"{_color('RESET')}" + )