
Python OSINT Toolkit for Telegram
A Hackers-Arise walkthrough for building a custom Telegram OSINT toolkit in Python using Telethon's MTProto API instead of the limited Bot API, enabling full message-history access, group member enumeration (up to 200/request), and message/engagement metadata collection. The toolkit also extracts EXIF/GPS metadata from downloaded media (via Pillow/piexif) to geolocate targets, persists results in SQLite via aiosqlite, and exposes everything through a Click CLI with modules for profile, members, messages, and media lookups.
What it is
Part one of a Hackers-Arise tutorial series on building a Telegram OSINT toolkit in Python with Telethon. This installment stops at establishing the authenticated client — it covers Telegram's data model, the API choice, environment setup, and the first Telethon connection. Message/member/profile scraping logic is deferred to later parts.
How it works
Telethon speaks MTProto (Telegram's native client protocol), so the script authenticates as a real user account rather than a bot. This is what lifts the two hard bot limits the page names: bots are blind to message history from before they joined a group, and are capped at 20MB downloads. A user session gets full history and files up to 2GB. Authentication produces a .session file that the page likens to a stored credential — treat it as sensitive.
Preconditions / Affected
- Targets are limited to public channels/groups — discoverable by username, link, or in-app search. One-on-one chats, secret chats, and private groups require an invite or admin approval and stay out of reach.
- Requires
api_idandapi_hashfrom Telegram's API tools page, plus your phone number for the login-code handshake.
What to do
Setup on Kali (verbatim):
kali> mkdir Scripts/tg-osint
kali> python3 -m venv venv
kali> source venv/bin/activate
kali> mkdir -p modules output logs
kali> touch main.py config.py utils.py client.py .env .gitignore
kali> pip install telethon python-dotenv rich aiosqlite pillow piexif clickNote the fuller dependency set beyond what the catalog summary lists: python-dotenv, aiosqlite, and click are also installed. Then lock the environment:
pip freeze > requirements.txtCredentials go in .env (keep it in .gitignore):
API_ID=12345678
API_HASH=abcdef1234567890abcdef1234567890
PHONE=+1234567890
SESSION_NAME=hackers-arise-osint-sessionconfig.py loads these; a thin client.py module holds a start_client() that runs the async auth handshake and consumes the login code sent to your device.
Caveats
- Account ban risk is the operational constraint, not a footnote. Telegram enforces anti-spam rate limits that scale with account age and trust; aggressive or high-frequency requests get the account flagged or banned. Throttle before scaling collection.
- This is an incomplete tutorial — it ends mid-sentence at the
.sessionfile, before any actual OSINT collection code. Acting on it now buys you a configured, authenticated client and nothing more.
Technologies named here
- Python
- Telegram
- Kali Linux
- SQLite
- Click
Related in OSINT
i8void/cybersleuth
Insights into Suspected DPRK Workers
