Skip to content

Latest commit

 

History

History
701 lines (524 loc) · 18.4 KB

File metadata and controls

701 lines (524 loc) · 18.4 KB

Network Scanner Integration - ASUS 4C with Blockcode NFTs

Complete integration of nmap, netstat, unison, and PureData/plugdata with blockcode NFT evolution for monitoring the ASUS 4C network.


Overview

┌─────────────────────────────────────────────────────────────────┐
│              Network Scanning Stack (ASUS 4C)                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  nmap (network scan) ──┐                                        │
│                        ├──► Network Scanner ──► Blockcode NFT   │
│  netstat (connections) ┘         │                    │         │
│                                   │                    │         │
│  unison (sync) ───────────────────┘                    │         │
│                                                        │         │
│  PureData/plugdata ◄───── OSC callbacks ◄──────────────┘         │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Components

1. Network Monitor with Plugdata (network_monitor_plugdata.py)

Features:

  • ✅ nmap network scanning
  • ✅ netstat active connection monitoring
  • ✅ unison file synchronization on network changes
  • ✅ OSC callbacks to PureData/plugdata
  • ✅ Auto-generated PureData patches
  • ✅ Continuous monitoring mode

Usage:

# Single scan
python network_monitor_plugdata.py

# Continuous monitoring (30s interval)
python network_monitor_plugdata.py --monitor

# With unison sync
python network_monitor_plugdata.py --monitor --unison

# Custom interval (10s)
python network_monitor_plugdata.py --monitor --interval 10

2. Network Scanner with Blockcode (network_scanner_blockcode.py)

Features:

  • ✅ Integrates nmap + netstat + blockcode NFTs
  • ✅ Creates NFTs from network scan results
  • ✅ Evolves NFTs when network changes
  • ✅ Sends callbacks to PureData
  • ✅ JSON export of scan results

Usage:

# Run unified scan
python network_scanner_blockcode.py --scan

# Continuous monitoring
python network_scanner_blockcode.py --monitor

# With unison + custom interval
python network_scanner_blockcode.py --monitor --unison --interval 20

Installation

Required Tools

# Install nmap
brew install nmap

# Install unison (optional, for file sync)
brew install unison

# Install Python OSC library (for PureData)
pip install python-osc

# Blockcode NFT system (already in this directory)
# No additional install needed

PureData/plugdata

# Already installed at:
~/Documents/plugdata/

# Generated patch will be saved to:
~/Documents/plugdata/network_monitor.pd

Workflow

1. Network Scan → Blockcode NFT Evolution

Step 1: Run nmap scan on ASUS 4C network
  └─► Discovers hosts: 192.168.1.1, 192.168.1.10, etc.

Step 2: Parse scan results
  └─► hosts_found: 5
      connections: 12

Step 3: Create network state NFT
  └─► Pattern: AB.3:3.P&B.F1
      Vertex: [1, 0, 0, 0]  (WiFi active)
      Metadata: {hosts: 5, connections: 12}

Step 4: On next scan, if network changed
  └─► Evolve NFT via X-edge: [1,0,0,0] → [0,0,0,0]
      Or via T-edge for temporal: [1,0,0,0] → [1,0,0,1]

Step 5: Send to PureData
  └─► OSC message: /network/scan_complete [5, timestamp, 12]
      PureData converts to audio (5 hosts → 500Hz tone)

2. PureData Audio Feedback

Network Scan Results → OSC → PureData → Audio

hosts_found:    5  → 500Hz sine wave
connections:   12  → Filter resonance at 700Hz
scan_duration: 3s  → Amplitude envelope

Real-time audio represents network state

3. Unison Sync on Network Change

Scan 1: 5 hosts found
Scan 2: 3 hosts found  (network changed!)
  └─► Trigger unison sync
      ~/blockcode ↔ ssh://backup/RSN7C
      
      Syncs modified packages during network changes

ASUS 4C Network Specifics

Typical ASUS Router Configuration

Router IP:     192.168.1.1 or 192.168.50.1
DHCP range:    192.168.1.2 - 192.168.1.254
WiFi SSID:     "asus 4c" or similar
Admin portal:  http://192.168.1.1

Scan Targets

# Primary scan
nmap -sn 192.168.1.0/24

# Service detection
nmap -sV 192.168.1.1

# Port scan (router)
nmap -p 22,80,443,8080 192.168.1.1

# Fast scan
nmap -T4 -sn 192.168.1.0/24

PureData Patch

Auto-generated patch receives OSC and converts to audio:

┌─────────────────────────────────────────────┐
│  PureData Network Monitor Patch             │
├─────────────────────────────────────────────┤
│                                             │
│  [netreceive 9000] ← OSC from Python       │
│         │                                   │
│         ↓                                   │
│  [oscparse]                                 │
│         │                                   │
│         ↓                                   │
│  [route /network/scan_complete]            │
│         │                                   │
│         ├──► hosts_found → [* 100] → [osc~] → [dac~]
│         │                                   │
│         └──► connections → [* 50] → [vcf~] │
│                                             │
└─────────────────────────────────────────────┘

Audio Output:
  - More hosts = higher frequency
  - More connections = higher filter resonance
  - Network activity = audio feedback

Integration Architecture

┌──────────────────────────────────────────────────────────────────┐
│                    ASUS 4C Network Monitor                        │
└───────────────────────────┬──────────────────────────────────────┘
                            │
        ┌───────────────────┼───────────────────┐
        │                   │                   │
        ▼                   ▼                   ▼
   ┌────────┐         ┌─────────┐        ┌──────────┐
   │  nmap  │         │ netstat │        │  unison  │
   │ Scanner│         │ Monitor │        │   Sync   │
   └───┬────┘         └────┬────┘        └────┬─────┘
       │                   │                   │
       └───────────────────┴───────────────────┘
                           │
                           ▼
            ┌──────────────────────────────┐
            │  Network Scanner Blockcode   │
            │                              │
            │  • Parse scan results        │
            │  • Detect changes            │
            │  • Trigger callbacks         │
            └──────────┬───────────────────┘
                       │
        ┌──────────────┼──────────────┐
        │              │              │
        ▼              ▼              ▼
┌──────────────┐  ┌─────────┐  ┌──────────────┐
│ Blockcode NFT│  │PureData │  │ JSON Export  │
│              │  │ OSC     │  │              │
│ • Create     │  │ • Audio │  │ • scan_*.json│
│ • Evolve     │  │ • Visual│  │ • History    │
│ • Track      │  │ • Tone  │  │ • Reports    │
└──────────────┘  └─────────┘  └──────────────┘

Usage Examples

Example 1: Basic Scan

cd ~/blockcode

python network_scanner_blockcode.py --scan

Output:

================================================================================
Unified Network Scan: asus 4c
================================================================================

🔍 Scanning ASUS 4C network...
  Scanning 192.168.1.0/24...
    ✓ Found 5 hosts

📊 Monitoring ports with netstat...
  ✓ Active connections: 12

🎨 Creating network scan NFT...
  ✓ NFT created: AB.3:3.P&B.F1
    Vertex: [1, 0, 0, 0]

  → PureData callback: {'hosts_found': 5, 'connections': 12, ...}

================================================================================
Scan complete!
================================================================================

Results saved: scan_results_20250130_123456.json

Example 2: Continuous Monitoring

python network_scanner_blockcode.py --monitor --interval 30

Runs continuous scans every 30 seconds, creating NFTs and sending PureData callbacks.

Example 3: With Unison Sync

python network_scanner_blockcode.py --monitor --unison

Triggers file sync when network changes detected.


PureData Integration

1. Generate Patch

python network_monitor_plugdata.py

Creates: ~/Documents/plugdata/network_monitor.pd

2. Open in Plugdata

open ~/Documents/plugdata/network_monitor.pd

Or open plugdata application and load network_monitor.pd

3. Start Monitoring

# In another terminal
python network_scanner_blockcode.py --monitor

PureData will receive OSC messages and generate audio based on network activity.


Blockcode NFT Evolution Rules

Network Scan Events

Event Evolution Edge Result
Hosts increase Spatial shift X-edge [0,y,z,t] → [1,y,z,t]
Hosts decrease Spatial shift X-edge [1,y,z,t] → [0,y,z,t]
Connections spike Temporal T-edge [x,y,z,0] → [x,y,z,1]
Network rescan Spatial Y-edge [x,0,z,t] → [x,1,z,t]

NFT Metadata Structure

{
  "pattern_code": "AB.3:3.P&B.F1",
  "vertex": [1, 0, 0, 0],
  "metadata": {
    "network_name": "asus 4c",
    "hosts_found": 5,
    "connections": 12,
    "scan_timestamp": "2025-01-30T12:34:56",
    "router_ip": "192.168.1.1",
    "scan_duration": 3.2
  }
}

File Structure

blockcode_nft_rewrite/
├── network_monitor_plugdata.py        (350 lines) ← Network monitoring
├── network_scanner_blockcode.py       (400 lines) ← Blockcode integration
├── NETWORK_SCANNER_INTEGRATION.md     (This file)
│
└── Generated:
    ├── scan_results_*.json            (Scan outputs)
    └── ~/Documents/plugdata/network_monitor.pd (PureData patch)

Dependencies

# System tools
brew install nmap        # Network scanner
brew install unison      # File sync (optional)

# Python packages
pip install python-osc   # For PureData OSC communication

# Already installed
# - plugdata (~/Documents/plugdata/)
# - Blockcode NFT system

Quick Start

cd ~/blockcode

# 1. Check tools
python network_scanner_blockcode.py

# 2. Run single scan
python network_scanner_blockcode.py --scan

# 3. Start continuous monitoring
python network_scanner_blockcode.py --monitor

# 4. Generate PureData patch
python network_monitor_plugdata.py

# 5. Open patch in plugdata
open ~/Documents/plugdata/network_monitor.pd

Scan Results Structure

{
  "timestamp": "2025-01-30T12:34:56",
  "network": "asus 4c",
  "nmap": {
    "scans": [
      {
        "target": "192.168.1.0/24",
        "hosts_found": 5,
        "hosts": [
          "192.168.1.1",
          "192.168.1.10",
          "192.168.1.15",
          "192.168.1.20",
          "192.168.1.25"
        ],
        "status": "success"
      }
    ]
  },
  "netstat": {
    "connections": 12,
    "details": [...]
  },
  "blockcode_nft": {
    "pattern_code": "AB.3:3.P&B.F1",
    "vertex": [1, 0, 0, 0]
  }
}

Unison Configuration

Basic Setup

# Create unison profile
cat > ~/.unison/asus4c_backup.prf << 'EOF'
# Unison profile for ASUS 4C network backup

root = ~/blockcode
root = ssh://backup-server//backup/RSN7C

# Sync on network changes
batch = true
silent = true

# Paths to sync
path = blockcode_nft_rewrite
path = flow_diagram.md
path = README.md

# Ignore
ignore = Path *.pyc
ignore = Path __pycache__
ignore = Path .git
EOF

# Run sync
unison asus4c_backup

Integration with Scanner

# Automatically triggered when network changes
monitor.run_unison_sync(
    source="~/blockcode",
    destination="ssh://backup/RSN7C"
)

PureData Audio Mapping

Network State → Audio Parameters

hosts_found:
  0-5 hosts   → 200-700Hz (base frequency)
  5-10 hosts  → 700-1200Hz
  10+ hosts   → 1200-2000Hz

connections:
  0-10 conns  → Filter Q: 1-3 (subtle resonance)
  10-50 conns → Filter Q: 3-6 (medium resonance)
  50+ conns   → Filter Q: 6-10 (sharp resonance)

scan_duration:
  0-5s   → Amplitude: 0.3
  5-15s  → Amplitude: 0.6
  15s+   → Amplitude: 0.9

network_change:
  True   → Trigger envelope (attack/release)
  False  → Sustained tone

Example PureData Patch Flow

[netreceive 9000]  ← Python sends OSC here
    │
    ↓
[oscparse]
    │
    ↓
[route /network/scan_complete]
    │
    ├──► [unpack f s f]  (hosts, timestamp, connections)
    │        │
    │        ├──► hosts × 100 + 200 → [osc~] → [*~ 0.3] → [dac~]
    │        │
    │        └──► connections × 50 + 100 → [vcf~ 4]
    │
    └──► [route /network/alert]
             └──► [bang] → [random 1000] → [osc~] → [dac~]

Example Outputs

Scan Output

$ python network_scanner_blockcode.py --scan

================================================================================
Unified Network Scan: asus 4c
================================================================================

🔍 Scanning ASUS 4C network...
  Scanning 192.168.1.0/24...
    ✓ Found 5 hosts

📊 Monitoring ports with netstat...
  ✓ Active connections: 12

🎨 Creating network scan NFT...
  ✓ NFT created: AB.3:3.P&B.F1
    Vertex: [1, 0, 0, 0]

  → PureData callback: {'hosts_found': 5, 'connections': 12, 'timestamp': '...'}

================================================================================
Scan complete!
================================================================================

Results saved: scan_results_20250130_123456.json

Continuous Monitoring Output

$ python network_scanner_blockcode.py --monitor --interval 10

================================================================================
Starting Continuous Network Monitor for 'asus 4c'
================================================================================

Dependencies:
  ✓ nmap
  ✓ netstat
  ✓ unison
  ✓ plugdata

Monitoring interval: 10 seconds
Press Ctrl+C to stop

[Scan #1] 12:34:56
────────────────────────────────────────────────────────────────────────────────
🔍 Running nmap scan on 192.168.1.0/24...
  ✓ Scan complete: 5 hosts found

📡 Getting active connections via netstat...
  ✓ Found 12 active connections

  → PureData OSC: /network/scan_complete [5, '...', 12]

  Summary: 12 active connections

[Scan #2] 12:35:06
────────────────────────────────────────────────────────────────────────────────
...

Advanced Usage

Custom Scan Scripts

from network_scanner_blockcode import NetworkScannerBlockcode

# Create scanner
scanner = NetworkScannerBlockcode("asus 4c")

# Custom scan
scan = scanner.nmap_scan_asus_network()
connections = scanner.netstat_monitor_ports()

# Create NFT from results
nft = scanner.create_network_nft(scan)

# Trigger evolution
evolved = scanner.trigger_blockcode_evolution(scan)

print(f"NFT: {nft['pattern_code']} at {nft['vertex']}")

Scheduled Scans

# Add to crontab
crontab -e

# Run scan every 30 minutes
*/30 * * * * cd ~/blockcode && python network_scanner_blockcode.py --scan >> network_monitor.log 2>&1

Troubleshooting

nmap not found

brew install nmap
# Or download from: https://nmap.org/download.html

Permission denied (nmap)

# Run with sudo for some scan types
sudo python network_scanner_blockcode.py --scan

PureData not receiving OSC

# Check PureData is running
# Check OSC port (default 9000)
# Install python-osc: pip install python-osc

Unison errors

# Initialize unison profile first
unison -help
# Or disable unison: remove --unison flag

Next Steps

  1. ✅ Network scanner with nmap/netstat
  2. ✅ PureData/plugdata integration
  3. ✅ Blockcode NFT creation from scans
  4. ✅ Unison sync on network changes
  5. ⏳ Real OSC implementation (requires python-osc)
  6. ⏳ Advanced nmap service detection
  7. ⏳ Web dashboard for scan visualization

Status: ✅ Complete integration ready
Network: ASUS 4C monitoring
Tools: nmap, netstat, unison, PureData
Blockcode: NFT evolution on network events
Run: python network_scanner_blockcode.py --scan