Printer pcl file restoration method based on mirror image network flow

By obtaining and parsing printer mirror network traffic and extracting and saving PCL files, the problem that users cannot audit printed files is solved, and the audit function of printer files is realized.

CN118939209APending Publication Date: 2024-11-12SHENSI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411143382.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In some cases, users cannot obtain administrator rights for the print management software, resulting in the inability to audit printed files.

Method used

Audit the printer files by obtaining printer mirror network traffic, reorganizing and parsing HTTP protocol data streams, extracting PCL file contents, and saving them as files.

Benefits of technology

It allows users to audit the printer's PCL files without administrator permissions, and restore and audit files through the network traffic level, solving the problem that users cannot audit printed files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939209A_ABST
    Figure CN118939209A_ABST
Patent Text Reader

Abstract

The invention discloses a printer pcl file restoration method based on mirror image network traffic, and belongs to the technical field of computers.The method comprises the steps that mirror image port traffic is collected, data stream recombination, protocol recognition and protocol deep analysis are conducted on the mirror image port traffic, firstly, printer traffic characteristics are recognized, the data traffic is judged, and printer data are transmitted; the method comprises the following steps: acquiring a data flow of a user host, then judging whether a printed file in the data flow is described by using a PCL language, and finally analyzing and restoring a printer PCL file through a detailed protocol. After the communication flow of the user host and the printer is captured based on a mirror port and the PCL file is restored, the restored PCL file can be converted into a PDF format file through open source tools such as GhostPCL and the like; according to the method, a brand new thought is adopted, namely, the printer file is audited through the network flow level, the PCL description file of the printer is restored, and a user is allowed to audit the file printed by the printer from the network flow side.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer technology, and in particular relates to a printer PCL file restoration method based on mirrored network traffic. Background Art

[0002] PCL, short for Printer Command Language, is a printer page description language introduced by HP in the 1970s for its laser printer products. It has now become an industry standard.

[0003] PCL commands are embedded in the print task data stream, quickly translating the application output into high-quality, device-specific rasterized images. The computer is connected to the printer via a network. When the user initiates a print task, the driver will translate the printed pictures, documents, etc. into a PCL language description file data stream through PCL commands and transmit it to the printer to complete the print task.

[0004] With the rapid development of information technology, printers are often attacked, making the security issues of printers more prominent. Therefore, it is particularly important to audit the legality and compliance of printed documents. The current audit method usually uses print management software to record the detailed information of each print, including print time, printer, and printed documents. Administrators can audit and monitor these records to achieve comprehensive management of printed content.

[0005] However, in some special cases, users may not be able to obtain administrator privileges for the print management software and are unable to audit printed files. Summary of the invention

[0006] In order to solve the problems raised in the above background technology, the present invention provides a printer pcl file restoration method based on mirrored network traffic to solve the problem that in some special cases, users may not be able to obtain the administrator privileges of the printing management software and cannot audit the printed files.

[0007] To achieve the above object, the present invention provides the following technical solutions: A printer pcl file restoration method based on mirrored network traffic comprises the following steps: S1: Get the HTTP information of the printer mirror TCP data stream. If the acquisition is successful, go to S2. If the acquisition is unsuccessful, go to S9. S2: Get the value of the boundary separator of the HTTP information and assign it to the string variable b_str, and enter S3; S3: Get the request message body of the HTTP information, and use "--+$b_str+\r\n" as the split character to split the HTTP request message body into three parts; S4: Get the third part of the HTTP request message body after cutting, and assign the value of this part of the message body to the variable data; S5: In the first 1000 bytes of the variable data, match the feature "@PJL SET JOBNAME=*\r\n". If the match succeeds, obtain the data payload between "JOBNAME=" and "\r\n" and assign it to the variable file_name. Otherwise, assign "unknown" to file_name. S6: Read all data in variable data, obtain the data load between the features “%-12345X@PJL JOB\r\n” and “%-12345X@PJLEOJ\r\n”, and assign it to pcl_data; S7: Get the response header information of the HTTP information, and determine whether the response status code is "200 OK". If so, go to S8; if not, go to S9; S8: Write the pcl_data load information to the disk and save it as a file with the suffix .pcl. The file name is the value assigned to file_name. The file is restored successfully and enters S9; S9: End the current task and exit the program.

[0008] Preferably, S1 is specifically: S1.1: Get the network data stream of the printer's mirror port and determine whether the network data stream is a TCP data stream. If so, reassemble all the data packets of the TCP data stream. If reassembly is complete, proceed to S1.2. Otherwise, proceed to S9. S1.2: Get the reorganized data and determine whether it is HTTP protocol. If so, go to S2, otherwise go to S9.

[0009] Preferably, S2 is specifically: S2.1: Get the HTTP request method of the reorganized data, and determine whether the request method is POST. If so, proceed to S2.2, otherwise proceed to S9; S2.2: Get the User-Agent of the HTTP request for the reorganized data, and determine whether the Value of the User-Agent is WSDAPI. If so, proceed to S2.3, otherwise proceed to S9; S2.3: Get the Content-Description of the HTTP request, and determine whether the Value of the Content-Description contains the keyword "WSDAPI". If so, go to S2.4, otherwise go to S9; S2.4: Get the Content-Type of the HTTP request and determine whether the Value of the Content-Type contains the "boundary=" string feature. If so, proceed to S2.5; otherwise, proceed to S9. S2.5: Get the value of the boundary delimiter and assign it to the string variable b_str, and enter S3.

[0010] Preferably, the printer pcl file restoration method further includes S0: determining whether the length of data is greater than 1500 bytes, if so, proceeding to the next step, otherwise proceeding to S9; S0 is provided between S4 and S5.

[0011] Preferably, the printer pcl file restoration method further includes S0.1: Condition 1: Read the first 200 bytes of the variable data, which contains the feature "%-12345X@PJL JOB\r\n"; Condition 2: Read the first 1000 bytes of data, which contain the feature "@PJL ENTER LANGUAGE=PCLXL"; When any one of condition 1 and condition 2 is not satisfied, go to S9; when both condition 1 and condition 2 are satisfied, go to S5; S0.1 is set between S0 and S5.

[0012] Preferably, the printer pcl file restoration method further includes S0.2: reading the last 200 bytes of data, and determining whether the last 200 bytes contain the feature "%-12345X@PJL EOJ\r\n", if so, proceeding to S6, otherwise proceeding to S9; S0.2 is set between S5 and S6.

[0013] Compared with the prior art, the present invention has the following beneficial effects: After this application captures the communication traffic between the user host and the printer based on the mirror port and restores the PCL file, the restored PCL file can be converted into a PDF format file through open source tools such as GhostPCL. This application uses a new idea, that is, to audit printer files at the network traffic level, restore the printer's PCL language description file, and allow users to audit files printed by the printer from the network traffic side. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 This is a flowchart of the present application. DETAILED DESCRIPTION

[0015] In order to facilitate those skilled in the art to understand the technical content of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific examples. It should be understood that the specific examples described herein are only used to explain the present invention and are not used to limit the present invention.

