Method and device for preventing screen capture and screen recording in sandbox under Linux, medium and equipment

By building a sandbox environment in a Linux system, isolating the X11 and Wayland socket files, and starting the corresponding service instances, the problem of the inability to fully prevent screenshots and screen recordings in existing technologies is solved, achieving more effective screen content protection.

CN120995518APending Publication Date: 2025-11-21BEIJING WANLIHONG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511162708.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Under Linux systems, existing methods for preventing screenshots and screen recordings cannot effectively cover all screenshot and screen recording methods. In particular, the methods for intercepting API call requests are limited under the X11 architecture, and the methods for intercepting the DBus interface under the Wayland architecture cannot intercept kernel-level behavior, resulting in a significant risk of screen content leakage.

Method used

Build a sandbox environment to isolate the X11 socket file and the Wayland socket file, start an Xorg service instance or Weston service, ensure that the application runs in an independent space, external processes cannot access the graphical interactive communication endpoint, and block the screenshot and screen recording paths.

Benefits of technology

It effectively blocks external processes from reading graphics layer data, reduces the risk of the session screen being captured and recorded, and improves the effectiveness of preventing screen content leakage under Linux.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120995518A_ABST
    Figure CN120995518A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for preventing screen capture and screen recording in a sandbox under Linux, a medium and equipment, and relates to the technical field of graphic interaction.The method comprises the steps that a sandbox environment is constructed and started based on a Linux system; an X11 socket file and a Wayland socket file in the sandbox environment are isolated, and the type of the current Linux graphic architecture is determined; if the Linux graphic architecture type is an X11 architecture, starting an Xorg service instance in the sandbox environment, and when an isolated first application program in the sandbox environment is started, performing graphic interaction with the first application program through the Xorg service instance; and if the Linux graphic architecture type is a Wayland architecture, starting a Weston service in the sandbox environment, and when an isolated second application program in the sandbox environment is started, carrying out graphic interaction with the second application program through the Weston service. According to the method and the device, the effect of preventing screen content leakage under Linux can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of graphical interaction, in particular to a method and device for preventing screen capture and screen recording in a Linux sandbox, a medium and equipment. BACKGROUND

[0002] At present, the existing Linux graphical system is mainly based on X11 architecture or Wayland architecture. The X11 architecture is a bottom-layer architecture standard of graphical user interface (GUI) in Linux system, and its core is to realize the separation of graphical display and input control through the Client-Server architecture, which has high flexibility and cross-platform nature. The Wayland architecture is a modern graphical display architecture designed as an alternative to X11, aiming to solve the historical problems of X11 (such as bloated architecture, low efficiency, weak security, etc.), and its core is to simplify the graphical interaction process by adopting a more direct "Client-Compositor" architecture, which has become the mainstream development direction of Linux desktop. Under the X11 architecture or Wayland architecture, other user processes on the same physical machine can access the current session picture content through X11 service or Wayland service, which has the risk of malicious screen capture and screen recording, and thus the user's screen content has a large leakage risk. Therefore, there is an urgent need for a way to prevent screen capture and screen recording under Linux system.

[0003] At present, the commonly used way to prevent screen capture and screen recording under Linux system is as follows: for X11 architecture, by intercepting the calling request of various screen capture APIs and screen recording APIs, once unauthorized malicious screen capture or screen recording is found, the corresponding request is prevented, so as to achieve the purpose of preventing screen capture and screen recording. For Wayland architecture, by intercepting the screen capture and screen recording behavior through DBus interface to achieve the purpose of preventing screen capture and screen recording. However, the way of intercepting the calling request of API under X11 architecture can only intercept part of the known API, and cannot cover all screen capture and screen recording paths; the way of intercepting DBus interface under Wayland architecture can only intercept the screen capture and screen recording behavior through standard DBus interface, and cannot intercept other non-standard paths such as kernel layer screen capture behavior, resulting in poor effect of preventing screen content leakage under Linux. SUMMARY

[0004] In order to improve the effect of preventing screen capture under Linux, the present application provides a method and device for preventing screen capture and screen recording in a Linux sandbox, a medium and equipment.

[0005] In a first aspect of the present application, a method for preventing screen capture and screen recording in a Linux sandbox is provided, which specifically comprises: constructing a sandbox environment based on a Linux system and starting the sandbox environment; isolating X11 socket files and Wayland socket files in the sandbox environment and determining a current Linux graphics architecture type; if the Linux graphics architecture type is an X11 architecture, starting an Xorg service instance in the sandbox environment, and when a first application program isolated in the sandbox environment is started, performing graphics interaction with the first application program through the Xorg service instance; if the Linux graphics architecture type is a Wayland architecture, starting a Weston service in the sandbox environment, and when a second application program isolated in the sandbox environment is started, performing graphics interaction with the second application program through the Weston service.

[0006] By adopting the technical solution, the various application programs under the Linux system environment are isolated from the host system by starting the sandbox environment, so that the application programs started in the sandbox environment run in an independent space and are less likely to be monitored by external processes. Then, the X11 socket files and the Wayland socket files in the sandbox environment are isolated, so that whether in the process of graphics interaction with the application program under the X11 architecture or in the process of graphics interaction with the application program under the Wayland architecture, an external process cannot access the communication endpoints related to the graphics interaction, thereby blocking the reading permission of the graphics layer data from the source, reducing the risk of screen capture and screen recording. Further, when the Linux graphics architecture type is the X11 architecture, after the first application program is started, the first application program and the independently started Xorg service instance perform graphics interaction only in the sandbox environment, and the X11 socket files are isolated in advance, so that the external process cannot access the Xorg service instance. When the Linux graphics architecture type is the Wayland architecture, after the second application program is started, the second application program and the independently started Weston service perform graphics interaction only in the sandbox environment, and the Wayland socket files are isolated in advance, so that the external process cannot access the Weston service, so that the graphics rendering and display of the started application program are limited to the inside of the sandbox environment, the external process cannot bypass the sandbox environment to obtain the graphics content in the sandbox, thereby effectively blocking the screen capture and screen recording path, and improving the effect of preventing screen content leakage under Linux.

[0007] In an embodiment, the isolating the X11 socket files and the Wayland socket files in the sandbox environment specifically includes: The sandbox file system of the sandbox environment hides a socket path corresponding to an X11 socket file and a socket path corresponding to a Wayland socket file in the sandbox environment.

[0008] In an embodiment, the starting the Xorg service instance in the sandbox environment specifically comprises: selecting a target virtual display instance from the virtual display instances that are not currently occupied; starting the Xorg service instance in the sandbox environment based on the target virtual display instance.

[0009] In an embodiment, the starting the Xorg service instance in the sandbox environment based on the target virtual display instance specifically comprises: determining a first number corresponding to the target virtual display instance; creating an Xorg service instance with a display number of the first number and starting the Xorg service instance in the sandbox environment.

[0010] In an embodiment, when the first application isolated in the sandbox environment is started, the Xorg service instance is used for graphic interaction with the first application, specifically comprising: determining a first number corresponding to the target virtual display instance; setting an environment variable of an application started in the sandbox environment to a first environment variable according to the first number, the first environment variable being represented as: DISPLAY1=:X; In the formula, DISPLAY1 represents the first environment variable, and :X represents the first number. When the first application isolated in the sandbox environment is started, the Xorg service instance is used for graphic interaction with the first application in an interface corresponding to the first environment variable.

[0011] In an embodiment, the starting the Weston service in the sandbox environment specifically comprises: switching a current graphic interaction interface to a target virtual terminal by openvt, the target virtual terminal being a currently idle virtual terminal; starting the Weston service under the Wayland architecture in the sandbox environment based on the target virtual terminal.

[0012] In an embodiment, when the second application isolated in the sandbox environment is started, the Weston service is used for graphic interaction with the second application before the graphic interaction, further comprising: determining a second number associated with the target virtual terminal; starting an X11 compatible layer in the sandbox environment according to the second number, the X11 compatible layer being represented as Xwayland:Y, wherein :Y represents the second number; when the second application isolated in the sandbox environment is started, performing graphical interaction with the second application through the Weston service, and the graphical interaction specifically includes: setting an environment variable of the application started in the sandbox environment as a second environment variable according to the second number, the second environment variable being represented as: DISPLAY2=:Y; in the formula, DISPLAY2 represents the second environment variable, and :Y represents the second number; when the second application isolated in the sandbox environment is started, performing graphical interaction with the second application in an interface corresponding to the second environment variable through the Weston service.

[0013] In a second aspect of the present application, a device for preventing screen capture and screen recording in a sandbox under Linux is provided, and specifically includes: a sandbox starting module configured to construct a sandbox environment and start the sandbox environment based on a Linux system; a file isolation module configured to isolate X11 socket files and Wayland socket files in the sandbox environment, and determine a current Linux graphics architecture type; a first interaction module configured to, if the Linux graphics architecture type is an X11 architecture, start an Xorg service instance in the sandbox environment, and when a first application isolated in the sandbox environment is started, perform graphical interaction with the first application through the Xorg service instance; a second interaction module configured to, if the Linux graphics architecture type is a Wayland architecture, start a Weston service in the sandbox environment, and when a second application isolated in the sandbox environment is started, perform graphical interaction with the second application through the Weston service.

[0014] By adopting the technical scheme, the sandbox starting module is based on a Linux system, constructs a sandbox environment and starts the sandbox environment, then the file isolation module isolates X11 socket files and Wayland socket files in the sandbox environment and determines a current Linux graphic architecture type, then the first interaction module starts an Xorg service instance in the sandbox environment when the Linux graphic architecture type is an X11 architecture, and performs graphic interaction with the first application through the Xorg service instance when the first application in the sandbox environment is started, finally, the second interaction module starts a Weston service in the sandbox environment when the Linux graphic architecture type is a Wayland architecture, and performs graphic interaction with the second application through the Weston service when the second application in the sandbox environment is started.

[0015] In a third aspect of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, when the computer program is loaded and executed by a processor, the method steps in any one of the first aspect are executed.

[0016] In a fourth aspect of the present application, an electronic device is provided, specifically comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, the processor being configured to load and execute the computer program stored in the memory, so that the electronic device executes the method in any one of the first aspect.

[0017] In summary, the present application includes at least one of the following beneficial technical effects: by starting a sandbox environment, the various application programs under the Linux system environment are isolated from the host system, so that the application programs started in the sandbox environment run in an independent space and are less likely to be monitored by external processes. Then, the X11 socket file and the Wayland socket file in the sandbox environment are isolated, so that whether in the process of graphical interaction with the application program under the X11 architecture or in the process of graphical interaction with the application program under the Wayland architecture, external processes cannot access the communication endpoints related to graphical interaction, thereby blocking the reading permission of the external processes on the graphical layer data from the source, reducing the risk of screen capture and screen recording. Further, when the Linux graphical architecture type is the X11 architecture, after the first application program is started, the first application program and the independently started Xorg service instance only perform graphical interaction within the sandbox environment, and the X11 socket file is isolated in advance, so that the external processes cannot access the Xorg service instance; when the Linux graphical architecture type is the Wayland architecture, after the second application program is started, the second application program and the independently started Weston service only perform graphical interaction within the sandbox environment, and the Wayland socket file is isolated in advance, so that the external processes cannot access the Weston service, so that the graphical rendering and display of the started application program are limited within the sandbox environment, and the external processes cannot bypass the sandbox environment to obtain the graphical content within the sandbox, thereby effectively blocking the screen capture and screen recording path, and improving the effect of preventing screen content leakage under Linux. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 is a flowchart of a Linux sandbox anti-screen capture and anti-screen recording method provided by an embodiment of the present application; Figure 2 is a structural diagram of a Linux sandbox anti-screen capture and anti-screen recording device provided by an embodiment of the present application; Figure 3 is a structural diagram of another Linux sandbox anti-screen capture and anti-screen recording device provided by an embodiment of the present application.

[0019] Marked for explanation: 11, sandbox starting module; 12, file isolation module; 13, first interaction module; 14, second interaction module; 15, compatible starting module. DETAILED DESCRIPTION

[0020] In order to make the person skilled in the art better understand the technical solutions in the specification, the technical solutions in the specification will be clearly and completely described below in combination with the drawings in the specification. Obviously, the described embodiments are only some of the embodiments of the present application, not all.

[0021] In the description of the embodiments of the present application, the words "exemplary", "for example", or "for instance" are used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary", "for example", or "for instance" in the embodiments of the present application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of "exemplary", "for example", or "for instance" is intended to present concepts in a concrete manner.

[0022] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, B alone, and A and B together. In addition, unless otherwise specified, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more features. The terms "include", "contain", "have" and their variants mean "include but not limited to", unless otherwise specifically emphasized.

[0023] Referring to Figure 1 The embodiments of the present application disclose a flowchart of a method for preventing screen capture and screen recording in a Linux sandbox, which can be implemented by relying on a computer program, and can also be run on a device for preventing screen capture and screen recording in a Linux sandbox based on the Von Neumann system. The computer program can be integrated in an application, or can be run as an independent tool application. Specifically, the method comprises the following steps: S101: Based on a Linux system, a sandbox environment is constructed and started.

[0024] Specifically, in the embodiments of the present application, the sandbox environment (Sandbox) is an independent running environment isolated from the host system, which is established by the namespace technology in the Linux system, and is used to limit the access permission of programs to system resources. The namespace technology is a lightweight virtualization technology provided in the Linux system, which isolates different resources through different types of namespaces. In addition, the types of namespaces include but are not limited to file system isolation, user space isolation (User Namespace) and process space isolation (PID Namespace), which all belong to the namespace mechanism provided by the Linux kernel. It should be noted that the file system isolation can be a mount namespace (MountNamespace), and the mount namespace is a resource isolation mechanism provided by the Linux kernel, and its core function is to create an independent file system view for different process groups. In other embodiments, the file system isolation can also be chroot or overlayfs. In addition, the user space isolation is used to isolate user and user group IDs, and the process space isolation is used to isolate process IDs.

[0025] Further, the execution subject of the Linux sandbox anti-screen capture and anti-screen recording method disclosed in the embodiments of the present application is a terminal, which can be a personal computer with a Linux system or a tablet computer with a Linux system. In addition, an implementation scenario is that when a person needs to open a process (such as an application or a software tool installed in the terminal) in the terminal and needs to prevent screen capture and screen recording from leaking screen content, the person clicks the created sandbox environment in the terminal, and in response to the person clicking the created sandbox environment in the terminal, the sandbox environment is started, thereby isolating each application installed in the terminal from the host system. Further, when the person starts a single application in the sandbox environment, any screen capture software, screen recording software or remote desktop, screen grabbing outside the sandbox environment cannot access the resources in the sandbox environment, which reduces the risk of being captured and recorded to a certain extent. It should be noted that the application isolated in the sandbox environment can be understood as an application running in a specific "safe container".

[0026] S102: Isolating the X11 socket file and the Wayland socket file in the sandbox environment, and determining the current Linux graphics architecture type.

[0027] Specifically, after the sandbox environment is started, the X11 socket file and the Wayland socket file in the sandbox environment need to be isolated. An implementable embodiment is that the sandbox file system of the sandbox environment hides the socket path corresponding to the X11 socket file and the socket path corresponding to the Wayland socket file. The X11 socket file can be understood as a specific communication endpoint created by using a Unix domain socket (UDS) under an X11 architecture, which is used for interaction with an X11 related process. The Unix domain socket is a local process communication mechanism provided by an operating system, and any program that needs to transfer data between processes on the same host can use it. The "address" of the Unix domain socket is a socket file (Unix domain socket file) in the file system, and the X11 socket file belongs to the socket file and is used to identify the endpoint of inter-process communication.

[0028] Under the X11 architecture, each Xorg instance communicates with the client through an independent Unix Domain Socket, that is, through an X11 socket file. The Xorg instance is mainly used to provide an X11 protocol interface for the application program in the terminal, so that it communicates with the Xorg server through the X11 socket file to realize graphic display or interaction. In the embodiment of the present application, the socket path corresponding to the X11 socket file includes but is not limited to / tmp / .X11-unix / X0, / tmp / .X11-unix / X1 and / tmp / .X11-unix / X2. The socket path corresponding to the X11 socket file is hidden. A feasible way of hiding is to isolate the file system view through Mount Namespace. The process outside the sandbox environment cannot perceive the socket path, so as to achieve the purpose of hiding the socket path. In other embodiments, the root directory of the sandbox environment can also be switched to an independent directory through chroot, so as to achieve the purpose of hiding the socket path. Further, the external process outside the sandbox environment cannot access the X11 socket file, and the access permission of the external process to the Xorg instance is blocked, so as to block the reading permission of the external process to the graphic layer data from the source, and further reduce the risk of screen capture and screen recording. It should be noted that the Xorg server is responsible for directly interacting with hardware (such as a graphics card, a display, and a mouse), and managing graphic output and input events.

[0029] In addition, under the Wayland architecture, the application program started in the sandbox environment performs graphical interaction with the Weston service started separately, and in the process of graphical interaction, the Weston compositor listens to an independent socket file, i.e., a Wayland socket file, and uses the socket file as an interface for communication with the started application program. Therefore, the socket path corresponding to the Wayland socket file is hidden, so that an external process outside the sandbox environment cannot access the Wayland socket file, and an external process outside the sandbox environment cannot obtain the display content in the sandbox environment through a Wayland protocol interface, further reducing the risk of screen capture and screen recording. It should be noted that the socket path corresponding to the Wayland socket file includes but is not limited to / run / user / 1000 / wayland-1 and / tmp / sandbox / wayland-0. In addition, the socket path is a string used to identify and locate the socket file.

[0030] Further, after isolating the X11 socket file and the Wayland socket file, it is necessary to determine the current architecture type of the Linux graphics system, i.e., the Linux graphics architecture type. A feasible determination method is to print the value of the XDG_SESSION_TYPE environment variable through the echo command. The specific command is "echo $XDG_SESSION_TYPE". After execution, the type of the current session is returned. If the returned value is X11, it is determined that the Linux graphics architecture type is the X11 architecture. If the returned value is Wayland, it is determined that the Linux graphics architecture type is the Wayland architecture.

[0031] S103: If the Linux graphics architecture type is the X11 architecture, an Xorg service instance is started in the sandbox environment, and when the first application program in the sandbox environment is started, the Xorg service instance performs graphical interaction with the first application program.

[0032] Specifically, if the Linux graphics architecture type is the X11 architecture, a target virtual display instance is selected from the currently unoccupied virtual display instances. Specifically, a virtual display instance can be randomly selected from the currently unoccupied virtual display instances to determine the target virtual display instance. A feasible way to determine the unoccupied virtual display instance from the created multiple virtual display instances is to check whether an Xorg instance is using a virtual display instance with a single display number through the ps command or the pgrep command. If so, it is determined that the virtual display instance is occupied. If not, it is determined that the virtual display instance is unoccupied.

[0033] The virtual display instance is a virtual display instance created by the Xorg server, which is a logical display space independent of the physical display, and is a form of virtual display device, aiming to provide an independent and isolated graphical environment from other display interfaces, and to interact with the application in the terminal through the socket file (the above X11 socket file). At the same time, an independent number is allocated to each virtual display instance created to avoid conflicts between display interfaces. The format of the number is “:N”, N is a non-negative integer, such as 0, :1, :2, etc., which is used to distinguish different display interfaces. Among them, :0 usually represents the physical main screen, and :1 and :2 usually represent virtual display instances. In addition, the unoccupied virtual display instance can be understood as the virtual display space corresponding to the virtual display instance is not activated for image session.

[0034] Further, the number corresponding to the target virtual display instance is determined as the first number, and then the Xorg instance with the display number of the first number, i.e. the Xorg service instance, is created and started in the sandbox environment. Specifically, the Xorg service instance is started by the command obtained by combining “Xorg” and the first number. Exemplarily, the first number is “:2”, and the Xorg service instance can be started by the command “Xorg:2”, and the corresponding X11 socket file ( / tmp / .X11-unix / X2) is used to interact with the isolated application in the sandbox environment. Thus, different interface services are used inside and outside the sandbox environment, so that the display interfaces cannot be interconnected, even if the screenshot software is started outside the sandbox environment for screenshot, or the screen recording software is started for screen recording, the application started in the sandbox cannot be screenshot or screen recorded. Among them, the display number is the key identifier to distinguish multiple Xorg instances in the same system.

[0035] After the Xorg service instance is started, the environment variable of the application started in the sandbox environment needs to be set to the first environment variable, and the first environment variable is represented as: DISPLAY1=:X; In the formula, DISPLAY1 represents a first environment variable, and :X represents a first number. DISPLAY1=:X can be understood as: an application program started in a sandbox environment is connected to an Xorg service instance with a display number of the first number X through the first environment variable, so as to render graphics or perform graphic interaction on a display interface or a virtual display instance corresponding to the first number. In the X11 architecture, DISPLAY is a key environment variable, which is equivalent to the "destination address" of the started application program, and determines that the window, image and other contents of the started application program will be rendered to a certain specific virtual display instance. For example, setting DISPLAY=:0 indicates that the application program will send the interface to the Xorg instance of local:0; setting DISPLAY=:2 indicates that the application program will render the interface to the virtual display instance corresponding to:2. After the environment variable is set, when the first application program in the sandbox environment is started, that is, when the first application program is started in the sandbox environment, the first application program is started and displayed on the interface corresponding to the first environment variable, and the Xorg service instance and the first application program perform graphic interaction on the interface corresponding to the first environment variable.

[0036] In S104, if the Linux graphics architecture type is the Wayland architecture, a Weston service is started in the sandbox environment, and when the second application program in the sandbox environment is started, the Weston service and the second application program perform graphic interaction.

[0037] Specifically, if the Linux graphics architecture type is the Wayland architecture, the Weston service is started in the sandbox environment. In an embodiment of the present application, a feasible starting mode is: the current graphic interaction interface (image session interface) is switched to a target virtual terminal through a preset openvt command tool, that is, an independent graphic environment is constructed. The target virtual terminal is a currently idle virtual terminal. In other embodiments, the target virtual terminal can also be switched to through a preset chvt command tool. For example, the command "openvt M" is used to switch to the Mth virtual terminal, and M is the virtual terminal number. In the Linux system, the virtual terminal (VT) is a software mechanism for simulating a physical terminal device, which allows users to open multiple independent text mode session windows on the same computer. Each virtual terminal can be independently logged in, run programs, and does not interfere with each other.

[0038] Further, in the sandbox environment, the Weston service on the target virtual terminal is started, and the specific process is as follows: the Weston compositor is started on the target virtual terminal, a dedicated socket file, i.e., a Wayland socket file, is listened to, and finally the Weston service is started. The dedicated socket file is the only interface for communication with the application program, and the application program under each Wayland architecture performs graphic interaction with the Weston service through the dedicated socket file, so that the Weston service takes over the output of the target virtual terminal as the Wayland display server and provides graphic interface support. The Weston compositor is a reference implementation based on the Wayland protocol, is a lightweight and modular display server, is responsible for managing the graphic output, window rendering and user input (such as mouse, keyboard and touch) in the Linux system, and is one of the core components of the Wayland ecosystem, aiming to replace the traditional Xorg under the X11 architecture. The corresponding path of the socket file is / run / user / 1000 / wayland-1 or / tmp / sandbox / wayland-0.

[0039] After the Weston service is started in the sandbox environment, the Xwayland compatible layer component in the Weston needs to be started, so that the subsequent application programs started in the sandbox environment can be normally started, whether the application programs are under the X11 architecture or under the Wayland architecture; if the Xwayland compatible layer component is not started, only the application programs started in the sandbox environment under the Wayland architecture can be normally started, and the application programs started in the sandbox environment under the X11 architecture cannot be normally started.

[0040] Further, a feasible way to start the Xwayland component in the sandbox environment is to select a currently unoccupied virtual display instance, determine a second number of the unoccupied virtual display instance, establish a binding relationship between the second number and the target virtual terminal, and finally determine the second number associated with the target virtual terminal. Then start the X11 compatibility layer in the sandbox environment, which is represented as Xwayland:Y, where :Y represents the second number. Wherein, starting Xwayland:Y can be understood as starting the Xwayland instance with the second number, which is similar to the logic of starting the Xorg instance with the first number in step S103. Further, after starting the X11 compatibility layer, Xwayland creates a socket file corresponding to the X11 compatibility layer as a communication endpoint for communication with the started application. For example, if the second number is :1, the path of the corresponding socket file is expressed as / tmp / .X11-unix / X1.

[0041] Next, the environment variable of the application started in the sandbox environment is set to a second environment variable, which is represented as: DISPLAY2=:Y; Wherein, DISPLAY2 represents the second environment variable, and :Y represents the second number; it should be noted that the started application specifies to connect to the corresponding Xwayland instance, i.e., the X11 compatibility layer, through the second environment variable. For example, if the second number is ":2", the started application specifies to connect to Xwayland:2 through ":2".

[0042] When the second application is started in the sandbox environment, the second application only interacts with the Weston service in graphics, and the specific process is that the second application connects to the socket file corresponding to the X11 compatibility layer through the second environment variable, and then realizes interaction with the X11 compatibility layer, and the X11 compatibility layer converts the X11 protocol into the Wayland protocol. By taking the X11 compatibility layer as a protocol conversion bridge, the second application finally realizes graphics interaction with the Weston service, which is that the graphics interaction between the Weston service and the second application in the interface corresponding to the second environment variable is displayed in the target virtual terminal (which has a binding relationship with the second number) through the X11 compatibility layer bridge. It should be noted that in the embodiments of the present application, the first application is an application under the X11 architecture, and the second application is an application under the X11 architecture or an application under the Wayland architecture.

[0043] The implementation principle of the method for preventing screen capturing and screen recording in a sandbox under Linux according to an embodiment of the present application is as follows: a sandbox environment is started to isolate each application program under the Linux system environment from the host system, so that the application program started in the sandbox environment runs in an independent space and is difficult to be monitored by an external process. Then, the X11 socket file and the Wayland socket file in the sandbox environment are isolated, so that in the process of graphical interaction with the application program under the X11 architecture or in the process of graphical interaction with the application program under the Wayland architecture, an external process cannot access the communication endpoint related to the graphical interaction, thereby blocking the reading permission of the graphical layer data from the source and reducing the risk of screen capturing and screen recording of the session picture. Further, when the Linux graphical architecture type is the X11 architecture, after the first application program is started, the first application program and the independently started Xorg service instance perform graphical interaction only in the sandbox environment, and the X11 socket file is isolated in advance, so that the external process cannot access the Xorg service instance; when the Linux graphical architecture type is the Wayland architecture, after the second application program is started, the second application program and the independently started Weston service perform graphical interaction only in the sandbox environment, and the Wayland socket file is isolated in advance, so that the external process cannot access the Weston service, so that the graphical rendering and display of the started application program are limited to the inside of the sandbox environment, the external process cannot bypass the sandbox environment to obtain the graphical content in the sandbox, and thus the screen capturing and screen recording path is effectively blocked, and the effect of preventing screen content leakage under Linux is improved.

[0044] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the apparatus embodiments of the present application, please refer to the method embodiments of the present application.

[0045] Please refer to Figure 2 The structure diagram of the device for preventing screen capturing and screen recording in a sandbox under Linux provided by the embodiment of the present application is shown in FIG. 1. The device for preventing screen capturing and screen recording in a sandbox under Linux can be realized by software, hardware or a combination of the two to become all or part of the device. The device includes a sandbox starting module 11, a file isolation module 12, a first interaction module 13 and a second interaction module 14.

