User-mode file management and control method and system, storage medium and equipment
Through the user-state file control method, using file header information to judge and execute file processing instructions, the file type permission control and encryption of mobile terminals is realized, the problems of data leakage and permission management in the existing technology are solved, and the file control is improved Convenience and efficiency.
Patent Information
- Application Number
- CN202411228585.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-06
AI Technical Summary
The file management technology of existing mobile terminals is complex and has poor stability. Ordinary application developers cannot make kernel modifications, resulting in high risk of data leakage and the file kernel encryption scheme fails to effectively control read and write permissions.
Using user-state file control methods, obtain file processing instructions, read file header information to determine file type, execute matching file processing instructions, including encryption and permission control, avoid file information leakage, and perform file content reading and writing. Permission checksum number control.
It realizes file control without kernel-level modification of terminal manufacturers, which is convenient and effective to avoid file information leakage, and has customized encryption algorithms and file modification history traceability functions, improving file control efficiency.
Smart Images

Figure CN119089472A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of file control, and in particular, relates to a user-mode file control method, system, storage medium and device. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] In the process of processing files on existing mobile terminals, for example, document files created by WPS are stored in the logical SD card and can be arbitrarily exported, modified, read and written, etc. Therefore, while mobile terminal data processing provides convenience for users, it also greatly increases the risk of data leakage.
[0004] At present, the file control technology commonly used by the Android platform involves Linux kernel modification, which is relatively complex, has poor stability, and is difficult to develop. Ordinary application developers cannot modify the kernel, so both the device and the Android system need to be customized by the terminal manufacturer.
[0005] Manufacturers usually use file kernel encryption to deal with file loss, but because the read and write permissions of specific business applications are not controlled, applications with decryption capabilities can read and write files that should not be opened. Even if ordinary application developers use custom encryption files to encrypt file content, the above problems still exist. Summary of the invention
[0006] In order to solve the above technical problems, the present invention provides a user-mode file management method and system, which does not require terminal manufacturers to perform kernel-level modifications, and the file management is convenient and can avoid the leakage of file information.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] A first aspect of the present invention provides a user-mode file management method.
[0009] In one or more embodiments, a user-mode file management method is provided, including:
[0010] Get file processing instructions;
[0011] Read the file header information of the file to be operated, determine the type of the file to be operated, and then determine whether to execute the file processing instruction:
[0012] When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority;
[0013] When the type of the file to be operated is a common file, the file processing instruction is directly executed.
[0014] As an implementation method, the construction process of the file to be operated is:
[0015] Determine whether to generate a control file based on the set strategy. If so, write the header information of the control file, and then encrypt the actual content of the control file before writing it; if not, write it as a normal file.
[0016] As an implementation method, when the type of the file to be operated is a control file, the file header information is described by both a fixed file header and a variable-length file header. The fixed file header is used to describe the attribute information of the control file, and the variable-length file header is used to describe the information of the allowed operation process; the content of the control file is encrypted according to the encryption attributes and then saved.
[0017] As an implementation mode, the length of the variable-length file header is stored in the fixed file header to determine the offset of the stored content when the process is opened.
[0018] As an implementation method, the fixed file includes a header version, a magic word of a control type, an encryption attribute, a number of times the file is allowed to be read and written, a length of a permission attribute, and a hash value of the permission attribute;
[0019] As an implementation method, the variable-length file header includes a hash value of the allowed operation process.
[0020] As an implementation mode, when the type of the file to be operated is a control file, during the content reading process of the control file, firstly, it is determined whether the current file can be opened by the current process according to the control information;
[0021] If there is no permission, an error is returned;
[0022] If there is permission, determine whether the number of reads has been exceeded;
[0023] If the number of reads exceeds the limit, an error is returned after erasing the file contents;
[0024] If the number of reads is not exceeded, the read position is corrected, and then the file content is decrypted according to the key to return the actual file content.
[0025] As an implementation mode, when the type of the file to be operated is a control file, during the process of writing the content of the control file, it is determined whether the writing times are exceeded, and if the writing times are exceeded, the writing cannot be performed;
[0026] If the number of write times is not exceeded, the comparison result between the current process and the hash value of the process allowed to open is used to determine whether the current process is a process that is allowed to write;
[0027] If the current process is not a process that allows writing, then return;
[0028] If the current process is a process that allows writing, the modification record is updated during the writing process, and this record is included in the modification history and recorded in the file header.
[0029] A second aspect of the present invention provides a user-mode file management and control system.
[0030] In one or more embodiments, a user-mode file management system includes:
[0031] A file processing instruction acquisition module, which is used to acquire file processing instructions;
[0032] The file processing instruction response module is used to read the file header information of the file to be operated, determine the type of the file to be operated, and then determine whether to execute the file processing instruction:
[0033] When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority;
[0034] When the type of the file to be operated is a common file, the file processing instruction is directly executed.
[0035] A third aspect of the present invention provides an electronic device.
[0036] In one or more embodiments, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the user-mode file management method described above are implemented.
[0037] A fourth aspect of the present invention provides a computer-readable storage medium.
[0038] In one or more embodiments, a computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the user-mode file management method described above.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] (1) The user-mode file control method of the present invention determines whether to execute the file processing instruction according to the type of the file to be operated. It does not require the terminal manufacturer to perform kernel-level modifications and can be completed by ordinary application developers. In addition, it determines whether the file processing instruction has matching permissions based on the control information of the controlled file. File control is convenient and can avoid leakage of file information.
[0041] (2) The files of the present invention are encrypted and stored, and the encryption algorithm can be customized; the file read and write times information is provided, and the number of times the file is opened / modified can be controlled; the file modification history also facilitates tracing the history of file modification, thereby improving the efficiency of file management and control. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0043] Figure 1 It is a flowchart of a user-mode file management method according to an embodiment of the present invention;
[0044] Figure 2 is a schematic diagram of a control file header according to an embodiment of the present invention;
[0045] Figure 3 Schematic diagram of the construction process of the file to be operated in an embodiment of the present invention
[0046] Figure 4 is a schematic diagram of a file reading process according to an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of the structure of a user-mode file management and control system according to an embodiment of the present invention;
[0048] Figure 6 It is a schematic diagram of the structure of a file processing instruction acquisition module and a file processing instruction response module in an embodiment of the present invention;
[0049] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0051] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0052] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0053] Terminology explanation:
[0054] File control is the abbreviation of file management and control, which refers to multi-faceted control over file circulation, file storage, file reading and writing, etc.
[0055] File circulation refers to recording the information of files being modified by processes or applications, which can well trace the modification history of files;
[0056] File storage refers to storage using encryption technology;
[0057] File read and write permission control means that only specified processes or applications can have read and write permissions.
[0058] Embodiment 1
[0059] Figure 1 FIG. 1 is a flowchart of a user-mode file management method in an embodiment of the present invention. Figure 1 The user-mode file management method in the embodiment shown may include:
[0060] S101, obtaining a file processing instruction;
[0061] S102, reading the file header information of the file to be operated, determining the type of the file to be operated, and then determining whether to execute the file processing instruction:
[0062] When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority;
[0063] When the type of the file to be operated is a common file, the file processing instruction is directly executed.
[0064] The user-mode file control method of this embodiment determines whether to execute the file processing instruction according to the type of the file to be operated. It does not require the terminal manufacturer to perform kernel-level modifications and can be completed by ordinary application developers. In addition, it determines whether the file processing instruction has matching permissions based on the control information of the controlled file. File control is convenient and can avoid leakage of file information.
[0065] In step S101, the file processing instructions include but are not limited to file transfer, file storage, file reading and writing, etc.
[0066] In the specific implementation process, the I / O function specified in the libc library function can be intercepted through the hook technology to obtain the file processing instruction. Among them, hook is a system mechanism provided in Windows to replace the "interrupt" under DOS, which is translated into Chinese as "hook" or "hook". After hooking a specific system event, once the hooked event occurs, the program that hooks the event will receive a notification from the system, and the program can respond to the event in the first time.
[0067] Specifically, the API interface functions that need to be hooked for file operations include:
[0068] File open: openat function;
[0069] File copying: dup function, dup2 function, dup3 function, fcntl function;
[0070] File closing: close function;
[0071] File reading: read function, pread function, pread64 function;
[0072] File writing: write function, pwrite function, pwrite64 function;
[0073] File interception: ftruncate64 function;
[0074] Memory mapping: mmap function, unmap function, sync function;
[0075] File status: stat function, fstatat function.
[0076] In step S102, if Figure 2 As shown, the construction process of the file to be operated is:
[0077] Determine whether to generate a control file based on the set strategy. If so, write the header information of the control file, and then encrypt the actual content of the control file before writing it; if not, write it as a normal file.
[0078] During the specific implementation process, when the type of the file to be operated is a control file, the file header information is described by both a fixed file header and a variable-length file header. The fixed file header is used to describe the attribute information of the control file, and the variable-length file header is used to describe the information of the allowed operation process; the content of the control file is encrypted according to the encryption attribute and then saved (it can also be plain text).
[0079] like Figure 3 As shown, the fixed file includes the header version, the magic word of the control type (used to quickly determine whether it is a controlled file), encryption attributes (including encryption keys, encryption algorithms), the number of times the file is allowed to read and write, the length of the permission attribute, and the hash value of the permission attribute;
[0080] Specifically, the fixed file header is hashed, and the generated 4-byte hash value is saved in the control header summary and used as a detailed judgment of the control file.
[0081] The variable-length file header includes a hash value of an allowed operation process. During the file operation process, a judgment is made as to whether the current process is an allowed operation process. If the hash values are different, the operation is interrupted.
[0082] For example, the fixed file header length is 43 bytes, and the length of the variable-length file header is stored in the fixed file header, so when the process is opened, the offset of the actual stored content can be known.
[0083] In the specific implementation process, during the open function process of opening the file, the file header information is read to determine whether it is a file with control information. If so, the relevant information is read for backup. If not, the subsequent operations are processed as ordinary files.
[0084] When the type of the file to be operated is a control file, such as Figure 4 As shown, in the process of reading the content of the control file, firstly, according to the control information, it is determined whether the current file can be opened by the current process;
[0085] If there is no permission, an error is returned;
[0086] If there is permission, determine whether the number of reads has been exceeded;
[0087] If the number of reads exceeds the limit, an error is returned after erasing the file contents;
[0088] If the number of reads is not exceeded, the read position is corrected, and then the file content is decrypted according to the key to return the actual file content.
[0089] The content offset is determined according to the length of the variable-length file header, and the reading position is then corrected.
[0090] When the type of the file to be operated is a control file, during the process of writing the content of the control file, it is determined whether the writing times are exceeded. If the writing times are exceeded, the file cannot be written;
[0091] If the number of write times is not exceeded, the comparison result between the current process and the hash value of the process allowed to open is used to determine whether the current process is a process that is allowed to write;
[0092] If the current process is not a process that allows writing, then return;
[0093] If the current process is a process that allows writing, the modification record is updated during the writing process, and this record is included in the modification history and recorded in the file header.
[0094] Embodiment 2
[0095] Figure 5 is a schematic diagram of a user-mode file management system structure in an embodiment of the present invention. Figure 1 The user-mode file control method corresponds to Figure 5 As shown, the user-mode file management and control system in this embodiment may include:
[0096] A file processing instruction acquisition module 501, which is used to acquire a file processing instruction;
[0097] The file processing instruction response module 502 is used to read the file header information of the file to be operated, determine the type of the file to be operated, and then determine whether to execute the file processing instruction:
[0098] When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority;
[0099] When the type of the file to be operated is a common file, the file processing instruction is directly executed.
[0100] exist Figure 6 In the example, the file processing instruction acquisition module 501 can be implemented using a HOOK module.
[0101] In the specific implementation process, the file processing instruction response module 502 includes but is not limited to a policy control module, an encryption and decryption module, a process authority control module, a read and write times control module and a file modification record module;
[0102] The policy control module is configured as follows:
[0103] Determine whether to generate a control file based on the set strategy. If so, write the header information of the control file, and then encrypt the actual content of the control file before writing it; if not, write it as a normal file.
[0104] The encryption and decryption modules are configured as follows:
[0105] The content of the control file is encrypted according to the encryption attribute and then saved.
[0106] The process permission control module is configured as follows:
[0107] Based on the comparison result between the current process and the hash value of the process allowed to open, it is determined whether the current process is a process that is allowed to write.
[0108] The read and write times control module is configured as:
[0109] During the reading and writing process of the content of the control file, control the number of read and write times.
[0110] The file modification logging module is configured as follows:
[0111] During the writing process, the modification record is updated, the record is included in the modification history and recorded in the file header.
[0112] It should be noted here that the various modules in the user-mode file management and control system of this embodiment correspond one-to-one to the various steps in Example 1, and the specific implementation process is the same, which will not be described in detail here.
[0113] Embodiment 3
[0114] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, Figure 1 The steps of the user mode file control method are shown.
[0115] Reference Figure 7 , a schematic diagram of an electronic device is given. It should be noted that, Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0116] like Figure 7 As shown, electronic device 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage portion 708 into a random access memory (RAM) 703. In RAM 703, various programs and data required for system operation are also stored. Central processing unit 701, ROM 702 and RAM 103 are connected to each other via a bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0117] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a local area network (LAN) card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0118] When the central processing unit 701 in the electronic device of this embodiment executes the program, the following is achieved: Figure 1 The steps in the user mode file control method shown.
[0119] Embodiment 4
[0120] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, Figure 1 The steps of the user mode file control method are shown.
[0121] in, Figure 1 The computer program instructions corresponding to the method shown may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0122] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0123] Embodiment 5
[0124] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. This embodiment provides a computer program product, which includes a computer program carried on a computer readable medium, the computer program including a computer program for executing Figure 1 In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 709, and / or installed from a removable medium 711. When the computer program is executed by the central processing unit 701, various functions defined in the apparatus of the present application are executed.
[0125] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A user-mode file management method, characterized in that: include: Get file processing instructions; Read the file header information of the file to be operated, determine the type of the file to be operated, and then determine whether to execute the file processing instruction: When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority; When the type of the file to be operated is a common file, the file processing instruction is directly executed.
2. The user-mode file management method according to claim 1, characterized in that: The construction process of the file to be operated is: Determine whether to generate a control file based on the set strategy. If so, write the header information of the control file, and then encrypt the actual content of the control file before writing it; if not, write it as a normal file.
3. The user-mode file control method according to claim 1, characterized in that: When the type of the file to be operated is a control file, the file header information is described by both a fixed file header and a variable-length file header. The fixed file header is used to describe the attribute information of the control file, and the variable-length file header is used to describe the information of the allowed operation process; the content of the control file is encrypted according to the encryption attribute and then saved.
4. The user-mode file control method according to claim 3, characterized in that: The length of the variable-length file header is stored in the fixed file header to determine the offset of the stored content when the process is opened.
5. The user-mode file control method according to claim 3, characterized in that: The fixed file contains the header version, the magic word of the control type, the encryption attribute, the number of times the file is allowed to be read and written, the length of the permission attribute, and the hash value of the permission attribute; Or / and, the variable-length file header includes a hash value of the allowed operation process.
6. The user-mode file control method according to claim 1, characterized in that: When the type of the file to be operated is a control file, during the content reading process of the control file, firstly, it is determined whether the current file can be opened by the current process according to the control information; If there is no permission, an error is returned; If there is permission, determine whether the number of reads has been exceeded; If the number of reads exceeds the limit, an error is returned after erasing the file contents; If the number of reads is not exceeded, the read position is corrected, and then the file content is decrypted according to the key to return the actual file content.
7. The user-mode file management method according to claim 1, characterized in that: When the type of the file to be operated is a control file, during the process of writing the content of the control file, it is determined whether the writing times are exceeded. If the writing times are exceeded, the file cannot be written; If the number of write times is not exceeded, the comparison result between the current process and the hash value of the process allowed to open is used to determine whether the current process is a process that is allowed to write; If the current process is not a process that allows writing, then return; If the current process is a process that allows writing, the modification record is updated during the writing process, and this record is included in the modification history and recorded in the file header.
8. A user-mode file management method, characterized in that: include: A file processing instruction acquisition module, which is used to acquire file processing instructions; The file processing instruction response module is used to read the file header information of the file to be operated, determine the type of the file to be operated, and then determine whether to execute the file processing instruction: When the type of the file to be operated is a controlled file, reading the control information of the file to be operated, judging whether the file processing instruction has matching authority according to the control information, and executing the file processing instruction with matching authority; When the type of the file to be operated is a common file, the file processing instruction is directly executed.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the user-mode file management method as described in any one of claims 1 to 7 are implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the user-mode file management method as described in any one of claims 1-7 are implemented.
