Get the FREE Ultimate OpenClaw Setup Guide →
A

Tor Browser Automation

Verified

@Admin4Giter

npx machina-cli add skill @Admin4Giter/tor-browser --openclaw
Files (1)
SKILL.md
4.9 KB

Tor Browser Automation

Headless browser automation with Tor SOCKS5 proxy support for accessing .onion sites and anonymous web browsing.

Prerequisites

  • Tor service running with SOCKS5 proxy on port 9050
  • Python 3.8+
  • Playwright with Chromium browser

Quick setup:

# Install Tor
sudo apt install tor && sudo systemctl start tor

# Install Python dependencies
pip install playwright
playwright install chromium

Quick Start

# Check Tor connection
tor-browser check-tor

# Navigate to a .onion site
tor-browser open http://3g2upl4pq6kufc4m.onion

# Get page snapshot
tor-browser snapshot -i

# Click an element
tor-browser click @e1

# Take screenshot
tor-browser screenshot -o output.png --full

Commands

Navigation

# Open URL via Tor
tor-browser open <url> [--proxy socks5://host:port]

# Check Tor connection status
tor-browser check-tor

Page Analysis

# Get full page snapshot
tor-browser snapshot

# Get interactive elements only (forms, buttons, links)
tor-browser snapshot -i

# Extract all links
tor-browser links

# Get page text
tor-browser gettext
tor-browser gettext --ref @e5

Interaction

# Click element by ref
tor-browser click @e1

# Fill input field
tor-browser fill @e2 "text to enter"

# Wait for page load
tor-browser wait 2000

Screenshots

# Take viewport screenshot
tor-browser screenshot

# Save to file
tor-browser screenshot -o capture.png

# Full page screenshot
tor-browser screenshot --full -o page.png

Python API

from scripts.tor_browser import TorBrowser, Config
import asyncio

async def main():
    # Configure browser
    config = Config(
        tor_proxy="socks5://127.0.0.1:9050",
        headless=True,
        timeout=30000
    )
    
    # Initialize and start
    browser = TorBrowser(config)
    await browser.start()
    
    # Navigate
    result = await browser.navigate("http://3g2upl4pq6kufc4m.onion")
    print(f"Loaded: {result['title']}")
    
    # Get snapshot
    snapshot = await browser.get_snapshot(interactive_only=True)
    for elem in snapshot['elements']:
        print(f"{elem['ref']}: {elem['tag']} - {elem['text'][:30]}")
    
    # Interact
    await browser.fill("@e2", "search query")
    await browser.click("@e3")
    
    # Extract data
    links = await browser.extract_links()
    for link in links:
        print(f"{link['text']}: {link['href']}")
    
    # Cleanup
    await browser.close()

asyncio.run(main())

Configuration Options

OptionDefaultDescription
tor_proxysocks5://127.0.0.1:9050Tor SOCKS5 proxy URL
headlesstrueRun without GUI
timeout30000Page load timeout (ms)
user_agentTor Browser UABrowser user agent
viewport1920x1080Browser viewport size

Security & Legal

Intended Use:

  • Security research and threat intelligence
  • Anonymous web scraping of public dark web resources
  • Testing .onion site accessibility
  • Privacy-preserving web automation

Important:

  • Only use for legal purposes
  • Respect site Terms of Service
  • Do not use for unauthorized access
  • Comply with local laws regarding dark web access
  • Be aware that some activities may be monitored

Troubleshooting

Tor Connection Issues

# Check Tor is running
sudo systemctl status tor

# Test SOCKS5 proxy
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip

# View Tor logs
sudo journalctl -u tor -f

Common Errors

Connection refused:

  • Ensure Tor service is started
  • Check firewall rules
  • Verify proxy URL

Timeout:

  • .onion sites may be slow; increase timeout
  • Try different Tor circuits: restart Tor service

CAPTCHA blocking:

  • Use --headed mode to manually solve
  • Some sites block automation

Docker Setup

FROM python:3.11-slim

RUN apt-get update && apt-get install -y tor
RUN pip install playwright && playwright install chromium

COPY . /app
WORKDIR /app

CMD ["tor-browser", "check-tor"]

References

License

MIT - See original licenses for Playwright and Tor Project components.

Source

git clone https://clawhub.ai/Admin4Giter/tor-browserView on GitHub

Overview

Tor Browser Automation enables headless browser control through a Tor SOCKS5 proxy to access .onion sites and perform anonymous browsing. It supports navigation, element interaction, screenshots, and data extraction for security research, dark web scraping, and privacy-focused automation.

How This Skill Works

The skill uses Playwright with Chromium to route traffic through the Tor SOCKS5 proxy (default socks5://127.0.0.1:9050). A Python API exposes a Config object and a TorBrowser class to launch browsers, navigate onion URLs, capture snapshots, interact with elements, and extract data, assuming a Tor service is running locally.

When to Use It

  • Navigating .onion sites anonymously for research or testing
  • Scraping data from Tor hidden services while preserving identity
  • Security research on dark web forums or resources
  • Accessibility testing of onion sites
  • Privacy-preserving automated workflows for sensitive sites

Quick Start

  1. Step 1: Install and start Tor, then install Python dependencies (pip install playwright; playwright install chromium)
  2. Step 2: Open an onion URL with Tor Browser (tor-browser open http://example.onion)
  3. Step 3: Capture a snapshot or take a screenshot (tor-browser snapshot -i or tor-browser screenshot -o output.png --full)

Best Practices

  • Ensure Tor is running with a SOCKS5 proxy on port 9050 before automation
  • Install Python >= 3.8, Playwright, and the Chromium browser as shown in the quick setup
  • Configure tor_proxy in Config (default socks5://127.0.0.1:9050) and consider headless mode for automation
  • Respect legal requirements and site terms; avoid unauthorized access or activities
  • Validate onion URLs, handle delays/timeouts, and monitor automation for unusual activity

Example Use Cases

  • Check Tor connection with tor-browser check-tor
  • Open a .onion site via Tor using tor-browser open http://<onion-url>
  • Capture a page snapshot with tor-browser snapshot -i
  • Extract all links using tor-browser links and iterate over onion pages
  • Use the Python API to navigate to an onion page and print the loaded title

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers