Remote-Code-Command-execution

A naive ssh clone, with screen sharing
git clone https://github.com/abdulrahim2002/Remote-Code-Command-execution

Log | Files | Refs | README

streamVideo.py (1305B)


      1 from flask import Flask, Response
      2 import cv2
      3 import numpy as np
      4 import pyautogui
      5 import time
      6 import utility
      7 
      8 FRAME_RATE = 15
      9 IP = utility.get_ip_address()
     10 
     11 app = Flask(__name__)
     12 
     13 SCREEN_SIZE = (1280,720)
     14 # SCREEN_SIZE = (1920,1080)
     15 
     16 def gen_frames():
     17     while True:
     18         start_time = time.time()  # Record the start time
     19 
     20         # Capture the screen
     21         img = cv2.cvtColor(np.array(pyautogui.screenshot()), cv2.COLOR_RGB2BGR)
     22 
     23         # Resize the screenshot to the desired resolution
     24         img = cv2.resize(img, SCREEN_SIZE)
     25 
     26         # Convert the frame to a JPEG image
     27         ret, buffer = cv2.imencode('.jpg', img)
     28 
     29         # Yield the image data as bytes
     30         yield (b'--frame\r\n'
     31                b'Content-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
     32 
     33         # Calculate the time elapsed since the start of the loop
     34         elapsed_time = time.time() - start_time
     35 
     36         # If the elapsed time is less than the desired time per frame, delay the loop
     37         if elapsed_time < 1 / FRAME_RATE:
     38             time.sleep(1 / FRAME_RATE - elapsed_time)
     39 
     40 @app.route('/')
     41 def video():
     42     return Response(gen_frames(),
     43                     mimetype='multipart/x-mixed-replace; boundary=frame')
     44 
     45 if __name__ == '__main__':
     46     print(f'Path: http://{IP}:5000')
     47     app.run(host=IP)
     48 
     49