[0046] The sandbox starting module 11 is configured to construct and start a sandbox environment based on a Linux system. The file isolation module 12 is configured to isolate the X11 socket file and the Wayland socket file in the sandbox environment and determine the current Linux graphical architecture type. The first interaction module 13 is configured to, if the Linux graphics architecture type is the X11 architecture, start an Xorg service instance in the sandbox environment, and when a first application program isolated in the sandbox environment is started, perform graphics interaction with the first application program through the Xorg service instance. The second interaction module 14 is configured to, if the Linux graphics architecture type is the Wayland architecture, start a Weston service in the sandbox environment, and when a second application program isolated in the sandbox environment is started, perform graphics interaction with the second application program through the Weston service.

[0047] Optionally, the file isolation module 12 is specifically configured to: hide a socket path corresponding to an X11 socket file and a socket path corresponding to a Wayland socket file in the sandbox environment through a sandbox file system of the sandbox environment.

[0048] Optionally, the first interaction module 13 is specifically configured to: select a target virtual display instance from currently unoccupied virtual display instances; start an Xorg service instance in the sandbox environment based on the target virtual display instance.

[0049] Optionally, the first interaction module 13 is specifically configured to: determine a first number corresponding to the target virtual display instance; create an Xorg service instance with a display number of the first number, and start the Xorg service instance in the sandbox environment.

[0050] Optionally, the first interaction module 13 is specifically configured to: determine a first number corresponding to the target virtual display instance; set an environment variable of an application program started in the sandbox environment to a first environment variable according to the first number, the first environment variable being represented as: DISPLAY1=:X; In the formula, DISPLAY1 represents the first environment variable, and :X represents the first number. When the first application program isolated in the sandbox environment is started, perform graphics interaction with the first application program in an interface corresponding to the first environment variable through the Xorg service instance.

[0051] Optionally, the second interaction module 14 is specifically configured to: switch a current graphics interaction interface to a target virtual terminal through openvt, the target virtual terminal being a currently idle virtual terminal; Based on the target virtual terminal, the Weston service under the Wayland architecture is started in the sandbox environment.

[0052] Optionally, as shown in Figure 3 The device further comprises a compatible starting module 15, which is specifically configured to: determine a second number associated with the target virtual terminal; start an X11 compatible layer in the sandbox environment according to the second number, and the X11 compatible layer is represented as Xwayland:Y, wherein :Y represents the second number.

[0053] Optionally, the second interaction module 14 is further configured to: set an environment variable of an application started in the sandbox environment to a second environment variable according to the second number, and the second environment variable is represented as: DISPLAY2=:Y; In the formula, DISPLAY2 represents the second environment variable, and :Y represents the second number. When the second application isolated in the sandbox environment is started, the Weston service performs graphical interaction with the second application on an interface corresponding to the second environment variable.

[0054] It should be noted that the Linux sandbox anti-screen capture and anti-screen recording device provided in the above embodiments is only used as an example to divide the above functions into different functional modules when the Linux sandbox anti-screen capture and anti-screen recording method is executed. In actual applications, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the Linux sandbox anti-screen capture and anti-screen recording device and the Linux sandbox anti-screen capture and anti-screen recording method provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0055] The application also discloses a computer readable storage medium, and the computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the Linux sandbox anti-screen capture and anti-screen recording method provided in the above embodiments.

[0056] The computer program can be stored in a computer readable medium, the computer program includes computer program code, the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc., the computer readable medium includes any entity or device, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc., which can carry computer program code, it should be noted that the computer readable medium includes but is not limited to the above components.

[0057] The computer readable storage medium stores the Linux in-box screen capture and recording prevention method of the above embodiment in the computer readable storage medium, and is loaded and executed on the processor to facilitate the storage and application of the method.

[0058] The computer readable storage medium stores the computer program, and the computer program is loaded and executed by the processor to realize the Linux in-box screen capture and recording prevention method.

[0059] The electronic device can be a desktop computer, a notebook computer or a cloud server, and the electronic device includes but is not limited to a processor and a memory, for example, the electronic device can also include an input / output device, a network access device and a bus, etc.

[0060] The processor can be a central processing unit (CPU), of course, according to the actual use, other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), ready programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., the general-purpose processor can be a microprocessor or any conventional processor, etc., and the present application does not limit this.

[0061] The memory can be an internal storage unit of the electronic device, for example, a hard disk or a memory of the electronic device, or an external storage device of the electronic device, for example, a plug-in hard disk, a smart memory card (SMC), a secure digital card (SD) or a flash memory card (FC) equipped on the electronic device, etc., and the memory can also be a combination of the internal storage unit and the external storage device of the electronic device, the memory is used to store computer programs and other programs and data required by the electronic device, and the memory can also be used to temporarily store data that has been output or will be output, and the present application does not limit this.

[0062] The Linux-based in-box screen interception and recording prevention method of the above-mentioned embodiment is stored in the memory of the electronic device and loaded and executed on the processor of the electronic device, facilitating use.

