Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small python script to extract (forward) messages from a bot using telegram as phishing backend / https://blog.rico-j.de/telegram-phishing-backend
# Script to forward the content of a chat between a Telegram Bot and a user to another user
# Make sure to insert your user_id into `receiver_id` and send /start to the bot on Telegram beforehand
import requests
import time
# from_chat_id and token are written in the javascript on the phishing site!
# the from_chat_id is the initial receiver of the phishing results
from_chat_id = ""
token = ""
# Enter your user_id as the receiver ID
receiver_id = ""
url = f"https://api.telegram.org/bot{token}/forwardMessage?chat_id={receiver_id}&from_chat_id={from_chat_id}&message_id="
error_counter = 0
message_counter = 0
while True:
# Query Telegram to forward the message with the given ID to the receiver
resp = requests.get(url + str(message_counter))
if resp.status_code != 200:
# If the Telegram API responds with a status code != 200, the message doesn't exist
# That could mean that it was deleted, or it's the last message in that chat!
# If there are 10 consecutive errors we stop the data collection!
print(f"Issue with request at index {message_counter}! Stopping")
error_counter += 1
if error_counter >= 10:
print("10 consecutive errors! Exiting!")
exit()
else:
error_counter = 0
# Telegram allows for 1 msg/s per chat - so we need this sleep in order to not get http 429 errors
time.sleep(1)
message_counter += 1
@d-Rickyy-b

This comment has been minimized.

Copy link
Owner Author

@d-Rickyy-b d-Rickyy-b commented Jul 4, 2021

This code is licensed MIT!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment