bercocok-tanam

๐ŸŒฑ CLI automation tool for Kiro & Cloudflare token harvesting with parallel workers and detailed reporting

0
0
0
public
Forked

๐ŸŒฑ bercocok-tanam

License: ISC
Node.js Version
GitHub Stars
GitHub Forks
GitHub Issues
Last Commit
Code Style: ESLint
Sponsor on Patreon

Automated CLI tool for harvesting Kiro refresh tokens, Cloudflare Workers AI API tokens, and Codebuddy AI OAuth tokens using Puppeteer. Features multi-worker parallel processing, proxy pool management, detailed per-account reporting, and comprehensive error tracking.

All-in-One Automation Screenshot

โœจ Features

  • ๐Ÿ”‘ Kiro Automation - Automated Kiro OAuth refresh token extraction
  • โ˜๏ธ Cloudflare Automation - Cloudflare Workers AI API token generation
  • ๐Ÿค– Codebuddy Automation [BETA] - Codebuddy AI OAuth token extraction (โš ๏ธ requires residential proxies)
  • ๐Ÿš€ All-in-One Mode - Run Kiro, Cloudflare, and Codebuddy automations in parallel
  • ๐ŸŒ Proxy Pool System - Shared proxy pool with automatic worker assignment and locking
  • ๐Ÿ‘ท Multi-Worker Parallel Processing - Configure multiple browser instances for faster processing
  • ๐Ÿ“Š Detailed Reporting - Per-worker and per-account statistics with timing breakdown
  • ๐ŸŽฏ Smart Account Queue Management - Automatic account locking prevents duplicate processing
  • โŒ Comprehensive Error Tracking - All failed accounts logged with timestamps and automation type
  • ๐Ÿ”„ Account Change Detection - Confirmation prompt when account count changes before automation
  • ๐Ÿ”Œ Flexible Proxy Support - Per-account proxies or shared proxy pool for all automations
  • โš™๏ธ Interactive Settings - Easy configuration management through CLI interface

๐Ÿ“‹ Requirements

  • Node.js 16+
  • Google Chrome or Chromium browser
  • Valid Google accounts (email|password format)
  • 9Router - Backend service for token management
    • This tool harvests tokens and imports them to 9Router
    • Must be running and accessible at configured ROUTER_URL
    • Default: http://127.0.0.1:20128/

๐Ÿš€ Installation

# Clone the repository
git clone https://github.com/fzrilsh/bercocok-tanam
cd bercocok-tanam

# Install dependencies
npm install

# Create accounts file
echo "email@example.com|password123" > accounts.txt

# (Optional) Configure settings
cp .env.example .env
# Edit .env with your settings

โš™๏ธ Configuration

Create a .env file in the project root:

ROUTER_URL=http://your-router-url:20128/
PW_HEADLESS=1
BROWSER_COUNT=4
BROWSER_SLOW_MO=2
CHROME_EXECUTABLE_PATH=/path/to/chrome
ACCOUNT_FILE=accounts.txt
RESULT_FILE={provider}_keys.txt
ERROR_ACCOUNT_FILE=errorAccounts.txt
PROXY_POOL_FILE=proxy_keys.txt
DELAY_BEFORE_NEXT_CLICK_MS=1000
DELAY_BETWEEN_ACCOUNTS_MS=3000
DELAY_BEFORE_BROWSER_CLOSE_MS=3000
DELAY_BEFORE_READING_COOKIES_MS=5000
TIMEOUT_NAVIGATION_MS=60000
TIMEOUT_DEFAULT_MS=15000
TIMEOUT_SHORT_MS=10000
Variable Description Default
ROUTER_URL 9Router endpoint for token import http://127.0.0.1:20128/
PW_HEADLESS 1 = headless, 0 = visible browser 1
BROWSER_COUNT Number of parallel browser instances 1
BROWSER_SLOW_MO Delay between browser actions (ms) 2
CHROME_EXECUTABLE_PATH Path to Chrome/Chromium executable Auto-detect
ACCOUNT_FILE Path to accounts file accounts.txt
RESULT_FILE The system automatically replaces {provider} with the automation name (kiro, cloudflare, or proxy) {provider}_keys.txt
ERROR_ACCOUNT_FILE Log file for failed accounts errorAccounts.txt
PROXY_POOL_FILE Shared proxy pool file (optional) - workers auto-pick available proxies proxy_keys.txt
DELAY_BEFORE_NEXT_CLICK_MS Delay before next click action 1000
DELAY_BETWEEN_ACCOUNTS_MS Delay between processing accounts 3000
DELAY_BEFORE_BROWSER_CLOSE_MS Delay before closing browser 3000
DELAY_BEFORE_READING_COOKIES_MS Delay before reading cookies 5000
TIMEOUT_NAVIGATION_MS Page navigation timeout 60000
TIMEOUT_DEFAULT_MS Default element wait timeout 15000
TIMEOUT_SHORT_MS Short element wait timeout 10000

๐Ÿ“ Account File Format

Create accounts.txt with one account per line:

user1@gmail.com|password123
user2@gmail.com|password456
user3@gmail.com|password789|http://proxy-server:8080
user4@gmail.com|password321|http://user:pass@proxy:8080

Format Rules:

  • One account per line
  • Fields separated by | (pipe)
  • Lines starting with # are comments
  • Proxy is optional (supported by all automations)

Proxy Pool (Optional)

Instead of specifying proxies per account, you can use a shared proxy pool. Create a proxy pool file (e.g., proxy_keys.txt):

191.96.254.138:6185:username:password
45.38.107.97:6014:username:password
198.105.121.200:6462:username:password

Format: ip:port:username:password (one proxy per line)

  • System automatically converts to http://user:pass@host:port format

How it works:

  • Workers automatically pick available proxies from the pool
  • Proxies are locked while in use (other workers wait)
  • 30-minute cooldown per proxy IP after use (prevents Google CAPTCHA from rapid reuse)
  • Proxy is released after browser closes
  • Priority: Account proxy > Pool proxy > No proxy

Important:

  • โš ๏ธ Codebuddy Automation: Requires residential proxies only. Datacenter proxies will result in โ€œAccount Access Restrictedโ€ errors due to Tencent Cloudโ€™s security policies. If you donโ€™t have residential proxies, Codebuddy automation will likely fail.
  • Proxy pool is used for Kiro, Cloudflare, and Codebuddy automations.

Enable by setting PROXY_POOL_FILE=proxy_keys.txt in .env

๐ŸŽฎ Usage

# Start the CLI
npm start

# Choose from menu:
# 1. ๐Ÿ”‘ Kiro Automation
# 2. โ˜๏ธ  Cloudflare Automation
# 3. ๐Ÿค– Codebuddy Automation [BETA] (โš ๏ธ Requires Residential Proxy)
# 4. ๐Ÿš€ All-in-One Automation
# 5. โš™๏ธ  Settings
# 6. ๐Ÿšช Exit

Account Change Confirmation

If you modify accounts.txt while at the menu, the system will detect changes when you start an automation:

? Account file changed: 5 โ†’ 3 accounts. Continue with automation? (Y/n)
  • Select Y to proceed with the new account list
  • Select n to return to menu and review changes

๐Ÿ“Š Reports

After each automation run, youโ€™ll see a detailed report:

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
  ๐ŸŒฑ KIRO AUTOMATION REPORT
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“Š OVERALL SUMMARY
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Total Accounts       : 10
  โœ… Success           : 8 accounts
  โŒ Failed            : 2 accounts
  Success Rate         : 80.0%
  Total Duration       : 5m 23s
  Average per Account  : 32.3s

๐Ÿ‘ท WORKER DETAILS
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  Kiro W1
    Processed: 5 accounts | โœ… 4 | โŒ 1
    Average: 31.2s/account
    Accounts:
      โœ… user1@gmail.com 28.5s
      โœ… user2@gmail.com 35.1s
      โŒ user3@gmail.com 29.8s
      โœ… user4@gmail.com 30.2s
      โœ… user5@gmail.com 32.4s

โŒ FAILED ACCOUNTS
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โ€ข user3@gmail.com
    Error: RefreshToken cookie not found

  ๐Ÿ’ก Check errorAccounts.txt for complete details

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“ Output Files

  • {provider}_keys.txt - Token output files, generated per automation:
    • kiro_keys.txt โ€” Kiro refresh tokens (format: email|refreshToken)
    • cloudflare_keys.txt โ€” Cloudflare Workers AI API tokens
    • codebuddy_keys.txt โ€” Codebuddy OAuth tokens (auto-imported to 9Router, no local save)
  • errorAccounts.txt - Failed accounts with error messages, timestamps, and automation type
  • logs/ - Detailed execution logs with timestamps

Error Accounts Format

email|password | Kiro | 2026-07-10T14:23:45.123Z | RefreshToken cookie not found
email|password | Cloudflare | 2026-07-10T14:25:12.456Z | Account ID not found

๐Ÿ—๏ธ Project Structure

