Skip to content

Instantly share code, notes, and snippets.

@azurekid
Last active August 20, 2025 12:54
Show Gist options
  • Select an option

  • Save azurekid/73a8449f6796c0e01f48d787b867d2b1 to your computer and use it in GitHub Desktop.

Select an option

Save azurekid/73a8449f6796c0e01f48d787b867d2b1 to your computer and use it in GitHub Desktop.
Invoke-StealthOperation

Building Invoke-StealthOperation: A Journey into Cultural Cybersecurity

Published: August 20, 2025 | By BlackCat Security Team


The Pattern Recognition Problem

While developing reconnaissance tools for the BlackCat module, I kept running into a fundamental issue: modern detection systems are not only flagging tools by what they were doing, but also when they were doing it. The functions themselves worked perfectly, but their timing patterns might scream "automation" to behavioral analysis engines.

Traditional approaches using fixed delays or simple randomization actually make the problem worse. A consistent 5-second interval between DNS queries is obviously scripted. Even random delays between 1-10 seconds create statistical signatures that machine learning detection can identify within minutes of observation.

The idea came from thinking about when legitimate network activity actually happens. Real users don't work at 3 AM. They take lunch breaks. They follow cultural patterns that vary by region. If my reconnaissance could mimic these natural rhythms, it would blend into expected traffic patterns instead of standing out as anomalous behavior.

This led me to use AI assistance to research business hours across different countries, discovering fascinating cultural work patterns that could be leveraged for reconnaissance timing. Spain's siesta tradition, China's noon nap culture, France's regulated 35-hour work weekโ€”these weren't just cultural curiosities. They were timing intelligence that could make automated reconnaissance appear naturally human.

Building a Cultural Solution

The first version of Invoke-StealthOperation was simple, calculating business hours for just the US and UK. But testing across different regions revealed the need for something more advanced. Spanish businesses often operate on split schedules: 9 AM to 2 PM, then 5 PM to 8 PM, with a three-hour siesta break. Running reconnaissance tools during siesta hours would stick outโ€”no legitimate Spanish business user would be doing intensive network activity at 3 PM on a Tuesday.

Building a database of business patterns could be useful. Each country has unique timing opportunities. Italy has its riposo tradition with long lunch breaks, France operates under legally mandated 35-hour work weeks that affect user patterns, and China incorporates traditional noon naps into modern business culture. Countries like Spain, Italy, and Mexico follow split schedules, while France, China, and Brazil have regulated or culturally-influenced timing patterns. Standard continuous business hours in countries like the US, UK, Germany, and Japan provided baseline comparison points.

A simple command like this demonstrates the cultural awareness:

"target.es" | Invoke-StealthOperation -DelayType BusinessHours -Country "ES" -MinDelay 1 -MaxDelay 30 | ForEach-Object {
    Find-DnsRecords -Domains $_
}

This automatically waits for Spanish business hours (9-14, 17-20), respects the siesta period (14-17), and applies realistic delays based on expected activity levels.

Algorithm Evolution and Features

Testing across different scenarios revealed that one delay pattern wasn't sufficient. Different operations needed different behavioral models, leading to four distinct timing algorithms:

Random Pattern provides basic unpredictable timing suitable for general reconnaissance. While good for initial scans, it lacks sophistication and can still be detected through statistical analysis over time.

Progressive Pattern mimics human behavior by becoming more cautious as operations continue. Humans don't maintain consistent timingโ€”we naturally slow down as we probe deeper into systems, making this pattern feel organic.

BusinessHours Pattern represents the cultural breakthrough, providing timezone-aware delays that understand local business culture in the target's timezone. The function automatically converts to the target country's time zone and waits for appropriate business hours before beginning operations, ensuring business hours are calculated correctly regardless of your location. This is where the real magic happens, blending automated activities into expected local traffic patterns.

Exponential Pattern deals with adaptive defenses by implementing exponential backoff (1s, 2s, 4s, 8s, 16s...). This proves essential for sensitive environments where systems seem to "learn" from reconnaissance patterns.

