This is a Python-based tool designed to help recover Telegram sessions by automating the process of receiving and handling One-Time Passwords (OTPs). It attempts to log into existing .session files, displays the account's phone number, captures the OTP sent to that number, and organizes sessions into 'recovered' or 'dead' folders based on the outcome.
- Session Processing: Iterates through all
.sessionfiles located in thesessionsdirectory. - Phone Number Display: Automatically retrieves and displays the phone number associated with the session, so you know exactly where to send the login code.
- OTP Handling: Automatically listens for and extracts the 5 or 6-digit login code from Telegram's official service account (ID 777000).
- 2FA Check: Can optionally skip sessions that have Two-Factor Authentication (2FA) enabled (configurable in
config.json). - Session Organization: Automatically moves sessions to
recovered_sessionsupon success ordead_sessionsupon failure (e.g., 2FA enabled, banned account, invalid session). - Phone Number Logging: Saves the phone numbers of all successfully recovered accounts to
recovered_numbers.txt. - Interactive Controls: Allows you to manually retry (R), mark as failed (F), or proceed to the next session (Enter) after an OTP is received.
- Python 3.8+
- Telegram API credentials (from my.telegram.org)
Install dependencies:
pip install -r requirements.txtrequirements.txt:
pyrogram==2.0.106
tgcrypto
colorama.
├── main.py
├── config.json
├── sessions/
├── recovered_sessions/
├── dead_sessions/
└── recovered_numbers.txt
-
Get API Credentials:
- Log in to your Telegram account at https://my.telegram.org.
- Go to "API development tools" and create a new application.
- You will receive an
api_idandapi_hash.
-
Configure the Bot:
- Open the
config.jsonfile. - Paste your
api_idandapi_hashinto the respective fields. - Set
SKIP_2FA_enabledtotrueif you want to automatically skip accounts that have 2FA enabled. Otherwise, leave it asfalse.
Example
config.json:{ "api_id": 1234567, "api_hash": "0123456789abcdef0123456789abcdef", "SKIP_2FA_enabled": false } - Open the
-
Add Session Files:
- Place all your Telegram
.sessionfiles (e.g.,my_account.session) into thesessions/directory. The script creates this directory if it doesn't exist.
- Place all your Telegram
-
Run the Script:
- Execute the main script from your terminal:
python main.py
-
The bot will:
- The bot will start processing each session file one by one.
- It will log in and display the phone number for the account (e.g.,
📱 Phone Number: +1234567890). - The script will then pause and ask you to send an OTP to that number (e.g., by logging in on another device) and press Enter to continue.
- It will log in and display the phone number for the account (e.g.,
- Handle the OTP:
- Once you've sent the code, the bot will detect the incoming OTP message from Telegram (ID 777000) and display the code.
- You will then be prompted to:
- Press Enter to confirm recovery (saves the number, moves the session) and move to the next session.
- Type
rand press Enter to retry waiting for an OTP for the same session. - Type
fand press Enter to mark the session as failed and move it todead_sessions.
- ✅
recovered_sessions/→ Sessions successfully verified - ❌
dead_sessions/→ Banned, invalid, or 2FA-locked sessions - 📝
recovered_numbers.txt→ Log of recovered phone numbers
- This script requires valid Telegram sessions created using Pyrogram or similar tools.
- The OTP capture depends on receiving messages from @Telegram (777000).
- If
SKIP_2FA_enabledistrue, accounts with 2FA will be auto-skipped. - Run the script responsibly — repeated login attempts may trigger Telegram’s floodwait limits.
📱 Starting Telegram OTP Recovery Bot...
📁 Created directory: sessions
🟢 Found 5 session files.
Press Enter to start the recovery bot...
🔄 Processing session: user1.session
📱 Phone Number: +8801XXXXXXX
⏳ Waiting for OTP message...
🔐 OTP Code: 123456
✅ Session recovered!
📂 Moved user1.session to recovered_sessions
📝 Saved phone number to recovered_numbers.txt
This project is licensed under the MIT License. See the LICENSE file for details. This project is licensed under the MIT License. Use at your own risk. Not affiliated with Telegram.
- Nabil – GitHub: xNabil
Love the bot? Wanna fuel more WAGMI vibes? Drop some crypto love to keep the charts lit! 🙌
- SUI:
0x8ffde56ce74ddd5fe0095edbabb054a63f33c807fa4f6d5dc982e30133c239e8 - USDT (TRC20):
TG8JGN59e8iqF3XzcD26WPL8Zd1R5So7hm - BNB (BEP20):
0xe6bf8386077c04a9cc05aca44ee0fc2fe553eff1 - Binance UID:
921100473
Every bit helps me grind harder and keep this bot stacking bags! 😎