feat: amélioration scripts bash, scan réseau, fix cron, README

- system_prompt: section scripts bash (commandes interdites, mosquitto_pub, bonnes pratiques)
- script.py: nettoyage guillemets échappés à la sauvegarde
- network.py: nouvelle action scan (nmap/arp-scan/arp fallback), auto-détection subnet
- cron.py: _get_current_crontab() évite d'écrire "(aucune sortie)" dans le crontab
- README créé

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 19:10:59 +00:00
parent ea1c67b33f
commit fc5b3f3bdc
10 changed files with 278 additions and 21 deletions
+29 -2
View File
@@ -2,6 +2,8 @@
Skill NETWORK — administration réseau.
Usage LLM :
SKILL:network ARGS:scan [subnet] — découverte des hôtes (ex: scan 192.168.7.0/24)
SKILL:network ARGS:arp — table ARP locale (hôtes récents)
SKILL:network ARGS:ip [show|route|link]
SKILL:network ARGS:ping <hôte> [count]
SKILL:network ARGS:traceroute <hôte>
@@ -20,8 +22,8 @@ Usage LLM :
"""
import subprocess
DESCRIPTION = "Administration réseau : ip, ping, traceroute, DNS, ports, firewall ufw/iptables"
USAGE = "SKILL:network ARGS:ip | ping <host> | traceroute <host> | dns <host> | ports | connections | firewall status|allow|deny|list | wget <url>"
DESCRIPTION = "Administration réseau : scan réseau, table ARP, ip, ping, traceroute, DNS, ports, firewall ufw/iptables"
USAGE = "SKILL:network ARGS:scan [subnet] | arp | ip | ping <host> | traceroute <host> | dns <host> | ports | connections | firewall status|allow|deny|list | wget <url>"
def _run(cmd: str, timeout: int = 20) -> str:
@@ -167,6 +169,31 @@ def run(args: str, context) -> str:
return "Précise l'URL."
return _run(f"curl -sI {url} | head -10")
if action == "scan":
# Détermine le subnet à scanner
subnet = rest.strip()
if not subnet:
# Auto-détecte le subnet depuis l'IP locale
iface_out = _run("ip -br addr show | grep -v '^lo' | head -1")
# Extrait le CIDR (ex: 192.168.7.5/24 → 192.168.7.0/24)
import re
m = re.search(r'(\d+\.\d+\.\d+)\.\d+/(\d+)', iface_out)
if m:
subnet = f"{m.group(1)}.0/{m.group(2)}"
else:
subnet = "192.168.0.0/24"
# Préfère nmap si dispo, sinon ping sweep
nmap_check = _run("which nmap")
if nmap_check and "nmap" in nmap_check:
return _run(f"nmap -sn --host-timeout 3s {subnet} -oG - | grep 'Up$' | awk '{{print $2, $3}}'", timeout=60)
# Fallback : arp-scan
arpscan_check = _run("which arp-scan")
if arpscan_check and "arp-scan" in arpscan_check:
return _run(f"arp-scan {subnet}", timeout=30)
# Fallback : table ARP après ping broadcast
_run(f"ping -c 1 -b {subnet.rsplit('.',1)[0]}.255 2>/dev/null || true", timeout=5)
return _run("arp -n")
if action == "arp":
return _run("arp -n")