Additional features like Jitter adds randomness to the cultural timing, preventing overly perfect patterns. Silent operation prevents timing messages from appearing in logs during security assessments. BusinessHours timing provides ultimate patience, automatically waiting until appropriate local business hours when operations begin outside normal working times.

Here's how these patterns work in practice:

# Progressive reconnaissance that adapts to target responses
Get-Content targets.txt | Invoke-StealthOperation -DelayType Progressive -MinDelay 2 -MaxDelay 60

# Cultural timing with added human-like randomness  
Invoke-StealthOperation -DelayType BusinessHours -Country "IT" -MinDelay 2 -MaxDelay 20 -Jitter 0.3 -Silent

# Automatic business hours patience with Japanese cultural patterns
Invoke-StealthOperation -DelayType BusinessHours -MinDelay 5 -MaxDelay 30 -Country "JP"

# Override timezone for regional precision (US West Coast)
Invoke-StealthOperation -DelayType BusinessHours -Country "US" -TimeZone "Pacific Standard Time" -MinDelay 2 -MaxDelay 15

# Quick UTC offset for field operations (Central European Time)
Invoke-StealthOperation -DelayType BusinessHours -Country "DE" -TimeZone "+1" -MinDelay 3 -MaxDelay 12

Enhanced User Experience: Validation and Visual Feedback

Parameter Validation for Reliability

Building a tool that depends on cultural intelligence requires bulletproof parameter validation. The latest version includes strict country code validation that prevents configuration errors before they cause problems:

# This will show a clear error with all valid options
Invoke-StealthOperation -Country "Spain" -DelayType BusinessHours
# Error: "Spain" does not belong to the set "US,UK,DE,JP,AU,ES,IT,FR,MX,CN,BR,IN,KR"

# This works perfectly with tab completion
Invoke-StealthOperation -Country "ES" -DelayType BusinessHours

The ValidateSet attribute provides several user experience improvements:

  • Tab completion automatically shows valid country codes
  • Clear error messages list all acceptable values when invalid input is provided
  • IDE support enables IntelliSense autocompletion in VS Code and ISE
  • Documentation integration keeps help text synchronized with valid values

This validation came from real-world experience where typos like "UK" vs "GB" or "Spain" vs "ES" would silently fall back to US business hours, undermining the entire cultural intelligence approach.

Visual Communication Through Emojis

The enhanced emoji system provides immediate visual feedback about operational state and timing strategy:

VERBOSE: ๐Ÿš€ Starting stealth pipeline with BusinessHours timing
VERBOSE: ๐Ÿข Using country-specific configuration: ES  
  ๐Ÿข Stealth delay: 8s (BusinessHours (ES))
VERBOSE: โœ… Stealth pipeline completed for 1 items

Different operational contexts get distinctive emoji indicators:

Timing Strategy Emojis:

  • ๐Ÿข Country-specific business hours (cultural patterns)
  • ๐ŸŒ Timezone override (generic patterns with custom timezone)
  • ๐Ÿ“ˆ Progressive delays (escalating caution)
  • ๐Ÿš€ Exponential backoff (adaptive defense response)
  • ๐ŸŽฒ Random timing (baseline unpredictability)

Status and Warning Emojis:

  • ๐Ÿš€ Pipeline start notification
  • โœ… Successful completion indicator
  • โš ๏ธ Configuration warnings (invalid timezones, fallback scenarios)
  • ๐ŸŒ… Siesta/lunch break waiting periods
  • ๐ŸŒ™ Long waits until business hours
  • โฐ Short waits for business hour start

The emoji system emerged from console fatigue during long reconnaissance sessions. When running operations that might span hours, visual differentiation becomes critical for quick status assessment. The context-aware emojis communicate timing strategy at a glance:

# Country-specific cultural timing
"target.es" | Invoke-StealthOperation -Country ES -DelayType BusinessHours -Verbose
# Output: ๐Ÿข Stealth delay: 5s (BusinessHours (ES))

