Autonomous loops

From brucesongs/kali-claw · View interactive version

Autonomous loops is an AI agent skill from the GitHub repository brucesongs/kali-claw. Performing repetitive enumeration across many targets - Running batch vulnerability scans on multiple hosts - Monitoring for changes in target environment - Executing attack chains that require iterative steps - User says \"loop\", \"automate\", \"batch\", \"repeat.

How to use this skill

Skill file

Autonomous Loops

Supplementary Files:

- payloads.md — Scope Lock templates, rate limit configurations, loop command templates, and error handling response templates

- test-cases.md — Structured test cases for sequential pipeline, watch loop, batch processing, learning cycle, scope violation, and rate limit backoff

- guides/safe-autonomous-pentest.md — Deep-dive guide on autonomous vs manual decision making, scope lock construction, loop composition, and monitoring

Summary

Autonomous Loops skill domain covering infrastructure operations.

Domain: infrastructure

Use Cases

  1. Sequential Pipeline — Chain multiple security tools in order (recon → scan → exploit) with automatic phase transitions
  2. Watch Loop — Monitor a target for changes (new ports, updated services) over extended periods
  3. Batch Processing — Run the same test against multiple targets with rate limiting and error recovery
  4. Learning Cycle — Execute a skill, capture results, extract patterns, and update knowledge base automatically
  5. Scope-Locked Automation — Run autonomous loops with hard boundaries that prevent actions outside authorized scope

Activation

Core Principle

Autonomous does not mean uncontrolled. Every loop must have:

  1. A defined scope (what it can and cannot touch)
  2. A termination condition (when it stops)
  3. Rate limiting (how fast it runs)
  4. Evidence logging (what it did)
  5. Error handling (what happens when things go wrong)

Four Loop Patterns

Pattern 1: Sequential Pipeline

Execute a sequence of steps across multiple targets, one at a time.

FOR EACH target IN target_list:
    IF scope_check(target) == ALLOWED:
        result = execute_step(target)
        log_evidence(target, result)
        IF result.status == FAIL:
            handle_error(target, result)
            CONTINUE or BREAK based on severity
    ELSE:
        log_skipped(target, "Out of scope")

Use when: Enumerating ports across a subnet, testing a specific vulnerability across multiple hosts.

Safety rules:

Pattern 2: Watch Loop

Monitor a target for changes or conditions, then act when triggered.

WHILE condition_not_met AND iterations < max_iterations:
    current_state = observe(target)
    log_observation(current_state)
    IF trigger_condition(current_state):
        result = execute_response(target, current_state)
        log_evidence("trigger", result)
        IF one_shot: BREAK
    WAIT(polling_interval)

Use when: Waiting for a service to come online, monitoring for new open ports, watching log files for specific events.

Safety rules:

Pattern 3: Batch Processing

Apply the same operation to a batch of targets in parallel (with concurrency limit).

CONCURRENCY = 5  # Maximum simultaneous operations
results = []

FOR EACH batch IN split_into_batches(target_list, CONCURRENCY):
    batch_results = PARALLEL execute_step(batch)
    FOR EACH result IN batch_results:
        log_evidence(result.target, result)
        results.append(result)
    WAIT(rate_limit_delay)  # Pause between batches

Use when: Running nmap scans across many hosts, batch DNS lookups, mass HTTP header checks.

Safety rules:

Pattern 4: Learning Cycle

Iteratively refine an approach based on results from previous iterations.

approach = initial_approach
FOR iteration IN range(max_iterations):
    result = execute(approach)
    analysis = analyze_result(result)
    log_evidence(iteration, approach, result, analysis)
    IF analysis.success:
        log_evidence("success", approach)
        BREAK
    approach = refine(approach, analysis)
    IF approach.confidence < min_confidence:
        log_evidence("abort", "Confidence below threshold")
        BREAK

Use when: Brute-forcing with adaptive wordlists, SQL injection payload refinement, fuzzing with feedback.

Safety rules:

Safety Framework

Scope Lock

Before ANY loop starts, define and lock the scope:

## Scope Lock: [Operation Name]
- **Allowed targets:** [CIDR range / hostname list / URL list]
- **Allowed operations:** [Specific commands/techniques]
- **Forbidden operations:** [What must NOT be done]
- **Time limit:** [Maximum wall-clock time]
- **Iteration limit:** [Maximum number of iterations]
- **Abort conditions:** [Specific triggers that stop the loop]

Once defined, the scope cannot be widened during execution.

Rate Limiting

| Operation Type | Minimum Interval | Max Concurrency |

|---------------|-----------------|-----------------|

| Network scan (nmap) | 2s between hosts | 5 |

| Web request (HTTP) | 100ms between requests | 3 |

| DNS lookup | 50ms between queries | 10 |

| Brute force attempt | 500ms between attempts | 1 |

| Exploit attempt | 5s between attempts | 1 |

Evidence Logging

Every loop iteration must log:

## Loop Log Entry
- **Timestamp:** [ISO 8601]
- **Iteration:** [N / max]
- **Target:** [host/port/URL]
- **Action:** [command or technique]
- **Result:** [success/fail/error/timeout]
- **Output:** [truncated to 500 chars, full output saved to file]
- **State change:** [what changed on target, if any]

Error Handling

| Error Type | Response |

|-----------|----------|

| Target unreachable | Log and skip, continue to next target |

| Rate limit detected | Increase delay by 2x, retry once |

| Authentication failure | Log and skip (do NOT retry with variations) |

| Unexpected service response | Log details, flag for manual review, continue |

| IDS/IPS detected | STOP immediately, log incident |

| Target crash/unexpected downtime | STOP immediately, log incident |

| Scope violation attempt | STOP immediately, log incident |

Notification Rules

Notify the operator when:

Integration with Other Skills

| Skill | Loop Pattern | Application |

|-------|-------------|-------------|

| vulnerability-assessment | Batch Processing | Scan multiple hosts for vulnerabilities |

| password-attack | Learning Cycle | Adaptive brute force with feedback |

| web-sqli | Learning Cycle | Iterative payload refinement |

| network-pentest | Sequential Pipeline | Multi-host enumeration |

| osint | Batch Processing | Mass DNS/WHOIS lookups |

| terminal-ops | All patterns | Evidence logging protocol |

| verification-loop | Sequential Pipeline | Verify findings across multiple hosts |

| safety-guard | All patterns | Pre-execution safety checks |

Detection Methods

Autonomous Loop Indicators

SIEM Detection Rules

Defense Evasion Techniques

Loop Stealth

Self-Modification Stealth

Anti-Patterns

Orchestration

ECC Loop Pattern

Cross-Skill Pipeline

autonomous-loops (provides loop patterns)
    ├── Sequential Pipeline → network-pentest, terminal-ops, verification-loop
    ├── Watch Loop → security-bounty-hunter, deep-research
    ├── Batch Processing → repo-scan, osint, vulnerability-assessment
    └── Learning Cycle → search-first, continuous-learning, password-attack

Quality Gate

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.