forked from EntySec/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathghost
executable file
·125 lines (113 loc) · 3.93 KB
/
ghost
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
#!/usr/bin/env python3
#
# MIT License
#
# Copyright (c) 2020 EntySec
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
import os
os.system("printf '\033]2;Ghost Framework\a'")
import sys
import subprocess
import readline
import time
from core.badges import badges
from core.server import server
from core.helper import helper
badges = badges()
server = server()
helper = helper()
readline.parse_and_bind('tab: complete')
def banner():
os.system("clear")
os.system("cat banner/banner.txt")
print("")
print("Ghost Framework " + helper.version)
print("--------------------")
print("")
def main():
rport = str(helper.rport)
rhost = ""
try:
ui = input('\033[4mghost\033[0m> ').strip(" ")
except:
sys.exit()
ui = ui.split()
while True:
if ui == []:
pass
elif ui[0] == "exit":
sys.exit()
elif ui[0] == "clear":
os.system("clear")
elif ui[0] == "update":
os.system("chmod +x etc/update.sh && etc/update.sh")
elif ui[0] == "help":
print("")
print("Core Commands")
print("=============")
os.system("cat data/cmds/core_cmds.txt")
print("")
elif ui[0] == "options":
if len(rhost) >= 12 or len(rport) >= 12:
if len(rhost) > len(rport):
bigger = len(rhost) - 3
else:
bigger = len(rport) - 3
else:
bigger = 8
print("")
print("Ghost Options")
print("=============")
print("")
print(" Option Value" + " " * bigger + "Description")
print(" ------ -----" + " " * bigger + "-----------")
print(" RHOST " + rhost + " " * (5 - len(rhost) + bigger) + "Remote host.")
print(" RPORT " + rport + " " * (5 - len(rport) + bigger) + "Remote port.")
print("")
elif ui[0] == "set":
if len(ui) < 3:
print("Usage: set <option> <value>")
else:
if ui[1].lower() == "rhost":
rhost = ui[2]
print(badges.I + "RHOST ==> " + ui[2])
elif ui[1].lower() == "rport":
rport = ui[2]
print(badges.I + "RPORT ==> " + ui[2])
else:
print(badges.E + "Option is not found!")
elif ui[0] == "run":
if rhost == "" or rport == "":
print(badges.E + "Failed to connect to target!")
else:
try:
server.connect(rhost, rport)
except SystemExit:
pass
else:
print(badges.E + "Unrecognized command!")
try:
ui = input('\033[4mghost\033[0m> ').strip(" ")
except:
sys.exit()
ui = ui.split()
banner()
main()