# Same country with timezone override
"target.es" | Invoke-StealthOperation -Country ES -TimeZone "+2" -DelayType BusinessHours -Verbose  
# Output: ๐ŸŒ Stealth delay: 3s (BusinessHours (UTC+2))

The emoji differentiation immediately shows that the second command is using generic business hours with a custom timezone instead of Spanish cultural patterns. This visual feedback prevents configuration mistakes that could compromise operational security.

Testing and Practical Applications

Real-world testing demonstrates the effectiveness of cultural timing patterns. Multi-country campaigns showed how different regions naturally follow their local business rhythms. Spanish targets would wait for morning business hours, pause during siesta, then resume at 5 PM. Italian targets respected riposo periods. US targets ran continuously. Each approach felt completely natural for its region.

The enhanced visual feedback makes long reconnaissance sessions much more manageable. A typical cultural timing session now provides clear status indicators:

VERBOSE: ๐Ÿš€ Starting stealth pipeline with BusinessHours timing
VERBOSE: ๐Ÿข Using country-specific configuration: ES
  ๐Ÿข Stealth delay: 3s (BusinessHours (ES))
  ๐Ÿข Stealth delay: 8s (BusinessHours (ES))
  ๐ŸŒ… Waiting 45m until ES siesta/lunch break ends...
  ๐Ÿข Stealth delay: 5s (BusinessHours (ES))
VERBOSE: โœ… Stealth pipeline completed for 15 items

The visual progression tells the operational story at a glance: normal Spanish business hours timing, then an automatic pause for siesta, followed by resumed afternoon activity. This immediate feedback prevents questioning whether the cultural intelligence is actually working.

Phased reconnaissance approaches provide particularly effective behavior patterns, mimicking how attackers naturally escalate their activities. Starting with gentle random delays for initial DNS reconnaissance, progressing to methodical timing for subdomain enumeration, and finally using exponential backoff for sensitive container discovery creates realistic behavioral patterns that avoid detection systems:

# Multi-region cultural awareness with visual confirmation
$targets = @(
    @{Domain="target.es"; Country="ES"},
    @{Domain="target.it"; Country="IT"}, 
    @{Domain="target.com"; Country="US"}
)

$targets | ForEach-Object {
    Write-Host "๐ŸŒ Starting reconnaissance for $($_.Domain) using $($_.Country) cultural patterns" -ForegroundColor Cyan
    $_.Domain | Invoke-StealthOperation -DelayType BusinessHours -Country $_.Country -MinDelay 2 -MaxDelay 15 -Verbose | ForEach-Object {
        Find-SubDomain -DomainName $_
    }
}

# Phased reconnaissance escalation with emoji feedback
$phases = @(
    @{Function="Find-DnsRecords"; Pattern="Random"; Min=1; Max=5; Description="๐ŸŽฒ Initial reconnaissance"},
    @{Function="Find-SubDomain"; Pattern="Progressive"; Min=5; Max=30; Description="๐Ÿ“ˆ Subdomain enumeration"},
    @{Function="Find-PublicStorageContainer"; Pattern="Exponential"; Min=10; Max=120; Description="๐Ÿš€ Sensitive discovery"}
)

$phases | ForEach-Object {
    Write-Host $_.Description -ForegroundColor Green
    "target.com" | Invoke-StealthOperation -DelayType $_.Pattern -MinDelay $_.Min -MaxDelay $_.Max -Verbose
}

Advanced techniques involve layering multiple delay patterns for incredibly realistic behavior. Applying cultural timing first, then adding random human-like variation creates results that feel completely organic. The function also supports adaptive timing that monitors target response speeds and automatically adjusts caution levelsโ€”fast responses suggest high-performance monitoring, triggering more conservative approaches.

