-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfEagle.py
325 lines (310 loc) · 16.4 KB
/
fEagle.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import os
import sys
import signal
import header
import commandParser as _command_parser
import fescriptManager
import socket as s
import json
import shutil
import time
from colorama import init
init()
from colorama import Fore,Back
from processManager import _process_mode,FE_PROCESS_MANAGER
from functions.functions import FUNCTIONS
from fescripts.libs.PFable import fable_mode,fable
from colorManager import *
from feConfig import *
_HEADER = header.FE_HEADER()
_COLOR_M = FE_COLOR()
_FUNCTIONS = FUNCTIONS()
_cp = _command_parser.FE_COMMAND_PARSE()
_fsc = fescriptManager.FE_SCRIPT_MANAGER()
_proc = FE_PROCESS_MANAGER()
_in_app = True
__FE_MULTI_FESCRIPT__ = []
def goodBye():
print(Fore.LIGHTBLUE_EX + "\nGoodbye!" + Fore.RESET)
sys.exit(0)
def signal_handler(sig, frame):
goodBye()
signal.signal(signal.SIGINT, signal_handler)
def clearConsole():
os.system('cls' if os.name == 'nt' else 'clear')
def main():
_HEADER.printHeader()
while (_in_app):
try:
command = input(Fore.RESET + "FatEagle ~> " if _fsc.loaded_script == "" else "FatEagle " + Fore.MAGENTA + "fescript" + Fore.RESET + "(" + Fore.YELLOW + _fsc.loaded_script + Fore.RESET + ") ~> ")
except:
goodBye()
if (command != ""):
if (command.casefold() == "myIP".casefold()):
print("Your IP adrress is :",Fore.LIGHTGREEN_EX + s.gethostbyname(s.gethostname()) + Fore.RESET)
elif (command.casefold() == "myHost".casefold()):
print("Your host name is :",Fore.LIGHTGREEN_EX + s.gethostname() + Fore.RESET)
elif (os.name == "nt" and command == "cls"):
clearConsole()
elif (os.name != "nt" and command == "clear"):
clearConsole()
elif (command.casefold() == "banner".casefold()):
_HEADER.printHeader()
elif (_cp.isLoading(command) != False):
f = _cp.isLoading(command)
if (f["Type"] == "FESCRIPT"):
_fsc.loadScript(f["Name"])
elif (command.casefold() == "unload module"):
if (_fsc.loaded_script != ""): _fsc.unloadScript()
elif (command.casefold() == "fesInfo".casefold()):
if (_fsc.loaded_script != ""):
try:
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
eval("_main_module." + pathilize(_fsc.loaded_script) + "().info()")
except:
print(Fore.LIGHTRED_EX + "fescript " + Fore.LIGHTBLUE_EX + pathilize(_fsc.loaded_script) + Fore.LIGHTRED_EX + " does not exist or may it has some errors" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
elif (command.casefold() == "fesHelp".casefold()):
if (_fsc.loaded_script != ""):
try:
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
eval("_main_module." + pathilize(_fsc.loaded_script) + "().help()")
except:
print(Fore.LIGHTRED_EX + "fescript " + Fore.LIGHTBLUE_EX + pathilize(_fsc.loaded_script) + Fore.LIGHTRED_EX + " does not exist or may it has some errors" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
elif (command.casefold() == "fesOptions".casefold()):
if (_fsc.loaded_script != ""):
try:
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
eval("_main_module." + pathilize(_fsc.loaded_script) + "().switchInfo()")
except:
print(Fore.LIGHTRED_EX + "fescript " + Fore.LIGHTBLUE_EX + pathilize(_fsc.loaded_script) + Fore.LIGHTRED_EX + " does not exist or may it has some errors" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
elif (command.casefold() == "fesRequire".casefold()):
if (_fsc.loaded_script != ""):
try:
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
eval("_main_module." + pathilize(_fsc.loaded_script) + "().missedSwitch()")
except:
print(Fore.LIGHTRED_EX + "fescript " + Fore.LIGHTBLUE_EX + pathilize(_fsc.loaded_script) + Fore.LIGHTRED_EX + " does not exist or may it has some errors" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
elif (_cp.IsSet(command) != False):
setValue(command)
elif (_cp.IsShow(command) != False):
showValue(_cp.IsShow(command))
elif (command.casefold() == "fesStart".casefold()):
try:
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
_proc.setPM(_process_mode.IN_SCRIPT)
eval("_main_module." + pathilize(_fsc.loaded_script) + "()._pre_start()")
_proc.setPM(_process_mode.FREE)
except:
print(Fore.LIGHTRED_EX + "fescript " + Fore.LIGHTBLUE_EX + pathilize(_fsc.loaded_script) + Fore.LIGHTRED_EX + " does not exist or may it has some errors" + Fore.RESET)
elif (_cp.IsSearch(command) != False):
_search = _cp.IsSearch(command)
if (_search == "*"): _search = "s"
_file = open("ModulesDB.json","r",encoding="utf8")
_modules = json.load(_file)
cols = ["name","description"]
data = []
for _ in _modules:
if (_search.casefold() in _["MODULE_FNAME"].casefold() or _search.casefold() in _["MODULE_INFO"].casefold()
or _search.casefold() in _["MODULE_DESC"].casefold()
or _search.casefold() in _["MODULE_AUTHOR"].casefold()):
data.append([_["MODULE_FNAME"],_["MODULE_INFO"]])
if (len(data) == 0):
print(Fore.LIGHTRED_EX + "can't find any module named '" + Fore.CYAN + _search + Fore.LIGHTRED_EX + "'.\nif you added new fescript, you may need to update modules database using:" + Fore.YELLOW + "\n update db" + Fore.RESET)
else:
_fable = fable(cols,data,fable_mode.BOLD_COLUMNS)
print(_fable.popData())
elif (command.casefold() == "update mdb".casefold()):
updateModulesDB(True)
elif (command.casefold() == "update fundb".casefold()):
_FUNCTIONS.updateFunctionDB(True)
elif (_cp.isFunSearch(command) != False):
_FUNCTIONS.searchFunc(_cp.isFunSearch(command))
elif (command.casefold() == "exit".casefold()):
print(Fore.LIGHTBLUE_EX + "\nGoodbye!" + Fore.RESET)
sys.exit(0)
elif (_cp.IsAdd(command) != False):
arged = _cp.IsAdd(command)
__fes_dir = getListOfFiles("fescripts/")
for i in range(0,len(__fes_dir)):
__fes_dir[i] = __fes_dir[i].replace("fescripts/","")
_fescript = arged[1]
_list_name = arged[2]
__all_vars = globals().keys()
found = False
for i in __all_vars:
if (_list_name == i):
found = True
break
if (found):
found = False
for i in __fes_dir:
if (_fescript == i):
found = True
break
if (found):
if (_fescript not in eval(_list_name)):
eval(_list_name + ".append(\"" + _fescript + "\")")
else:
print(Fore.LIGHTRED_EX + "fescript '" + Fore.LIGHTBLUE_EX + _fescript + Fore.LIGHTRED_EX + "' is Undefined!" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "list '" + Fore.LIGHTBLUE_EX + _list_name + Fore.LIGHTRED_EX + "' is Undefined!" + Fore.RESET)
del __all_vars
del __fes_dir
elif (_cp.IsShowList(command) != False):
_list_name = _cp.IsShowList(command)
__all_vars = globals().keys()
found = False
for i in __all_vars:
if (_list_name == i):
found = True
break
if (found):
eval("print(" + str(_list_name) + ")")
else:
print(Fore.LIGHTRED_EX + "list '" + Fore.LIGHTBLUE_EX + _list_name + Fore.LIGHTRED_EX + "' is Undefined!" + Fore.RESET)
del __all_vars
elif (command.casefold() == "deltemp".casefold()):
clearModuleTemp(True)
elif (command.casefold() == "info __FE_MULTI_FESCRIPT__".casefold()):
for i in __FE_MULTI_FESCRIPT__:
print(i + " : ")
_main_module = locals()[pathilize(i)] = __import__("fescripts." + i.replace("/","."),fromlist=['object'])
_ = eval("_main_module." + pathilize(i) + "().switchInfo()")
del _main_module
elif (command.casefold() == "start __FE_MULTI_FESCRIPT__".casefold()):
for i in __FE_MULTI_FESCRIPT__:
print(i + " : ")
_main_module = locals()[pathilize(i)] = __import__("fescripts." + i.replace("/","."),fromlist=['object'])
_proc.setPM(_process_mode.IN_SCRIPT)
_ = eval("_main_module." + pathilize(i) + "()._pre_start()")
del _main_module
_proc.setPM(_process_mode.FREE)
elif (_cp.IsMultiFesSet(command) != False):
arged = _cp.IsMultiFesSet(command)
_s_name = arged[1]
_s_val = arged[2]
_fes_name = arged[3]
_fsc.loadScript(_fes_name)
setValue("set " + _s_name + " " + _s_val)
elif (command.casefold() == "version".casefold()):
print(_COLOR_M.colorful_str("Fat Eagle V" + VERSION_))
elif (_cp.isFuncCall(command) != False):
funcCall = _cp.isFuncCall(command)
_FUNCTIONS.execute(funcCall[0],funcCall[1])
elif (_cp.isExec(command) != False):
_shell = _cp.isExec(command)
os.system(_shell)
elif (command.casefold() == "fwi".casefold()):
print(Fore.YELLOW + "Fat Eagle is a hacking and cybersecurity framework written in python by " + DEVELOPER + """
you can easily run it everywhere like windows,linux,mac,android and everywehere python can run. with this framework you can access to top security tools like exploits,payloads,hash crackers,phishing tools and e.t.c.""" + Fore.RESET)
else:
print(Fore.LIGHTCYAN_EX + command + Fore.LIGHTRED_EX + " is not a valid command." + Fore.RESET)
def showValue(switch):
if (_fsc.loaded_script != ""):
found = False
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
props = eval("_main_module." + pathilize(_fsc.loaded_script) + "().allSwitches()")
del _main_module
for i in props:
if (switch in i):
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
eval("_main_module." + pathilize(_fsc.loaded_script) + "().showSwitch(\"" + switch + "\")")
found = True
del _main_module
break
if (found == False):
print(Fore.LIGHTRED_EX + "switch " + Fore.LIGHTBLUE_EX + switch + Fore.LIGHTRED_EX + " does not exist!" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
def setValue(command):
if (_fsc.loaded_script != ""):
other = command[4:len(command)].split()
found = False
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
props = eval("_main_module." + pathilize(_fsc.loaded_script) + "().allSwitches()")
del _main_module
for i in props:
if (other[0] == i):
_main_module = locals()[_fsc.loaded_script] = __import__(_fsc.loaded_script.replace("/","."),fromlist=['object'])
oper = eval("_main_module." + pathilize(_fsc.loaded_script) + "().setSwitch(\"" + other[0] + "\",\"" + other[1] + "\")")
if (oper == None):
print(Fore.LIGHTBLUE_EX + other[0] + Fore.RESET + " ---> " + Fore.LIGHTGREEN_EX + other[1] + Fore.RESET)
else:
if (oper[0] == False):
print(Fore.RED + oper[1] + Fore.RESET)
found = True
del _main_module
break
if (found == False):
print(Fore.LIGHTRED_EX + "switch " + Fore.LIGHTBLUE_EX + other[0] + Fore.LIGHTRED_EX + " does not exist!" + Fore.RESET)
else:
print(Fore.LIGHTRED_EX + "no module loaded." + Fore.RESET)
def pathilize(_str):
last = ""
for i in _str[::-1]:
if (i == '/'):
break
else:
last += i
return last[::-1]
def getListOfFiles(dirName):
listOfFile = os.listdir(dirName)
allFiles = list()
for entry in listOfFile:
fullPath = os.path.join(dirName, entry)
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
else:
path = fullPath.replace("\\","/")
if (path[len(path) - 3:len(path)] == ".py" and "libs" not in path and "temp" not in path):
allFiles.append(path[0:len(path) - 3])
return allFiles
def updateModulesDB(userRequest = False):
FeScripts = getListOfFiles("fescripts/")
data = []
for _ in FeScripts:
if ('s' in _):
_main_module = locals()[_] = __import__(_.replace("/","."),fromlist=['object'])
info = eval("_main_module." + pathilize(_) + "()._info()")
desc = eval("_main_module." + pathilize(_) + "()._help()")
author = eval("_main_module." + pathilize(_) + "()._author()")
data.append({"MODULE_FNAME":_,"MODULE_INFO":info.replace("\n", ""),"MODULE_DESC":desc,"MODULE_AUTHOR":author})
del _main_module
_file = open("ModulesDB.json","w",encoding="utf8")
json.dump(data,_file,indent=4, sort_keys=True)
_file.close()
if (userRequest): print(Fore.GREEN + "Modules Database Updated!" + Fore.RESET)
def clearModuleTemp(userRequest = False):
folder = 'fescripts/temp/'
for filename in os.listdir(folder):
file_path = os.path.join(folder, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print(Fore.RED + ('Failed to delete %s. Reason: %s' % (file_path, e)) + Fore.RESET)
if (userRequest): print(Fore.GREEN + "Modules Temp Cleared!" + Fore.RESET)
if (__name__ == "__main__"):
msg = 'Loading Fat Eagle ...'
clearConsole()
sys.stdout.write(msg)
sys.stdout.flush()
time.sleep(2)
for _ in range(len(msg)):
time.sleep(0.1)
sys.stdout.write('\033[D \033[D')
sys.stdout.flush()
if (MODULE_DB_UPDATE_ON_START): updateModulesDB()
if (CLEAR_MODULE_TEMPS_ON_START): clearModuleTemp()
_FUNCTIONS.updateFunctionDB()
main()