Power system data file tamper-proofing and restoring method, system, equipment and medium

By calculating and storing the initial hash value of the power system data file and restoring it when the content changes, the problem that the power system data file is prone to tampering is solved, and the files are tamper-proof and restored, ensuring the safety and reliability of the power grid operation.

CN119720291APending Publication Date: 2025-03-28NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411900010.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

Power system data files are susceptible to tampering attacks, resulting in safety risks in the power grid operation.

Method used

By calculating the initial content hash value of the file to be protected and storing it to a preset database, periodically monitor whether the file exists, and delete the tampered file when the content hash value changes and restore the original file from the database.

Benefits of technology

It effectively prevents file tampering, ensures the integrity and reliability of power grid data, and reduces operational security risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720291A_ABST
    Figure CN119720291A_ABST
Patent Text Reader

Abstract

The invention discloses an electric power system data file tamper-proofing and restoring method, system and device and a medium, and relates to the technical field of electric power system security, and the method comprises the following steps: calculating an initial content hash value of a to-be-protected file; storing the file name, the file content, the absolute path and the initial content hash value of the to-be-protected file into a preset database; monitoring whether the to-be-protected file exists or not every preset time interval; if not, restoring the to-be-protected file based on the file name, the file content and the absolute path of the to-be-protected file read from the preset database; if yes, calculating a current content hash value of the to-be-protected file; comparing whether the current content hash value is the same as the initial content hash value or not; and if not, deleting the to-be-protected file, and restoring the to-be-protected file from the preset database. The technical problem that in the prior art, data files of an electric power system are prone to being tampered and attacked is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of power system security, and in particular to a method, system, equipment and medium for preventing tampering and restoring data files in a power system. Background Art

[0002] With the development of computer technology and the strong support of the country for smart grids, files are an important storage medium in power grid operation equipment, and more and more power system data is stored in files. File storage brings great convenience to business applications. At the same time, because files are directly exposed to the operating system, any operating system user can access them and they are vulnerable to tampering attacks. Once the data is tampered with, it will have a fatal impact on the upper-level business applications. Using wrong data for calculation and analysis will bring great security risks to the operation of the power grid. Summary of the invention

[0003] The purpose of the present invention is to provide a method, system, device and medium for preventing tampering and restoring data files in a power system in order to solve at least one of the above technical problems.

[0004] In the first aspect, an embodiment of the present invention provides a method for tamper-proofing and restoring data files of an electric power system, which is applied to an electric power system; the method comprises: calculating an initial content hash value of a file to be protected; the file to be protected is an electric power system data file; storing the file name, file content, absolute path and the initial content hash value of the file to be protected in a preset database; monitoring whether the file to be protected exists at preset time intervals; if not, restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database; if it exists, calculating the current content hash value of the file to be protected; comparing whether the current content hash value is the same as the initial content hash value; if not, deleting the file to be protected, and restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

[0005] Further, calculating the initial content hash value of the file to be protected includes: calculating the initial content hash value of the file to be protected based on the SM3 algorithm or the MD5 algorithm.

[0006] Further, monitoring whether the file to be protected exists at every preset time interval includes: calling an interface to open the file to be protected once at every preset time interval with the file name and absolute path of the file to be protected read from a preset database as parameters.

[0007] Furthermore, the preset time interval includes 50ms.

[0008] In a second aspect, an embodiment of the present invention further provides a power system data file tamper-proof and restoration system, which is applied to a power system; comprising: a calculation module, a storage module, a monitoring module, a comparison module and a restoration module; wherein the calculation module is used to calculate the initial content hash value of the file to be protected; the file to be protected is a power system data file; the storage module is used to store the file name, file content, absolute path and the initial content hash value of the file to be protected in a preset database; the monitoring module is used to monitor whether the file to be protected exists at preset time intervals; the restoration module is used to restore the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database if the file to be protected does not exist; the calculation module is also used to calculate the current content hash value of the file to be protected if the file to be protected exists; the comparison module is used to compare whether the current content hash value is the same as the initial content hash value; the restoration module is also used to delete the file to be protected if the current content hash value is not the same as the initial content hash value, and restore the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

[0009] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method provided in the embodiment of the present invention when executing the computer program.

[0010] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method provided in the embodiment of the present invention is implemented.

[0011] The present invention provides a method, system, device and medium for preventing and restoring data files of an electric power system from being tampered with. By calculating the hash value of the data files of the electric power system in real time and comparing it with the hash value of the original file, detection and restoration of whether the data files of the electric power system have been tampered with can be realized, thereby effectively preventing the problem of files being tampered with, and realizing recovery and restoration after the files have been tampered with, thereby ensuring the safety and reliability of the operation of the power grid, and alleviating the technical problem in the prior art that the data files of the electric power system are easily subject to tampering attacks. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0013] Figure 1 A flow chart of a method for tamper-proofing and restoring data files in a power system provided by an embodiment of the present invention;

[0014] Figure 2 A schematic diagram of a power system data file tamper-proof and restoration system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0016] Embodiment 1

[0017] Figure 1 1 is a flow chart of a method for tamper-proofing and restoring data files in a power system according to an embodiment of the present invention, and the method is applied to a power system. Figure 1 As shown, the method specifically comprises the following steps:

[0018] Step S102, calculating the initial content hash value of the file to be protected; the file to be protected is a power system data file.

[0019] Step S104: store the file name, file content, absolute path and initial content hash value of the file to be protected in a preset database.

[0020] Step S106, monitoring whether the file to be protected exists at every preset time interval; if not, executing step S108; if exists, executing step S110.

[0021] Step S108, restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

[0022] Step S110, calculating the current content hash value of the file to be protected.

[0023] Step S112, compare the current content hash value with the initial content hash value to see if they are the same; if they are not the same, execute step S114; if they are the same, return to execute step S106 and continue to monitor the file to be protected.

[0024] Step S114, deleting the file to be protected, and restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

[0025] In an optional implementation provided by an embodiment of the present invention, the calculation of the hash value in step S102 includes: calculating the initial content hash value of the file to be protected based on the SM3 algorithm or the MD5 algorithm.

[0026] Specifically, step S104 includes: executing a database insert SQL statement to store the file name, file content, absolute path and initial content hash value of the file to be protected in a preset database.

[0027] Specifically, step S106 includes: calling an interface for opening the file to be protected once at a preset time interval with the file name and absolute path of the file to be protected read from the preset database as parameters. For example, the preset time interval includes 50ms.

[0028] In an optional implementation provided by an embodiment of the present invention, the hash value calculation in step S110 includes: calculating the current content hash value of the file to be protected based on the SM3 algorithm or the MD5 algorithm.

[0029] Specifically, in step S114, deleting the file to be protected is implemented as follows: calling a file deletion interface through a monitoring program to delete the file to be protected.

[0030] Specifically, the implementation of restoring the file to be protected in step S108 and step S114 is as follows: using the file name and absolute path of the file to be protected read from the preset database as parameters, calling the new file interface to create a new blank file, and then using the file content of the file to be protected read from the preset database as a parameter, calling the write file interface to write the file content into the blank file, thereby obtaining the restored file to be protected.

[0031] From the above description, it can be seen that an embodiment of the present invention provides a method for preventing and restoring power system data files from being tampered with, by calculating the hash value of the power system data file in real time and comparing it with the hash value of the original file, it can detect and restore whether the power system data file has been tampered with, effectively preventing the problem of file tampering, and can restore the file after it has been tampered with, thereby ensuring the safety and reliability of power grid operation, and alleviating the technical problem that power system data files are susceptible to tampering attacks in the prior art.

[0032] Embodiment 2

[0033] The embodiment of the present invention provides a method for preventing tampering and restoring data files in a power system. The specific implementation method is as follows:

[0034] (1) Use the SM3 algorithm to calculate the hash value of the power system data file;

[0035] (2) The file name, file path, file content, and hash value are stored in the database by executing the database insert SQL statement;

[0036] (3) The timer calls the file opening interface every 50 ms with the file name and absolute path of the file to be protected read from the preset database as parameters to determine whether the power system data file exists;

[0037] (4) If the file exists, calculate the file hash value and compare it with the file hash value in the database. If they are the same, continue to monitor the file; if they are different, delete the tampered file and restore the file using the file name, file path, and file content in the database;

[0038] (5) If the file does not exist, restore the file using the file name, file path, and file content in the database.

[0039] Embodiment 3

[0040] Figure 2 Schematic diagram of a power system data file tamper-proof and restoration system provided according to an embodiment of the present invention. Figure 2 As shown, the system includes: a calculation module 10, a storage module 20, a monitoring module 30, a comparison module 40 and a restoration module 50.

[0041] Specifically, the calculation module 10 is used to calculate the initial content hash value of the file to be protected; the file to be protected is a power system data file.

[0042] The storage module 20 is used to store the file name, file content, absolute path and initial content hash value of the file to be protected in a preset database.

[0043] The monitoring module 30 is used to monitor whether the file to be protected exists at a preset time interval.

[0044] The restoration module 50 is used to restore the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database if the file to be protected does not exist.

[0045] The calculation module 10 is further configured to calculate a current content hash value of the file to be protected if the file to be protected exists.

[0046] The comparison module 40 is used to compare whether the current content hash value is the same as the initial content hash value.

[0047] The restoration module 50 is further configured to delete the file to be protected if the current content hash value is different from the initial content hash value, and restore the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

[0048] The present invention further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method provided in the embodiment of the present invention when executing the computer program.

[0049] The present invention also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a processor, the method provided in the embodiment of the present invention is implemented.

[0050] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

[0051] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. A method for preventing tampering and restoring data files in a power system, characterized in that: Applied to a power system; the method comprises: Calculating an initial content hash value of a file to be protected; the file to be protected is a power system data file; The file name, file content, absolute path and initial content hash value of the file to be protected are stored in a preset database; Monitoring whether the file to be protected exists at preset time intervals; If it does not exist, restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database; If it exists, calculate the current content hash value of the file to be protected; Compare the current content hash value with the initial content hash value to see if they are the same; If they are not the same, the file to be protected is deleted, and the file to be protected is restored based on the file name, file content and absolute path of the file to be protected read from the preset database.

2. The method according to claim 1, characterized in that: Calculating the initial content hash value of the file to be protected includes: calculating the initial content hash value of the file to be protected based on the SM3 algorithm or the MD5 algorithm.

3. The method according to claim 1, characterized in that: Monitoring whether the file to be protected exists at every preset time interval includes: calling an interface to open the file to be protected once at every preset time interval with the file name and absolute path of the file to be protected read from the preset database as parameters.

4. The method according to claim 1, characterized in that: The preset time interval includes 50ms.

5. A power system data file tamper-proof and restoration system, characterized in that: Applied to power system; including: calculation module, storage module, monitoring module, comparison module and restoration module; wherein, The calculation module is used to calculate the initial content hash value of the file to be protected; the file to be protected is a power system data file; The storage module is used to store the file name, file content, absolute path and initial content hash value of the file to be protected in a preset database; The monitoring module is used to monitor whether the file to be protected exists at a preset time interval; The restoration module is used for restoring the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database if the file to be protected does not exist; The calculation module is further configured to calculate a current content hash value of the file to be protected if the file to be protected exists; The comparison module is used to compare whether the current content hash value is the same as the initial content hash value; The restoration module is further used to delete the file to be protected if the current content hash value is different from the initial content hash value, and restore the file to be protected based on the file name, file content and absolute path of the file to be protected read from the preset database.

6. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.