Tool for automated collection and analysis of data from Telegram channels and chats with complete content archiving and interaction graph generation.
- Complete user profiles: ID, username, first name, last name, phone (if available)
- Statuses and flags: verification, Telegram Premium, bots, scam/fake accounts
- Activity: online/offline status, last seen timestamp
- Additional information: bio, language, profile photo
- Relationships: mutual contacts, presence in your contacts
- Retrieval of all channel/group members
- Saving membership data (join date, status)
- Integration with global user database
- Automatic extraction of all URLs from messages
- Support for Telegram links (t.me, @username)
- Saving link context (surrounding text)
- Link classification by type (telegram, http, https)
- Build interaction graphs from collected data
- Nodes: users, channels, domains
- Edges: membership, replies, forwards, link mentions
- Export to multiple formats (GraphML, GEXF, JSON, CSV, PNG)
- Filter by date, minimum reply count
- Graph statistics (node/edge types, degrees, bot/premium counts)
- Normalized schema with table relationships
- Extended models for storing all available data
- Automatic updating of existing records
- Support for incremental collection
- Python 3.10+
- All dependencies from
requirements.txt - Telegram API credentials in
.envfile or environment variables
API_ID=your_telegram_api_id
API_HASH=your_telegram_api_hash
# Clone repository
git clone https://github.com/He4vyL0v3/GhostlyGrabber
cd GhostlyGrabber
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt- Create a
.envfile in the project root with your Telegram API credentials - Run the collector:
cd src
python3 main.pyFollow the prompts to specify output folder, channel name, and collection options.
Create proxies.txt in src/ folder with proxy list. Supported formats:
| Format | Example |
|---|---|
| SOCKS5 | socks5://host:port |
| SOCKS5 with auth | socks5://user:pass@host:port |
| SOCKS4 | socks4://host:port |
| HTTP | http://host:port |
| MTProto | mtproto://secret@host:port |
| Telegram native | tg://proxy?server=...&port=443&secret=... |
Example:
socks5://127.0.0.1:1080
mtproto://secret@host:443
tg://proxy?server=s3.sosproxy.space.mtproto.ru&port=443&secret=ee520bd57bf173f2eee56fb9ce7afbb58c64726976652e676f6f676c652e636f6d
After collection, analyze the database with the analyzer:
python3 analyzer.py /path/to/GhostlyGrabber.db [options]Common options:
--with-linksβ include domain nodes from extracted links--start-date,--end-dateβ filter by date (ISO format)--formats graphml png csv-nodesβ export formats--min-replies 3β minimum replies to create an edge
Example:
python3 analyzer.py ~/data/GhostlyGrabber.db --with-links --formats graphml png --start-date 2024-01-01GhostlyGrabber/
βββ src/
β βββ main.py # Main collection script
β βββ analyzer.py # Analysis & graph building
β βββ db.py # Database logic
β βββ models.py # Database models
β βββ dialog.py # User dialogs
β βββ extractors.py # Link extraction from text
β βββ cache.py # API response cache
β βββ proxy.py # Proxy management
β βββ utils.py # Utility functions
βββ requirements.txt # Python dependencies
βββ README.md # Documentation
- users β extended user data
- posts_{channel} β channel posts
- discussions_{channel} β comments/replies
- members_{channel} β channel members
- links_{channel} β links from messages
| Field | Description |
|---|---|
| user_id | Unique Telegram user ID |
| username, first_name, last_name | Basic info |
| phone | Phone number (if available) |
| bot, verified, premium | Account flags |
| scam, fake, deleted, restricted | Warning flags |
| status, was_online | Activity info |
| about, lang_code | Additional info |
| created_at, updated_at | Timestamps |
The program supports incremental collection:
- On subsequent runs, only new messages are downloaded
- Existing records are updated with new information
- Media files are not overwritten if they already exist
- Member collection: requires admin rights in channel/group
- User data: depends on privacy settings
- Phone number: only available with mutual contacts or public settings
- Request frequency limitations
- Possible temporary blocking with too active collection
- User privacy settings β main limiting factor
β Always available:
- User ID (permanent identifier)
- First and last name (if set)
- Username (if public)
- Flags (bot, verification, etc.)
- Phone number (requires mutual contacts)
- Last online time (depends on settings)
- Profile photo (can be downloaded separately)
Collected data can be used for:
- OSINT investigations: user activity analysis
- Content archiving: complete channel preservation
- Link analysis: information dissemination study
- Statistics: member count, post popularity analysis
- Network analysis: interaction graphs for community detection
- Comply with laws: tool usage must comply with your country's legislation
- Respect privacy: do not collect data unnecessarily or without consent
- Don't violate ToS: adhere to Telegram's terms of service
- Use responsibly: only for legal research and archiving
Project uses Black formatter with line length 120.
python format.py # Format src/ directory
python format.py src/ package/ # Format specific paths
python format.py --check # Check without changes
python format.py -v # Verbose output
python format.py --line-length 100 # Custom line lengthpip install blackWe welcome contributions to project development:
- Report bugs via Issues
- Suggest improvements via Pull Requests
- Share ideas for new features
Created with β€οΈ by Nighty3098 for the OSINT and Telegram research community





