-
Notifications
You must be signed in to change notification settings - Fork 1
/
ph0enix.py
151 lines (111 loc) · 4.43 KB
/
ph0enix.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
149
150
151
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
sys.dont_write_bytecode = True
from Core.Styling import *
from Core.Environment import Environment
from Core.Database import Database
from Core.Config import CoreConfig
from Core.Commands import Command
from Core.Input import InputManager
from Core.Validity import Validation
from Core.Requester import RequestHandler
from Core.Error import ErrorHandler
ErrorHandler().CreateLogFile()
class Ph0enix:
def __init__(self):
self.Environment = Environment()
self.Config = CoreConfig()
self.Database = Database(self.Environment.Env, self.Config)
self.Cmd = Command()
self.Input = InputManager()
self.Validator = Validation()
self.Request = RequestHandler()
self.Error = ErrorHandler()
def BuildLinks(self, Username: str = None) -> (list | None):
BuiltLinks = self.Request.LinkFormatter(Username)
if(len(BuiltLinks) > 0):
return BuiltLinks
self.Cmd.Clear(f"{sd.eBan} No data found", False)
self.Main()
def LoadLinks(self, Username: str = None): # -> (dict | None)
Links = self.Database.Select("website_urls", [["is_active", "=", 1]])
Response = {}
for LinkData in Links:
LinkID = LinkData["id"]
Link = str(LinkData["url"])
if("[USER]" in Link):
Response[LinkID] = Link.replace("[USER]", Username)
else:
print(self.Error.Throw("link_username_replacement_chunk_not_found", Link))
if(self.Validator.NotEmpty(Response)):
return Response
self.Cmd.Clear(f"{sd.eBan} No data found", False)
self.Main()
def StartSearch(self, Username: str = None, FormattedLinks: dict = {}) -> dict:
self.Cmd.Clear(f"{sd.sBan}Searching for {bc.GC}{Username}{bc.BC}\n", False)
Matches = {}
for LinkID, Link in FormattedLinks.items():
WebsiteName = self.Request.GetWebsiteName(Link)
if(self.Validator.NotEmpty(WebsiteName)):
IsInSite = self.Request.Search(Link)
if(IsInSite):
Matches[LinkID] = Link
StatusBanner = f"{bc.GC}Match Found{bc.BC}"
self.Error.AddToLog("info", f"Match found on '{WebsiteName}'")
else:
StatusBanner = f"{bc.RC}Not Found{bc.BC}"
self.Error.AddToLog("info", f"No match found on '{WebsiteName}'")
print(f"{bc.BC} | Website ID: {bc.GC}{LinkID}{bc.BC}")
print(f" | Website: {bc.GC}{WebsiteName}{bc.BC}")
print(f" | Status: {StatusBanner}")
print(f" | Location: {bc.GC}{Link}{bc.BC}\n")
return Matches
def PrintResults(self, Username: str = None, SearchResults: dict = [], TotalLinkCount: int = 0) -> None:
FoundCount = 0
if(self.Validator.NotEmpty(SearchResults)):
FoundCount = len(SearchResults.keys())
self.Cmd.Clear()
for MatchID, MatchLink in SearchResults.items():
if(self.Environment.Env["StoreResults"] == "true"):
self.Database.Insert(
Table="found_profiles",
Values=[self.Config.GenerateMD5(Username + self.Config.GenerateID()), MatchID, Username, MatchLink, self.Config.UnixTimestamp()]
)
print(f" | Website ID: {bc.GC}{MatchID}{bc.BC}")
print(f" | Website: {bc.GC}{self.Request.GetWebsiteName(MatchLink)}{bc.BC}")
print(f" | Location: {bc.GC}{MatchLink}{bc.BC}\n")
print(f"{sd.sBan}Found {bc.GC}{str(FoundCount)}{bc.BC} potential matches on {bc.GC}{TotalLinkCount}{bc.BC} websites\n")
def CommandStream(self, ShowHelp: bool = False, SeenIntro: bool = True) -> None:
if(ShowHelp):
print(f" Use {bc.GC}help{bc.BC} to see all commands\n")
InputValue = str(input(f"{bc.BC} Command ?>{bc.GC} ")).strip()
if(self.Validator.NotEmpty(InputValue)):
if(InputValue == "help"):
self.Cmd.Clear()
self.Input.Help()
elif(InputValue.startswith("database")):
self.Cmd.Clear()
self.Database.Interface.Stream(None, True)
else:
if(not SeenIntro):
print(f"{sd.iBan} Matches may not always be specific to the user you are looking for")
print(f"{sd.iBan} For example, someone else could have used the same username elsewhere\n")
Username = InputValue
if(self.Validator.NotEmpty(Username)):
WebsiteLinks = self.LoadLinks(Username)
SearchResults = self.StartSearch(Username, WebsiteLinks)
self.PrintResults(Username, SearchResults, len(WebsiteLinks))
else:
self.Cmd.Clear(self.Error.Throw("empty_command_stream_value"), False)
self.CommandStream()
if(__name__ == "__main__"):
def Initiate():
try:
Run = Ph0enix()
Run.CommandStream(True, False)
except KeyboardInterrupt:
ErrorHandler().AddToLog("info", "User interrupted the program")
quit()
Command().Clear()
Initiate()