MSSWY/main.py

92 lines
2.1 KiB
Python

import src.tools as tools
import src.site as site
import src.proxy as proxy
import src.monitor as monitor
import os
import glob
from dotenv import load_dotenv
from colorama import Style, Fore, init
def initialize():
# Init Environment
load_dotenv()
# Init Colorama
init(autoreset=True)
def checksites(sitepath=None):
print(f"{tools.heading('Checking Sitedata')}\n{tools.spacer}")
sitedic = {}
if sitepath:
sitedir = sitepath
else:
rootdir = os.path.dirname(os.path.abspath(__file__))
sitedir = rootdir + r"\sites"
for sitefile in glob.glob(sitedir + r"\*.json"):
asite = site.Site(sitefile)
print(f"> {Fore.MAGENTA}{asite.name:10s}{Style.RESET_ALL} |"
f" {tools.keyword('URL')}({asite.url})")
sitedic[asite.name] = asite
print(tools.spacer)
return sitedic
def createproxys():
print(f"{tools.heading('Creating Proxy(s)')}\n{tools.spacer}")
proxydic = {}
one = proxy.Proxy(
name="PrxOne",
url=os.getenv("PROXYURL"),
port=os.getenv("PROXYPORT"),
usr=os.getenv("PROXYUSR"),
pwd=os.getenv("PROXYPW")
)
print(f"> {Fore.MAGENTA}{one.name:10s}{Style.RESET_ALL} |"
f" {tools.keyword('PROXYIP')}({one.ip}) {tools.keyword('WORKING')}({one.isworking})")
# one.testurl("http://www.whatismyproxy.com/")
proxydic[one.name] = one
print(tools.spacer)
return proxydic
def createmonitors(n=1):
print(f"{tools.heading(f'Creating Monitor(s)')}\n{tools.spacer}")
monitordic = {}
for i in range(0, n):
mon = monitor.Monitor()
mon.name = f"Mon{i}"
mon.url = "test"
print(f"> {Fore.MAGENTA}{mon.name:10s}{Style.RESET_ALL} |"
f" {tools.keyword('URL')}({mon.url}) {tools.keyword('PROXY')}({mon.proxy})")
monitordic[mon.name] = mon
print(tools.spacer)
return monitordic
if __name__ == "__main__":
tools.clear()
initialize()
dicSites = checksites()
dicProxys = createproxys()
dicMonitors = createmonitors()
print(dicSites)
print(dicProxys)
print(dicMonitors)