"target.com" | 
    Invoke-StealthOperation -DelayType BusinessHours -Country "ES" -MinDelay 2 -MaxDelay 20 |
    Invoke-StealthOperation -DelayType Random -MinDelay 2 -MaxDelay 8 -Jitter 0.4

Implementation and Responsible Use

The function integrates seamlessly with BlackCat reconnaissance workflows through pipeline processing that handles massive datasets efficiently. Items process individually rather than loading entire collections into memory, supporting operations against wordlists with 100,000+ entries without system impact.

# Seamless pipeline integration with timing awareness
"target.com" | 
    Invoke-StealthOperation -DelayType BusinessHours -Country "UK" -MinDelay 2 -MaxDelay 15 |
    ForEach-Object { Find-DnsRecords -Domains $_ } |
    Where-Object { $_.RecordType -eq "A" } |
    ForEach-Object { 
        $_.Domain | Invoke-StealthOperation -DelayType Random -MinDelay 1 -MaxDelay 5 | 
        ForEach-Object { Find-SubDomain -DomainName $_ }
    }

# Memory-efficient processing of large datasets  
Get-Content massive-wordlist.txt | Invoke-StealthOperation -DelayType Random -MinDelay 1 -MaxDelay 3 | ForEach-Object { Find-SubDomain -DomainName "target.com" -WordList $_ }

Design Simplification: BusinessHours Logic

During development, I realized that having a separate -WaitForBusinessHours parameter was redundant. If someone chooses BusinessHours timing, they implicitly want business hours behavior. The original design required users to specify both -DelayType BusinessHours and -WaitForBusinessHours, which violated the principle of least surprise.

The current implementation makes waiting the default behavior for BusinessHours timing:

# Simple and intuitive - BusinessHours timing automatically waits for business hours
Invoke-StealthOperation -DelayType BusinessHours -Country "ES"

# No need for redundant parameters like the old design:
# Invoke-StealthOperation -DelayType BusinessHours -Country "ES" -WaitForBusinessHours

This design change eliminates user confusion and reduces the parameter surface area while maintaining all the cultural intelligence functionality.

Technical Foundation and Best Practices

Memory Efficiency Through Real-World Testing

Pipeline processing handles massive datasets efficiently because I optimized it during actual engagements:

Get-Content massive-wordlist.txt | Invoke-StealthOperation -DelayType Random -MinDelay 1 -MaxDelay 3 | ForEach-Object { Find-SubDomain -DomainName "target.com" -WordList $_ }

Items process individually rather than loading entire collections into memory. This design emerged from trying to scan 100,000+ subdomains without crashing the host system.

Timezone Implementation - The Hard-Won Details

The timezone handling went through multiple iterations:

  • System timezone APIs provide precise calculations
  • Daylight saving time transitions are handled automatically
  • Falls back to UTC when timezone data is unavailable

I learned about these edge cases the hard way, during assessments that spanned DST transitions and in regions with complex timezone politics.

Cultural Research That Matters

Through trial and error, I learned which cultural elements actually impact detection:

  • Spain/Italy: Siesta and riposo periods are sacred. Ignore them at your peril.
  • France: The 35-hour work week isn't just a lawโ€”it shapes legitimate user behavior patterns.
  • China: Noon nap culture means midday activity looks suspicious.
  • Brazil: Early start times completely change when "normal" business activity occurs.

Adaptive Timing - Learning from the Target

One of my favorite techniques emerged from a long-term engagement:

$targets | ForEach-Object {
    $startTime = Get-Date
    $_ | Invoke-StealthOperation -DelayType Progressive -MinDelay 1 -MaxDelay 10 | ForEach-Object { Find-DnsRecords -Domains $_ }
    $duration = (Get-Date) - $startTime
    
    if ($duration.TotalSeconds -lt 1) {
        $nextDelay = "Exponential"  # Target is fast - increase caution
    }
}

This approach monitors how quickly the target responds and adjusts the stealth pattern accordingly. Fast responses suggest high-performance monitoring, so the script automatically becomes more cautious.

The Responsibility That Comes With Power

Building culturally-aware security tools carries significant responsibility. The approach requires respecting the people behind cultural patternsโ€”siesta isn't just a detection evasion opportunity, it's a cultural tradition that deserves respect. Essential guidelines include testing only systems you own or have explicit written permission to test, documenting timing strategies for post-assessment analysis, considering impact on target systems and legitimate users, and always complying with local testing regulations and cultural norms.

Best Practices From Experience

  • Start with conservative delays and adjust based on what you observe
  • Document your timing strategies for client reports and lessons learned
  • Consider system stabilityโ€”some delays exist for good reasons
  • Use business hours awareness to minimize disruption to legitimate operations

The modular design supports customization through extending the business hours hash table with additional countries, implementing custom delay algorithms, and integrating external threat intelligence feeds. This flexibility allows security professionals to adapt the approach to specific regional requirements and organizational needs.

Visual Design Through User Experience

The emoji feedback system emerged from console fatigue during lengthy reconnaissance sessions. When operations span hours, visual differentiation becomes critical for operational awareness:

# Clear visual progression during cultural timing
VERBOSE: ๐Ÿš€ Starting stealth pipeline with BusinessHours timing
VERBOSE: ๐Ÿข Using country-specific configuration: ES
  ๐Ÿข Stealth delay: 12s (BusinessHours (ES))
  ๐Ÿข Stealth delay: 8s (BusinessHours (ES))
  ๐ŸŒ… Waiting 45m until ES siesta/lunch break ends...
  ๐Ÿข Stealth delay: 6s (BusinessHours (ES))
VERBOSE: โœ… Stealth pipeline completed for 25 items

The context-aware emoji system provides immediate operational intelligence:

  • ๐Ÿข vs ๐ŸŒ: Distinguishes cultural patterns from timezone overrides
  • ๐ŸŒ… vs ๐ŸŒ™: Different wait types (siesta vs overnight)
  • ๐Ÿ“ˆ ๐Ÿš€ ๐ŸŽฒ: Timing strategy at a glance
  • โš ๏ธ: Configuration issues requiring attention

This visual language reduces cognitive load during complex operations and prevents the configuration mistakes that used to compromise stealth effectiveness.

Future Development and Extensibility

The modular design supports customization because I knew others would want to adapt it:

  • Add countries to the $businessHours hash table
  • Implement custom delay algorithms
  • Integrate external threat intelligence feeds

Invoke-StealthOperation represents my approach to ethical security testing: sophisticated enough to be effective, but built with respect for the cultures and people it interacts with. It's not just about evading detectionโ€”it's about conducting operations that feel genuinely human.

The function solves technical problems through cultural understanding. Rather than fighting against human patterns, it embraces them. That philosophical shift has made all the difference in my security assessments.


How to Get Started

The BlackCat module is available at github.com/azurekid/blackcat. The function integrates seamlessly with existing reconnaissance workflows, and the cultural intelligence features activate automatically when you specify a valid country code.

The enhanced parameter validation means you can start testing immediately without worrying about configuration errors. Use tab completion to explore the supported countries:

Invoke-StealthOperation -Country <TAB> -DelayType BusinessHours

# Visual feedback confirms your configuration is working
"target.com" | Invoke-StealthOperation -Country ES -DelayType BusinessHours -Verbose
# VERBOSE: ๐Ÿข Using country-specific configuration: ES
#   ๐Ÿข Stealth delay: 8s (BusinessHours (ES))

Start with your local business hours, then experiment with different cultural patterns. The emoji feedback will immediately show whether you're using cultural patterns (๐Ÿข) or timezone overrides (๐ŸŒ), preventing the silent configuration errors that used to undermine stealth effectiveness.

You'll be surprised how much more natural your security testing feels when it respects the rhythms of human workโ€”and how much more reliable it becomes when the tools actively prevent configuration mistakes.


Build tools that understand people, not just technology. The best security testing happens when humans can't tell it apart from legitimate activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment