# RBSM Technical Documentation & Manual (v4.6.3)
Robust Browser Stealth Management — The Native Anti-Detect Browser Automation Engine

---

## 1. Quickstart & License Setup

### Installation & System Requirements
RBSM is a standalone compiled binary with zero external runtime dependencies. It supports:
- **Windows** (x86_64, Windows 10/11, Windows Server 2016+)
- **Linux** (x86_64, Ubuntu 20.04+, Debian 11+, CentOS 8+, Alpine with glibc)
- **macOS** (ARM64 Apple Silicon M1–M4 & x86_64 Intel)

### Step 1: Obtain System Hardware ID (HWID)
```bash
# Windows
rbsm.exe -hwid

# Linux
./rbsm_linux_amd64 -hwid

# macOS
./rbsm_macos_arm64 -hwid
```

### Step 2: License File (`license.lic`)
Place your signed `license.lic` file in the same directory as the executable.
```text
rbsm_folder/
├── rbsm.exe (or rbsm_linux_amd64)
├── license.lic
├── proxies.txt (optional)
├── rules.json (optional)
└── macros/ (optional)
```

### Step 3: Run Your First Automation
```bash
# Launch interactive browser with proxy
./rbsm_linux_amd64 -proxy=true -add-url="https://nowsecure.nl"

# Run macro headless with dynamic proxy rotation
./rbsm_linux_amd64 -macros=macros/scrape.mac -headless=true -proxy=true
```

---

## 2. Complete Command-Line (CLI) Flags Reference

### A. Engine Core & Licensing
| Option / Flag | Type | Default | Description | Example |
| :--- | :--- | :--- | :--- | :--- |
| `-hwid` | `bool` | `false` | Display system hardware ID for license registration. | `-hwid` |
| `-headless` | `bool` | `false` | Run browser in invisible headless mode. | `-headless=true` |
| `-macros <file>` | `string` | `""` | Run automated macro script. | `-macros=macros/run.mac` |
| `-record <file>` | `string` | `""` | Launch live interactive browser recorder to generate macro. | `-record=macros/out.mac` |
| `-cdp <port>` | `int` | `0` | Enable Remote Debugging Chrome DevTools Protocol port. | `-cdp=9222` |
| `-mcp` | `bool` | `false` | Enable Model Context Protocol (MCP) server for Claude / LLMs. | `-mcp=true` |
| `-max-session <n>`| `int` | `0` | Auto-terminate browser session after N seconds (0 = unlimited). | `-max-session=120` |

### B. Network, Proxies & GeoIP
| Option / Flag | Type | Default | Description | Example |
| :--- | :--- | :--- | :--- | :--- |
| `-build` | `bool` | `false` | Build local embedded offline GeoIP database from MMDB. | `-build` |
| `-db <path>` | `string` | `""` | Source MMDB file path for `-build`. | `-build -db="custom.mmdb"` |
| `-proxy` | `bool` | `false` | Enable proxy routing from `proxies.txt`. | `-proxy=true` |
| `-add-proxy <file>`| `string` | `""` | Import proxy or proxy list file into `proxies.txt`. | `-add-proxy="proxies.txt"` |
| `-country <iso>` | `string` | `""` | Filter proxies or enforce country profile (e.g. `US,DE,GB`). | `-country=US,DE` |
| `-no-judges` | `bool` | `false` | Skip startup proxy judge reachability test (0ms latency). | `-no-judges=true` |
| `-limit-proxy <n>`| `int` | `0` | Max allowed uses per unique exit IP before auto-rotating. Set `1` for 1-session-per-IP isolation. | `-limit-proxy=1` |
| `-limit-timeout <n>`| `int` | `300` | Max rotation retry attempts before graceful exit. | `-limit-timeout=300` |

### C. URLs, Cookies & Browser Security Profiles
| Option / Flag | Type | Default | Description | Example |
| :--- | :--- | :--- | :--- | :--- |
| `-add-url <url>` | `string` | `""` | Add target URL or URL list file to storage. | `-add-url="https://site.com"` |
| `-clear-url` | `bool` | `false` | Clear stored target URLs. | `-clear-url` |
| `-show-url` | `bool` | `false` | Display stored target URLs. | `-show-url` |
| `-filter <domains>`| `string` | `""` | Domain filter list (e.g. `google.com,facebook.com`). | `-filter="site.com,api.site.com"` |
| `-bypass` | `bool` | `false` | Redirect target URLs to localhost for local testing. | `-bypass` |
| `-rules <file>` | `string` | `""` | Load startup network interception and ad-blocking rules JSON. | `-rules=rules/block_ads.json` |
| `-internal-spoof` | `string` | `""` | Internal platform profile (`ios`, `android`, `windows`, `macos`). | `-internal-spoof=android` |
| `-spoof-tcp <cmd>`| `string` | `""` | Low-level TCP SYN / TTL / p0f fingerprint spoofing (`start`, `run`, `stop`). **Linux environment only**. | `-spoof-tcp=run` |
| `-disable-cors` | `bool` | `false` | Disable browser web security and bypass CORS (`--disable-web-security` & CSP bypass). | `-disable-cors` |
| `-save-cookies` | `bool` | `false` | Save active browser session cookies to `cookies.json` on exit. | `-save-cookies` |
| `-set-cookies` | `bool` | `false` | Load / restore cookies from `cookies.json` upon launch. | `-set-cookies` |
| `-save-html` | `bool` | `false` | Save final page HTML on exit to `output.html`. | `-save-html` |
| `-download` | `bool` | `false` | Enable automatic browser file downloads. | `-download` |

> ⚠️ **Linux-Only Note for `-spoof-tcp`**:
> `-spoof-tcp` modifies low-level OS kernel TCP SYN packet parameters, window sizes, and TTL to bypass passive OS fingerprinting (p0f). This flag requires Linux raw packet socket access (root / sudo privileges).

> 🍪 **Cookie Persistence (`cookies.json`)**:
> Use `-save-cookies` to persist authenticated session cookies to `cookies.json` upon exit, and `-set-cookies` to reload them into the browser on subsequent runs without re-authenticating.

---

## 3. Proxy Setup & Formats

### Supported Formats in `proxies.txt`
```text
# Standard (No Auth): <protocol>://<host>:<port>
http://192.168.1.100:8080
https://proxy.example.com:8443
socks5://192.168.1.100:1080
socks4://192.168.1.100:1080

# Authenticated: <username>:<password>#<protocol>://<host>:<port>
myuser:mypass#http://192.168.1.100:8080
myuser:mypass#socks5://proxy.provider.com:1080
customer123:secret#http://gate.smartproxy.com:7000
```

---

## 4. Macro Automation (.mac) Syntax

RBSM features a purpose-built domain-specific language (DSL) for undetectable, humanized browser automation.

### Complete Macro Commands Reference
- `NAV "<url>"`: Navigate to URL.
- `NAV_BACK` / `NAV_FORWARD` / `RELOAD`: Navigation controls.
- `WAIT <ms>`: Pause execution for fixed milliseconds.
- `WAIT_RANDOM <min_ms> <max_ms>`: Humanized randomized pause.
- `WAIT_ELEMENT "<selector>" [timeout_ms]`: Wait until element appears in DOM.
- `WAIT_VISIBLE "<selector>" [timeout_ms]`: Wait until element is rendered and visible.
- `CLICK "<selector>"`: Move mouse along Bézier curve and click element.
- `SMART_CLICK "<selector_list>"`: Smart selector matching with fallback.
- `DOUBLE_CLICK "<selector>"` / `RIGHT_CLICK "<selector>"`: Mouse clicks.
- `HOVER "<selector>"`: Move cursor over element without clicking.
- `TYPE "<selector>" "<text>"`: Human typing with variable keystroke delays (50–180ms).
- `SMART_INPUT "<selector_list>" "<text>"`: Smart input detection and typing.
- `CLEAR "<selector>"`: Clear input field value.
- `PRESS "<key>"`: Send keyboard keypress (e.g. `Enter`, `Tab`, `Escape`).
- `KEY_DOWN "<key>"` / `KEY_UP "<key>"`: Hold and release modifier keys.
- `SCROLL <x> <y>`: Scroll viewport by delta pixels.
- `SCROLL_TO "<selector>"`: Smooth scroll element into view.
- `SCREENSHOT "<filepath>"`: Save viewport screenshot.
- `EXPORT_HTML "<filepath>"`: Export page DOM HTML.
- `COOKIES`: Export active session cookies.
- `NEW_TAB` / `CLOSE_TAB` / `SWITCH_TAB <index>`: Multi-tab management.
- `EXEC_JS "<javascript_code>"`: Execute JavaScript in page context.
- `IF <condition>` ... `ELSE` ... `END_IF`: Conditional execution.
- `LOOP <count>` ... `END_LOOP`: Bounded loop execution.
- `EXIT`: Terminate macro script execution immediately.

### Dynamic Placeholders
- `{{ random_email }}`: Generates unique valid email (e.g. `alex.dev892@gmail.com`).
- `{{ random_name }}`: Generates realistic human full name.
- `{{ random_password }}`: Generates high-entropy secure password.
- `{{ random_user_agent }}`: Generates valid latest Chrome User-Agent string.
- `{{ timestamp }}`: Current Unix timestamp in seconds.
- `{{ date }}`: Current date formatted as `YYYY-MM-DD`.
- `{{ clipboard }}`: Reads active system clipboard content.

---

## 5. Macro Recipes & Examples

### Recipe 1: Cloudflare Turnstile Bypass
```macro
NAV "https://target-site-with-turnstile.com/login"
WAIT_RANDOM 2000 4000

IF SMART_EXIST "#turnstile-box, iframe[src*='challenges.cloudflare']"
    LOG "Turnstile challenge detected — solving with human physics..."
    WAIT_RANDOM 1500 2500
    SMART_CLICK "#turnstile-box, iframe[src*='challenges.cloudflare']"
    WAIT 4000
END_IF

WAIT_VISIBLE "input[name='email']" 10000
SMART_INPUT "input[name='email']" "{{ random_email }}"
WAIT_RANDOM 500 1200
SMART_INPUT "input[name='password']" "{{ random_password }}"
WAIT_RANDOM 800 1500
SMART_CLICK "button[type='submit']"
WAIT 5000
SCREENSHOT "login_success.png"
```

### Recipe 2: Undetectable Data Scraping with Proxy Rotation
```macro
NAV "https://books.toscrape.com"
WAIT_VISIBLE "article.product_pod" 8000

LOOP 5
    SCROLL 0 400
    WAIT_RANDOM 800 1600
END_LOOP

EXPORT_HTML "scraped_page.html"
SCREENSHOT "scraped_view.png"
```
