CoolFace
Apppublic

Mr-Risov/Telegram_reporting_system

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
main.py165 linesDownload Raw Back to root
1import os2import requests3from time import sleep4from configparser import ConfigParser5from os import system, name6from threading import Thread, active_count7import csv8import phonenumbers9from phonenumbers import PhoneNumber, PhoneNumberFormat10from random_user_agent.user_agent import UserAgent11from random_user_agent.params import SoftwareName, OperatingSystem12from bs4 import BeautifulSoup13import random14from emailtools import generate15 16software_names = [SoftwareName.CHROME.value, SoftwareName.FIREFOX.value, SoftwareName.EDGE.value, SoftwareName.OPERA.value]17operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value, OperatingSystem.MAC.value]18 19user_agent_rotator = UserAgent(software_names=software_names, operating_systems=operating_systems, limit=1200)20 21THREADS = 60022PROXIES_TYPES = ('http', 'socks4', 'socks5')23 24errors = open('errors.txt', 'a+')25 26time_out = 1527success_count = 028error_count = 029username = ""30 31def generate_random_phone_number():32    while True:33        country_code = "+{}".format(random.randint(1, 999))34        national_number = str(random.randint(1000000000, 9999999999))35        phone_number_str = country_code + national_number36        try:37            phone_number = phonenumbers.parse(phone_number_str)38            if phonenumbers.is_valid_number(phone_number):39                return phonenumbers.format_number(phone_number, PhoneNumberFormat.E164)40        except phonenumbers.phonenumberutil.NumberParseException:41            continue42 43def get_random_line(filename, username):44    with open(filename, 'r') as file:45        lines = file.readlines()46        line = random.choice(lines).strip()47        return line.replace('{username}', username)48 49def control(proxy, proxy_type, username):50    51    global success_count52    global error_count53    54    USER_AGENT = user_agent_rotator.get_random_user_agent()55    url = 'https://telegram.org/support'56    try:57        # Step 1: Send initial request and store cookies58        response = requests.get(url, proxies={'http': f'{proxy_type}://{proxy}', 'https': f'{proxy_type}://{proxy}'}, timeout=time_out)59    except AttributeError:60        error_count += 161        pass62    except Exception as e:63        error_count += 164        return errors.write(f'{e}\n')65        66    cookies = response.cookies67 68    # Step 2: Parse the HTML for the form69    soup = BeautifulSoup(response.text, 'html.parser')70    form = soup.find('form', action="/support")71 72    # Check if form is found73    if not form:74        print("Form not found on the page.")75        exit()76 77    # Step 3: Fill the form with data78    message_input = form.find('textarea', id='support_problem')79    email_input = form.find('input', id='support_email')80    phone_input = form.find('input', id='support_phone')81 82    # Fill the form with randomly selected data83    message = get_random_line('message.txt', username)84    email = generate('gmail')85    phone = generate_random_phone_number()86 87    if message_input:88        message_input['value'] = message89    if email_input:90        email_input['value'] = email91    if phone_input:92        phone_input['value'] = phone93 94    # Step 4: Prepare form data95    data = {input['name']: input.get('value', '') for input in form.find_all(['input', 'textarea'])}96 97    # Include hidden inputs98    hidden_inputs = form.find_all('input', type='hidden')99    for hidden_input in hidden_inputs:100        data[hidden_input['name']] = hidden_input['value']101 102    # Step 5: Send the POST request with stored cookies103    headers = {104        'User-Agent': USER_AGENT105    }106    try:107        response = requests.post(url, data=data, cookies=cookies, headers=headers)108 109    # Check the response status code110        if response.status_code == 200:111            print(f"Report Successful with Email: {email}, Phone Number: {phone} and Message: {message} using Proxy: {proxy, proxy_type}\n")112            success_count += 1113        else:114            error_count += 1115            pass116            117    except AttributeError:118        error_count += 1119        pass120    except requests.exceptions.RequestException:121        error_count += 1122        pass123    except Exception as e:124        error_count += 1125        return errors.write(f'{e}\n')126    127def get_views_from_saved_proxies(proxy_type, proxies, username):128    for proxy in proxies:129        control(proxy.strip(), proxy_type, username)130 131def start_view():132 133    while True:134            threads = []135            for proxy_type in PROXIES_TYPES:136                with open(f"{proxy_type}_proxies.txt", 'r') as file:137                    proxies = file.readlines()138                chunked_proxies = [proxies[i:i + 70] for i in range(0, len(proxies), 70)]139                for chunk in chunked_proxies:140                    thread = Thread(target=get_views_from_saved_proxies, args=(proxy_type, chunk, username))141                    threads.append(thread)142                    thread.start()143            for t in threads:144                t.join()145 146        147E = '\033[1;31m'148B = '\033[2;36m'149G = '\033[1;32m'150S = '\033[1;33m'151 152def check_views():153 154    global success_count155    global error_count156    157    while True:158        print(f'{G}[ TOTAL THREADS ]: {B}{active_count()} ⇝⇝⇝⇝ \n{G}[ SUCCESSFULL REPORT ]: {S}{success_count}\n{G}[ FAILED REPORT ]: {E}{error_count}\n')159        160        sleep(4)161 162username = input("Enter the username of Channel, Person or Group you want to report. You can also use link:: ")163 164Thread(target=start_view).start()165Thread(target=check_views).start()