[0063] The above merely describes exemplary embodiments of the present disclosure, and cannot limit the scope of the present disclosure. Any equivalent changes and modifications made in accordance with the teachings of the present disclosure are still within the scope of the present disclosure. The present application is intended to cover any variations, uses, or adaptive changes of the present disclosure that follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field not described in the present disclosure. The scope and spirit of the present disclosure are defined by the claims.

Claims

1. A method for preventing screen capture and screen recording in a Linux sandbox, characterized in that, The method comprises: constructing a sandbox environment based on a Linux system and starting the sandbox environment; isolating X11 socket files and Wayland socket files in the sandbox environment and determining a current Linux graphics architecture type; if the Linux graphics architecture type is an X11 architecture, starting an Xorg service instance in the sandbox environment and, when a first application program isolated in the sandbox environment is started, performing graphics interaction with the first application program through the Xorg service instance; if the Linux graphics architecture type is a Wayland architecture, starting a Weston service in the sandbox environment and, when a second application program isolated in the sandbox environment is started, performing graphics interaction with the second application program through the Weston service.

2. The method for preventing screen capture and screen recording in a Linux sandbox according to claim 1, characterized in that, The isolation of the X11 socket files and the Wayland socket files in the sandbox environment specifically comprises: performing hiding processing on socket paths corresponding to the X11 socket files and socket paths corresponding to the Wayland socket files in the sandbox environment through a sandbox file system of the sandbox environment.

3. The method of claim 1, wherein the method comprises: The starting of the Xorg service instance in the sandbox environment specifically comprises: selecting a target virtual display instance from currently unoccupied virtual display instances; starting an Xorg service instance in the sandbox environment based on the target virtual display instance.

4. The method of claim 3, wherein the method is characterized by, The starting of the Xorg service instance in the sandbox environment based on the target virtual display instance specifically comprises: determining a first number corresponding to the target virtual display instance; creating an Xorg service instance with a display number of the first number and starting the Xorg service instance in the sandbox environment.

5. The method of claim 3, wherein the method further comprises: The graphics interaction with the first application program through the Xorg service instance when the first application program isolated in the sandbox environment is started specifically comprises: determining a first number corresponding to the target virtual display instance; setting an environment variable of an application program started in the sandbox environment to a first environment variable according to the first number, the first environment variable being represented as: DISPLAY1=:X; in the formula, DISPLAY1 represents the first environment variable, and :X represents the first number; performing graphics interaction with the first application program in an interface corresponding to the first environment variable through the Xorg service instance when the first application program isolated in the sandbox environment is started.

6. The method for preventing screen capture and screen recording in a Linux sandbox according to claim 1, characterized in that, The starting of the Weston service in the sandbox environment specifically comprises: switching a current graphics interaction interface to a target virtual terminal through openvt, the target virtual terminal being a currently idle virtual terminal; starting a Weston service under a Wayland architecture in the sandbox environment based on the target virtual terminal.

7. The method of claim 6, wherein the method is characterized by, The second application program is isolated in the sandbox environment, and when the second application program is started, graphical interaction with the second application program through the Weston service is further included. A second number associated with the target virtual terminal is determined. An X11 compatibility layer is started in the sandbox environment according to the second number, and the X11 compatibility layer is represented as Xwayland:Y, wherein :Y represents the second number. The second application program is isolated in the sandbox environment, and when the second application program is started, graphical interaction with the second application program through the Weston service is further included. According to the second number, an environment variable of the application program started in the sandbox environment is set as a second environment variable, and the second environment variable is represented as: DISPLAY2=:Y; In the formula, DISPLAY2 represents the second environment variable, and :Y represents the second number. When the second application program is started in the sandbox environment, graphical interaction with the second application program is performed on an interface corresponding to the second environment variable through the Weston service.

8. An anti-screen capture and anti-recording screen device in a Linux sandbox, characterized in that, Comprise: A sandbox starting module (11) is configured to construct a sandbox environment and start the sandbox environment based on a Linux system; A file isolation module (12) is configured to isolate X11 socket files and Wayland socket files in the sandbox environment, and determine a current Linux graphics architecture type; A first interaction module (13) is configured to start an Xorg service instance in the sandbox environment if the Linux graphics architecture type is an X11 architecture, and perform graphical interaction with a first application program through the Xorg service instance when the first application program is started in the sandbox environment; A second interaction module (14) is configured to start a Weston service in the sandbox environment if the Linux graphics architecture type is a Wayland architecture, and perform graphical interaction with a second application program through the Weston service when the second application program is started in the sandbox environment.

9. A computer-readable storage medium having stored therein a computer program, characterized in that, The computer program is loaded and executed by the processor, and the method of any one of claims 1-7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, The processor loads and executes the computer program, and the method of any one of claims 1-7 is implemented.