[0016] Embodiment 1: like Figure 1 As shown, a printer pcl file restoration method based on mirrored network traffic includes the following steps: A1: Get the network data stream of the printer's mirror port. After the operation is completed, go to A2. A2: Determine whether the current data stream is a TCP stream. If so, reassemble all data packets of the current TCP data stream. After reassembly, proceed to A3. Otherwise, file restoration fails and proceed to A20. A3: Get the data payload after TCP reassembly and determine whether the current data is HTTP protocol. If yes, proceed to A4. Otherwise, file restoration fails and proceed to A20. A4: Get HTTP request header information, perform in-depth analysis on the HTTP protocol header, and proceed to A5; A5: Get the HTTP request method to see if it is POST. If it is, proceed to A6. Otherwise, the file restoration fails and proceed to A20. A6: Get the User-Agent of the HTTP request and determine whether the Value is WSDAPI. If so, proceed to A7. Otherwise, the file restoration fails and proceed to A20. A7: Get the Content-Description of the HTTP request and determine whether the Value contains the keyword "WSDAPI". If so, proceed to A8. Otherwise, the file restoration fails and proceed to A20. A8: Get the Content-Type of the HTTP request and check whether its value contains the "boundary=" string feature. If yes, proceed to A9. Otherwise, the file restoration fails and proceed to A20. A9: Gets the value of the boundary delimiter and assigns it to the string variable b_str. For example, "boundary=aa-bb-cc-dd;", the value of b_str is "aa-bb-cc-dd", and the process goes to A10; A10: Get the HTTP request message body, and use "--+$b_str+\r\n" as the split character to split the HTTP request message body. For example, when the value of b_str is "aa-bb-cc-dd", the split character is "--aa-bb-cc-dd\r\n". After completion, determine whether the HTTP request message body is split into three parts. If yes, proceed to A11. Otherwise, the file restoration fails and proceed to A20. A11: Get the third part of the HTTP request message body after cutting, assign the third part of the message body to the variable data, and then go to A12; A12: Determine whether the length of data is greater than 1500 bytes. If so, proceed to A13. Otherwise, the file restoration fails and proceed to A20. A13: Read the first 200 bytes of data and determine whether the first 200 bytes contain the feature "%-12345X@PJL JOB\r\n". If yes, go to A14; otherwise, the file restoration fails and go to A20. A14: Read the first 1000 bytes of data and determine whether the first 1000 bytes contain the feature "@PJL ENTERLANGUAGE=PCLXL". If yes, go to A15; otherwise, the file restoration fails and go to A20. A15: In the first 1000 bytes of data, match the feature "@PJL SET JOBNAME=*\r\n". If the match succeeds, obtain the data payload between "JOBNAME=" and "\r\n". The payload is the name of the printed file. After obtaining, assign it to the variable file_name. Otherwise, assign "unknown" to file_name. For example, "@PJL SET JOBNAME="test-123.docx"\r\n", the printed file name file_name = "test-123.docx". Go to A16; A16: Read the last 200 bytes of data and determine whether the last 200 bytes contain the feature "%-12345X@PJLEOJ\r\n". If yes, go to A17; otherwise, the file restoration fails and go to A20. A17: Read all data in data, obtain the data load between the features "%-12345X@PJL JOB\r\n" and "%-12345X@PJLEOJ\r\n", assign it to pcl_data, and enter A18; A18: Get HTTP response header information and determine whether the response status code is "200 OK". If yes, go to S19; otherwise, the file restoration fails and go to A20. A19: Write the pcl_data load information to the disk and save it as a file with the .pcl suffix. The printed file name is file_name. The file is restored successfully and the process goes to A20. A20: End the current task and exit the program.

[0017] In this embodiment, A1-A2 is for data flow collection, determining whether the collected data flow is the TCP protocol, and reorganizing the TCP data flow. A3-A7 is for printer protocol identification of the collected TCP data flow load, with the purpose of determining whether the data flow is printer communication flow. A8-A17 is for deep analysis of printer protocol flow, extracting the PCL print file load content translated by the PCL language, and extracting the printed file name at the same time. A18-A19 determines whether the printer prints the file successfully. If successful, the PCL file is written to the disk. If printing is unsuccessful, the PCL file is not restored. A20 is the end of the restoration process and exits.

[0018] The present invention designs a printer PCL file restoration method based on mirrored network traffic. The method collects mirrored port traffic, and performs data stream reorganization, protocol identification, and protocol in-depth analysis on the mirrored port traffic. First, the printer traffic characteristics are identified to determine that the data traffic transmits printer data. Then, it is determined whether the printed file in the data traffic is described in PCL language. Finally, the printer PCL file is restored through detailed protocol analysis.

[0019] After this application captures the communication traffic between the user host and the printer based on the mirror port and restores the PCL file, the restored PCL file can be converted into a PDF format file through open source tools such as GhostPCL. This application uses a new idea, that is, to audit printer files at the network traffic level, restore the printer's PCL language description file, and allow users to audit files printed by the printer from the network traffic side.

Claims

1. A printer pcl file restoration method based on mirrored network traffic, characterized in that: The following steps are involved: S1: Get the HTTP information of the printer mirror TCP data stream. If the acquisition is successful, go to S2. If the acquisition is unsuccessful, go to S9. S2: Get the value of the boundary separator of the HTTP information and assign it to the string variable b_str, and enter S3; S3: Get the request message body of the HTTP information, and use "--+$b_str+\r\n" as the split character to split the HTTP request message body into three parts; S4: Get the third part of the HTTP request message body after cutting, and assign the value of this part of the message body to the variable data; S5: In the first 1000 bytes of the variable data, match the feature "@PJL SET JOBNAME=*\r\n". If the match succeeds, obtain the data payload between "JOBNAME=" and "\r\n" and assign it to the variable file_name. Otherwise, assign "unknown" to file_name. S6: Read all data in variable data, obtain the data load between the features "%-12345X@PJL JOB\r\n" and "%-12345X@PJLEOJ\r\n", and assign it to pcl_data; S7: Get the response header information of the HTTP information and determine whether the response status code is "200 OK". If so, go to S8; if not, go to S9; S8: Write the pcl_data load information to the disk and save it as a file with the suffix .pcl. The file name is the value assigned to file_name. The file is restored successfully and enters S9; S9: End the current task and exit the program.

2. A printer pcl file restoration method based on mirrored network traffic according to claim 1, characterized in that: S1 is specifically: S1.1: Get the network data stream of the printer's mirror port and determine whether the network data stream is a TCP data stream. If so, reassemble all the data packets of the TCP data stream. If reassembly is complete, proceed to S1.

2. Otherwise, proceed to S9. S1.2: Get the reorganized data and determine whether it is HTTP protocol. If so, go to S2, otherwise go to S9.

3. A printer pcl file restoration method based on mirrored network traffic according to claim 2, characterized in that: S2 is specifically: S2.1: Get the HTTP request method of the reorganized data, and determine whether the request method is POST. If so, proceed to S2.2, otherwise proceed to S9; S2.2: Get the User-Agent of the HTTP request for the reorganized data, and determine whether the Value of the User-Agent is WSDAPI. If so, proceed to S2.3, otherwise proceed to S9; S2.3: Get the Content-Description of the HTTP request and determine whether the Value of the Content-Description contains the keyword "WSDAPI". If so, proceed to S2.4; otherwise, proceed to S9. S2.4: Get the Content-Type of the HTTP request and determine whether the Value of the Content-Type contains the "boundary=" string feature. If so, proceed to S2.5; otherwise, proceed to S9. S2.5: Get the value of the boundary delimiter and assign it to the string variable b_str, and enter S3.

4. A printer pcl file restoration method based on mirrored network traffic according to claim 1, characterized in that: The printer pcl file restoration method also includes S0: determining whether the length of data is greater than 1500 bytes, if so, proceeding to the next step, otherwise proceeding to S9; S0 is provided between S4 and S5.

5. A printer pcl file restoration method based on mirrored network traffic according to claim 4, characterized in that: The printer pcl file restoration method also includes S0.1: Condition 1: Read the first 200 bytes of the variable data, which contains the feature "%-12345X@PJL JOB\r\n"; Condition 2: Read the first 1000 bytes of data, which contain the feature "@PJL ENTER LANGUAGE=PCLXL"; When any one of condition 1 and condition 2 is not satisfied, go to S9; when both condition 1 and condition 2 are satisfied, go to S5; S0.1 is set between S0 and S5.

6. A printer pcl file restoration method based on mirrored network traffic according to claim 1, characterized in that: The printer pcl file restoration method also includes S0.2: reading the last 200 bytes of data, determining whether the last 200 bytes contain the feature "%-12345X@PJL EOJ\r\n", if so, entering S6, otherwise entering S9; S0.2 is set between S5 and S6.