|
| 1 | +# Challenge61 Multi-Instance Setup Guide |
| 2 | + |
| 3 | +This guide explains how to configure and run Challenge61, which demonstrates how hardcoded Telegram bot credentials can be discovered and exploited. The bot token is double-encoded in base64 to make it slightly more challenging but still discoverable through code inspection. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This challenge supports running on multiple app instances (e.g., Arcane and WrongSecrets Heroku apps) using either polling (getUpdates) or webhooks. |
| 8 | + |
| 9 | +## Option 1: Polling with getUpdates (Default - Works Out of Box) |
| 10 | + |
| 11 | +The code uses update offsets to minimize conflicts between multiple app instances: |
| 12 | +- No configuration needed |
| 13 | +- Uses update offsets to minimize conflicts between instances |
| 14 | +- Multiple instances can run simultaneously |
| 15 | +- Less efficient but simpler setup |
| 16 | +- `timeout=0` - No long polling, quick responses |
| 17 | +- `limit=1` - Process one update at a time |
| 18 | +- Offset acknowledgment - Marks updates as processed |
| 19 | + |
| 20 | +**Status**: ✅ Code updated and tested |
| 21 | + |
| 22 | +## Option 2: Webhook Solution (Recommended for Production) |
| 23 | + |
| 24 | +### Step 1: Configure Each Heroku App |
| 25 | + |
| 26 | +For **WrongSecrets Heroku app**: |
| 27 | +```bash |
| 28 | +heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a wrongsecrets-app |
| 29 | +heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a wrongsecrets-app |
| 30 | +``` |
| 31 | + |
| 32 | +For **Arcane Heroku app**: |
| 33 | +```bash |
| 34 | +heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a arcane-app |
| 35 | +heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a arcane-app |
| 36 | +``` |
| 37 | + |
| 38 | +### Step 2: Choose ONE App for the Webhook |
| 39 | + |
| 40 | +You can only set ONE webhook URL per bot. Choose either WrongSecrets or Arcane: |
| 41 | + |
| 42 | +**Option A: Use WrongSecrets app** |
| 43 | +```bash |
| 44 | +# Get your webhook token |
| 45 | +WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a wrongsecrets-app) |
| 46 | + |
| 47 | +# Set the webhook |
| 48 | +curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/setWebhook?url=https://your-wrongsecrets-app.herokuapp.com/telegram/webhook/challenge61&secret_token=$WEBHOOK_TOKEN" |
| 49 | +``` |
| 50 | + |
| 51 | +**Option B: Use Arcane app** |
| 52 | +```bash |
| 53 | +# Get your webhook token |
| 54 | +WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a arcane-app) |
| 55 | + |
| 56 | +# Set the webhook |
| 57 | +curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/setWebhook?url=https://your-arcane-app.herokuapp.com/telegram/webhook/challenge61&secret_token=$WEBHOOK_TOKEN" |
| 58 | +``` |
| 59 | + |
| 60 | +### Step 3: Verify Webhook |
| 61 | + |
| 62 | +```bash |
| 63 | +curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo" |
| 64 | +``` |
| 65 | + |
| 66 | +### Step 4: Test |
| 67 | + |
| 68 | +1. Open @WrongsecretsBot in Telegram |
| 69 | +2. Send `/start` |
| 70 | +3. Bot should respond: "Welcome! Your secret is: telegram_secret_found_in_channel" |
| 71 | + |
| 72 | +## Alternative: Use Both Apps with getUpdates (Current Setup) |
| 73 | + |
| 74 | +If you want both apps to be able to respond (not recommended but possible): |
| 75 | + |
| 76 | +1. **Keep webhook disabled** (default) |
| 77 | +2. **Accept that responses may be inconsistent** - whichever app polls first will respond |
| 78 | +3. **The improved getUpdates code** minimizes conflicts with offset handling |
| 79 | + |
| 80 | +## Troubleshooting |
| 81 | + |
| 82 | +### Check if webhook is active |
| 83 | +```bash |
| 84 | +curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo" |
| 85 | +``` |
| 86 | + |
| 87 | +### Remove webhook (to go back to getUpdates) |
| 88 | +```bash |
| 89 | +curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/deleteWebhook" |
| 90 | +``` |
| 91 | + |
| 92 | +### View Heroku logs |
| 93 | +```bash |
| 94 | +heroku logs --tail -a wrongsecrets-app | grep Challenge61 |
| 95 | +heroku logs --tail -a arcane-app | grep Challenge61 |
| 96 | +``` |
| 97 | + |
| 98 | +## Recommendation |
| 99 | + |
| 100 | +For **production with multiple apps**: Use webhook on ONE primary app (WrongSecrets). |
| 101 | + |
| 102 | +For **development/testing**: The current getUpdates approach with offsets works fine. |
| 103 | + |
| 104 | +## BotFather Configuration (Optional but Recommended) |
| 105 | + |
| 106 | +### 1. Configure Commands |
| 107 | + |
| 108 | +- Send `/setcommands` to @BotFather |
| 109 | +- Select your bot |
| 110 | +- Add: `start - Get the secret message` |
| 111 | + |
| 112 | +### 2. Set Description |
| 113 | + |
| 114 | +- Send `/setdescription` to @BotFather |
| 115 | +- Select your bot |
| 116 | +- Add: "OWASP WrongSecrets Challenge 61 - Demonstrates hardcoded bot credentials. Send /start to receive the secret!" |
| 117 | + |
| 118 | +### 3. Set About Text |
| 119 | + |
| 120 | +- Send `/setabouttext` to @BotFather |
| 121 | +- Add: "Educational security challenge from OWASP WrongSecrets project" |
| 122 | + |
| 123 | +## Testing the Bot |
| 124 | + |
| 125 | +1. Find the bot: Search for @WrongsecretsBot in Telegram (or your bot username) |
| 126 | +2. Send: `/start` |
| 127 | +3. Receive: "Welcome! Your secret is: telegram_secret_found_in_channel" |
| 128 | + |
| 129 | +## Creating a New Bot |
| 130 | + |
| 131 | +If you need to create your own bot for testing: |
| 132 | + |
| 133 | +1. Message @BotFather in Telegram |
| 134 | +2. Send `/newbot` |
| 135 | +3. Follow prompts to choose name and username |
| 136 | +4. BotFather will provide a token like: `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz` |
| 137 | +5. Double-encode the token for use in this challenge: |
| 138 | + ```bash |
| 139 | + echo -n "YOUR_TOKEN" | base64 | base64 |
| 140 | + ``` |
| 141 | +6. Replace the `encodedToken` value in the `getBotToken()` method in Challenge61.java |
0 commit comments