bercocok-tanam/
โ”œโ”€โ”€ index.js              # Main entry point with menu system
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ browser.js        # Browser launching with stealth mode
โ”‚   โ”œโ”€โ”€ cloudflare.js     # Cloudflare token harvesting logic
โ”‚   โ”œโ”€โ”€ codebuddy.js      # Codebuddy OAuth token harvesting logic
โ”‚   โ”œโ”€โ”€ config.js         # Configuration management
โ”‚   โ”œโ”€โ”€ google-login.js   # Google authentication helpers
โ”‚   โ”œโ”€โ”€ kiro.js           # Kiro token harvesting logic
โ”‚   โ”œโ”€โ”€ progress.js       # Progress bar and status display
โ”‚   โ”œโ”€โ”€ reporter.js       # Report generation and formatting
โ”‚   โ”œโ”€โ”€ settings.js       # Interactive settings menu
โ”‚   โ””โ”€โ”€ utils.js          # Utility functions and helpers
โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ screenshot.png    # CLI screenshot
โ”œโ”€โ”€ accounts.txt          # Account list (user-created)
โ”œโ”€โ”€ kiro_keys.txt         # Kiro tokens output (auto-generated)
โ”œโ”€โ”€ cloudflare_keys.txt   # Cloudflare tokens output (auto-generated)
โ”œโ”€โ”€ codebuddy_keys.txt    # Codebuddy tokens output (not saved, auto-imported)
โ”œโ”€โ”€ errorAccounts.txt     # Failed accounts log
โ”œโ”€โ”€ logs/                 # Execution logs
โ”œโ”€โ”€ .env                  # Configuration (user-created)
โ”œโ”€โ”€ eslint.config.js      # ESLint configuration
โ””โ”€โ”€ package.json          # Dependencies and scripts

๐Ÿ› ๏ธ Tech Stack

  • Node.js - Runtime environment
  • Puppeteer - Browser automation
  • Puppeteer-Stealth - Anti-detection plugin
  • Inquirer - Interactive CLI prompts
  • CLI-Progress - Progress bars
  • ANSI-Colors - Terminal colors
  • 9Router - Token management backend service

๐Ÿ”ง Troubleshooting

โ€œNo accounts foundโ€ error

  • Check accounts.txt format: email|password or email|password|proxy
  • Ensure no extra spaces around the | separator
  • Remove empty lines or add # for comments
  • Google may require additional verification
  • Check if account credentials are correct
  • Wait a few minutes and retry (rate limiting)

Browser wonโ€™t launch

  • Verify Chrome path in settings or .env
  • Check Chrome is installed and executable
  • Try default Chrome path (remove custom setting)

โ€œspawn /Applications/Google Chrome.app EACCEโ€ (Mac)

Permission error when launching Chrome. Common causes:

  • Wrong path: /Applications/Google Chrome.app is the app bundle, not the executable
  • Solution: Use correct executable path:
    CHROME_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
    
  • If using Chromium: /Applications/Chromium.app/Contents/MacOS/Chromium
  • If using Brave: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
  • Alternative: Leave CHROME_EXECUTABLE_PATH empty โ€” Puppeteer auto-detects bundled Chromium
  • Check permissions: Ensure Chrome has execute permission:
    ls -l "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
    # Should show: -rwxr-xr-x (x = executable bit)
    
  • Security settings: If downloaded manually, remove quarantine attribute:
    xattr -d com.apple.quarantine "/Applications/Google Chrome.app"
    

9Router connection errors

  • Verify 9Router is running and accessible
  • Check ROUTER_URL in .env or settings
  • Test connection: curl http://127.0.0.1:20128/
  • Ensure firewall allows connections to router port
  • Check router logs for import errors
  • Disable Require Login in 9Router (Settings โ†’ Security) โ€” the import API will be rejected if authentication is enabled

Proxy errors

  • Verify proxy format: http://host:port or http://user:pass@host:port
  • Test proxy connection separately
  • Try without proxy first to isolate issue

CAPTCHA challenges and security restrictions

  • Kiro/Cloudflare: Proxy pool includes 30-minute cooldown per IP to prevent CAPTCHA
  • Codebuddy: Requires residential proxies only. Datacenter proxies will trigger โ€œAccount Access Restrictedโ€ errors from Tencent Cloudโ€™s security system. This is not a CAPTCHA but an account-level restriction that cannot be bypassed without residential IPs.
  • Reduce BROWSER_COUNT (fewer parallel instances)
  • Increase delays between actions
  • Ensure browser profile is clean (no previous bot flags)
  • Free datacenter proxies are more likely to trigger CAPTCHAs than residential proxies

๐Ÿ“„ License

ISC

๐Ÿ‘ค Author

Fazril Syaveral Hillaby

๐Ÿ™ Acknowledgements

Special thanks to the open-source community for making automation tools accessible.

๐Ÿค Contributing

Contributions welcome! Please ensure:

  • Code follows ESLint configuration (4-space indent)
  • All user-facing text is in English
  • Comprehensive error handling
  • Test changes with multiple accounts before submitting PR

๐Ÿ’ฌ Support & Community

For security vulnerabilities, please email directly instead of opening a public issue.

๐Ÿ“œ Changelog

See commit history for detailed changes.


Built with โค๏ธ for automation efficiency

v0.3.3[beta]