Method, system and medium for generating security verification code based on trajectory drawing interaction

Through a secure verification code generation method based on trajectory drawing interaction, using technologies such as JavaScript, C language and encryption algorithms, the problem of low security performance of existing verification codes when faced with machine cracking is solved, and the security and accuracy of verification codes are improved. sex, improving user experience.

CN113918898BActive Publication Date: 2024-09-06JINAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111011241.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-31
Publication Date
2024-09-06
Estimated Expiration
2041-08-31

AI Technical Summary

Technical Problem

Existing verification codes have low security performance when faced with machine cracking, and in order to enhance security, human identification is more difficult, resulting in poor user experience.

Method used

A secure verification code generation method based on trajectory drawing interaction is adopted to improve the security of the verification code by formulating security rules, using JavaScript and C language to rewrite logic, encrypting data tokens, shuffling algorithms and RC4 encryption, and determining trajectory algorithms. sex and correctness.

Benefits of technology

It effectively prevents the cracking of OCR image recognition technology and machine simulation generated trajectories, improves the security and correctness of verification codes, enhances the recognition ability of machine operations, and reduces the difficulty of human recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113918898B
    Figure CN113918898B
Patent Text Reader

Abstract

The present invention discloses a method, system and medium for generating a secure verification code based on trajectory drawing interaction. The method includes formulating security rules; the client requests the server to perform identity authentication; the server generates a data token, a verification code title and a picture, and stores the relevant information in a database; adds interference to the generated picture and transmits it to the client; the client restores and displays the disrupted verification code picture; records the trajectory information drawn by the user, encrypts the trajectory information data and the data token and transmits them to the server; the server determines the trajectory information and returns the result to the client. The present invention encrypts the sent data using the RC4 encryption algorithm; refuses to verify when a headless browser is detected in JavaScript; uses an algorithm designed to extract the characteristics of human-drawn trajectories to determine machine behavior. These technical means improve security and correctness, and can effectively prevent the cracking of OCR image recognition technology and the behavior of machine simulation to generate trajectories.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of verification code security, and in particular relates to a method, system and medium for generating a security verification code based on trajectory drawing interaction. Background Art

[0002] In the user authentication process, there are a large number of security verification operations that mainly use verification codes. However, most verification codes on the market are easy to crack and have low security performance. The few verification codes with high security simply increase the difficulty of recognition, making it difficult for machines and humans to recognize, resulting in a very poor user experience.

[0003] There are several mainstream behavioral verification codes on the market, such as text input verification codes and text selection verification codes. Although these two types of verification codes are simple to operate, with the development of OCR technology, it has become simple to effectively identify the text on the picture and complete the corresponding simulated behavior. The slider verification code allows the user to simply drag the slider to the correct position, and analyze the data based on the mouse trajectory to determine whether it is a human or a machine. However, there are endless methods to identify gaps in verification code pictures, such as: using artificial intelligence machine learning, using edge detection algorithms, comparing the brightness of each pixel of the complete picture and the picture without the slider, and after completing the gap recognition, the end point of the simulated drag can be obtained. In order to increase the difficulty of cracking, some verification codes blindly add noise to the background picture. Although the difficulty of image recognition has increased, it has also increased the difficulty of human recognition. Summary of the invention

[0004] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a method, system and medium for generating a security verification code based on trajectory drawing interaction.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] In one aspect of the present invention, a method for generating a security verification code based on trajectory drawing interaction is provided, comprising the following steps:

[0007] S1. Formulate security rules to resist verification code attacks;

[0008] S2. The client loads the JavaScript code to initialize the verification code component and requests identity authentication from the server.

[0009] S3, the server generates a data token, a verification code title and an image, and stores the relevant information in the database; adds interference to the generated image and transmits it to the client;

[0010] S4. The client uses a recovery algorithm to restore and display the disrupted verification code image;

[0011] S5, the client records the trajectory information drawn by the user, encrypts the trajectory information data and the data token together, and transmits them to the server;

[0012] S6. After decrypting the received data, the server reads the verification code-related information according to the data token, thereby determining the trajectory information submitted by the user and returning the result to the user.

[0013] As a preferred technical solution, the safety rules are specifically:

[0014] S11, using JavaScript to detect whether the user is trying to load the verification code component using a headless browser, and if so, abort the loading and do not allow verification;

[0015] S12. Use C language to rewrite part of the logic in JavaScript, use Emscripten to compile it into WebAssembly bytecode, and provide relevant functions for JavaScript code to call.

[0016] As a preferred technical solution, the generation and processing process of the data token, verification code title and picture is as follows:

[0017] S31, randomly generate a string consisting of letters and numbers as a data token Challengetoken;

[0018] S32, randomly obtaining a word with two to four characters from the collected word library as a verification code question;

[0019] S33, randomly obtaining a picture as a background picture, randomly generating parameters of each word in the verification code title, including the position coordinates, font size, angle and color of the word; the color of the word is different from the value of the YUV color mode Y channel of the color of the word position on the background picture; drawing the word on the background picture according to the parameters, and finally adding noise interference to the picture to obtain the verification code picture to be displayed to the user;

[0020] S34, storing the data token Challengetoken and the title information of the verification code in the redis database;

[0021] S35. Use the shuffle algorithm to shuffle the image into small blocks of 16x16, add interference, and transmit it to the client.

[0022] As a preferred technical solution, the track information drawn by the user is recorded as follows:

[0023] S51, when the desktop user presses the left button of the mouse on the verification code image, or the mobile user touches the verification code image, start recording the trajectory drawn by the user;

[0024] S52, every 25 milliseconds, record the time from the start of drawing to this time in milliseconds, and record the position of the mouse or touch point on the verification code image at this time;

[0025] S53, when the position of the mouse or the touch point moves outside the verification code image display area, or the user releases the left mouse button and stops touching, or the number of recorded track points reaches a preset maximum number, stop recording the track drawn by the user;

[0026] S54, the client encrypts the trajectory information data and the data token using RC4 and transmits them to the server.

[0027] As a preferred technical solution, the process of determining the trajectory information by the server in step S6 is as follows:

[0028] S61, after the server obtains the trajectory information data and data token, it first decrypts the data to obtain ChallengeToken, and retrieves the question information from the redis database based on ChallengeToken;

[0029] S62, using a trajectory determination algorithm to determine whether it is a machine operation;

[0030] S63, if the verification is passed, a verification token Verifytoken is generated, the validity period is set, stored in the database and encrypted and transmitted to the client; if it is not passed, the work is stopped;

[0031] S64, the client transmits the received verification token Verifytoken and other business data to the server for verification;

[0032] S65. The server will query the redis database to see whether the Verifytoken exists. If it does, the verification is successful, and the Verifytoken in the database is destroyed, and a verification success message is returned to the client; if it does not exist, a verification failure message is returned to the client.

[0033] As a preferred technical solution, the trajectory determination algorithm is specifically:

[0034] (1) Determine the starting point and the end point, specifically: determine whether the starting point and the end point of the point trajectory are within the position range of the question text given on the picture;

[0035] (2) Determine the connection time. Specifically, if the connection time exceeds 0.8s, the verification fails and is determined to be a machine operation.

[0036] (3) Determine the slope, specifically: if there is a 95% probability that the slope from the subsequent point to the first point is the same, it is determined to be a straight line operated by the machine;

[0037] (4) Determine the distance from the discrete point to the standard straight line. Specifically, if the distance from the discrete point to the standard trajectory straight line is too large, it is determined to be a machine operation.

[0038] Another aspect of the present invention provides a security verification code generation system based on trajectory drawing interaction, which is applied to the above-mentioned security verification code generation method based on trajectory drawing interaction, including a security rule formulation module, an initialization module, a data token and verification code generation module, a verification code recovery module, a trajectory information recording module and an identity authentication module;

[0039] The security rule formulation module is used to formulate security rules for resisting verification code attacks;

[0040] The initialization module is used to load the JavaScript code to initialize the verification code component and request the server to perform identity authentication;

[0041] The data token and verification code generation module is used to generate data tokens, verification code titles and pictures, and store the relevant information in a database; add interference to the generated pictures and transmit them to the client;

[0042] The verification code recovery module uses a recovery algorithm to restore and display the disrupted verification code image;

[0043] The track information recording module is used to record the track information drawn by the user, encrypt the track information data and the data token together and transmit them to the server;

[0044] The identity authentication module is used to read the verification code related information according to the data token after decrypting the received data at the server end, thereby determining the trajectory information submitted by the user and returning the result to the user.

[0045] Another aspect of the present invention provides a storage medium storing a program, which, when executed by a processor, implements the above-mentioned security verification code generation method based on trajectory drawing interaction.

[0046] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0047] (1) The solution of the present invention performs a series of processing from the generation of the verification code to the end of the verification process, including the shuffling algorithm to disrupt the image provided by the server; the RC4 encryption algorithm is used to encrypt the sent data; the verification is rejected when a headless browser is detected in JavaScript; part of the logic in JavaScript is rewritten in C language and provided to JavaScript calls in the form of compilation to WebAssembly bytecode; and the algorithm designed by extracting the features of human-drawn trajectories is used to identify machine behavior. These technical means greatly improve the security and correctness of the verification solution of the present invention, and can effectively prevent the cracking of OCR image recognition technology and the behavior of machine simulation of generated trajectories. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is a schematic diagram of the actual application of the method for generating a security verification code based on trajectory drawing interaction according to an embodiment of the present invention;

[0049] Figure 2 It is a business flow chart of a method for generating a security verification code based on trajectory drawing interaction according to an embodiment of the present invention;

[0050] Figure 3 It is a flowchart of specific steps of a method for generating a security verification code based on trajectory drawing interaction according to an embodiment of the present invention;

[0051] Figure 4 It is a structural schematic diagram of a security verification code generation system based on trajectory drawing interaction according to an embodiment of the present invention;

[0052] Figure 5 It is a schematic diagram of the structure of the storage medium of an embodiment of the present invention. DETAILED DESCRIPTION

[0053] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0054] Example

[0055] The solution described in this embodiment proposes a security verification code generation method based on trajectory drawing interaction. The "title" of the verification code is a word with two to four characters. The user needs to draw a sliding track by dragging the mouse or touching the screen in an orderly manner on a picture with multiple characters (which may include characters that do not appear in the words of the verification code title) to connect the given words in order, such as Figure 1 shown.

[0056] The solution described in this embodiment mainly includes four roles: user, client, server, and database. The client, server, and database communicate with each other through the HTTP protocol, wherein the user is the subject of verification of the present invention; the client is mainly responsible for monitoring and recording user behavior and resisting various attacks on the verification code; the server is mainly responsible for generating verification code information and verifying user behavior; the database is mainly responsible for storing verification code title data and related verification data.

[0057] Assume that user M, client, server, and database are used as examples. The user track information is recorded as track = {id, (x1, y1, t1), (x2, y2, t2)…(x n ,y n ,t n )}, the question information stored in the database is recorded as question = {(a1, b1), (a2, b2), r, Challengetoken}, and the verification information stored in the database is recorded as verify = {Verifytoken, time}.

[0058] like Figure 1 As shown, this embodiment provides a method for generating a security verification code based on trajectory drawing interaction, comprising the following steps:

[0059] S1. Formulate security rules to resist verification code attacks;

[0060] Furthermore, the safety rules are specifically as follows:

[0061] S11. Use JavaScript to detect whether the user is trying to load the verification code component using a headless browser such as Selenium. If so, the loading is aborted and verification is not allowed;

[0062] S12. Use C language to rewrite part of the logic in JavaScript, use Emscripten to compile it into WebAssembly bytecode, and then provide relevant functions for JavaScript code to call.

[0063] S2. The client loads the JavaScript code to initialize the verification code component and requests identity authentication from the server.

[0064] S3, the server generates a data token, a verification code title and an image, and stores the relevant information in the database; adds interference to the generated image and transmits it to the client;

[0065] Furthermore, the generation and processing of the data token, verification code title and image are as follows:

[0066] S31, randomly generate a string consisting of letters and numbers as a data token Challengetoken;

[0067] S32, randomly obtaining a word with two to four characters from the collected word library as a verification code question;

[0068] S33, randomly obtaining a picture as a background picture, randomly generating parameters of each word in the verification code title, including the position coordinates, font size, angle and color of the word; the color of the word is different from the value of the YUV color mode Y channel of the color of the word position on the background picture; drawing the word on the background picture according to the parameters, and finally adding noise interference to the picture to obtain the verification code picture to be displayed to the user;

[0069] S34, the title information

[0070] question={{(a1,b1),(a2,b2),…,(a n ,b n )}, r, Challengetoken} are stored in the redis database, where {(a1, b1), (a2, b2), …, (a n , b n )} are the coordinates of each word in the question, r is the radius of the area occupied by the word, and Challengetoken is the verification token;

[0071] S35. Use the shuffle algorithm to shuffle the image into small blocks of 16x16, add interference, and transmit it to the client.

[0072] S4. The client uses a recovery algorithm to restore and display the disrupted verification code image;

[0073] S5. Record the track information drawn by the user, where the track information drawn by the user is recorded as track, where track = {Challengetoken, (x1, y1, t1), (x2, y2, t2) ... (x n ,y n , t n )}, and encrypt the data before transmitting it to the server; where (x1, y1, t1), (x2, y2, t2)…(x n ,y n ,t n ) is the coordinates and sampling time information of each point in the trajectory.

[0074] Furthermore, the track information recorded by the user is specifically:

[0075] S51, when the desktop user presses the left button of the mouse on the verification code image, or the mobile user touches the verification code image, start recording the trajectory drawn by the user;

[0076] S52, every 25 milliseconds, record the time from the start of drawing to this time in milliseconds, and record the position of the mouse or touch point on the verification code image at this time;

[0077] S53, when the position of the mouse or the touch point moves outside the verification code image display area, or the user releases the left mouse button and stops touching, or the number of recorded track points reaches a preset maximum number, stop recording the track drawn by the user;

[0078] S54, the client encrypts the trajectory information data and the data token using RC4 and transmits them to the server.

[0079] S6. The server determines the trajectory information and returns the result to the client.

[0080] Furthermore, the process of the server determining the trajectory information in step S6 is as follows:

[0081] S61, after the server obtains the trajectory information data and the data token, it first decrypts the data to obtain the Challenge token, and retrieves the question information question from the redis database according to the Challenge token;

[0082] S62, the trajectory determination algorithm used is as follows:

[0083] (1) Determine the starting point and the end point, specifically: determine whether the starting point and the end point of the point trajectory are within the position range of the question text given on the picture;

[0084] (2) Determine the connection time. Specifically, if the connection time exceeds 0.8s, the verification fails and is determined to be a machine operation.

[0085] (3) Determine the slope, specifically: if there is a 95% probability that the slope from the subsequent point to the first point is the same, it is determined to be a straight line operated by the machine;

[0086] (4) Determine the distance between the discrete point and the standard straight line. Specifically, if the distance between the discrete point and the standard trajectory straight line is too large, it is determined to be a machine operation;

[0087] S63, if the verification is passed, a verification token Verifytoken is generated, the validity period time is set, the information verify = {Verifytoken, time} is stored in the database, and the Verifytoken is encrypted and transmitted to the client; if it fails, the work is stopped;

[0088] S64. After the client decrypts and obtains the information, it encapsulates the user verification information including the verification token Verifytoken, the username username, and the user password password into user information infor = {Verifytoken, username, password} and transmits it to the server through data encryption to wait for verification; wherein, the Verifytoken decrypted by the client may be NULL, which means that the verification fails and the user needs to return to step S2 and re-verify.

[0089] S65. After decrypting the data, the server will query the redis database for the existence of the Verifytoken. If not, a verification failure message will be returned to the client. If it exists, the server will continue to verify whether the username and password match. If not, a verification code failure message will be returned. If they match, the verification is successful and a verification success message will be returned to the client. If the Verifytoken exists, the server will destroy the Verifytoken in the database after continuing to verify the username and password, regardless of whether they match.

[0090] like Figure 4 As shown, in another embodiment of the present application, a security verification code generation system based on trajectory drawing interaction is provided, the system comprising a security rule formulation module, an initialization module, a data token and verification code generation module, a verification code recovery module, a trajectory information recording module and an identity authentication module;

[0091] The security rule formulation module is used to formulate security rules for resisting verification code attacks;

[0092] The initialization module is used to load the JavaScript code to initialize the verification code component and request the server to perform identity authentication;

[0093] The data token and verification code generation module is used to generate data tokens, verification code titles and pictures, and store the relevant information in a database; add interference to the generated pictures and transmit them to the client;

[0094] The verification code recovery module uses a recovery algorithm to restore and display the disrupted verification code image;

[0095] The track information recording module is used to record the track information drawn by the user, encrypt the track information data and the data token together and transmit them to the server;

[0096] The identity authentication module is used to read the verification code related information according to the data token after decrypting the received data at the server end, thereby determining the trajectory information submitted by the user and returning the result to the user.

[0097] It should be noted here that the system provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure is divided into different functional modules to complete all or part of the functions described above. The system is a security verification code generation method based on trajectory drawing interaction applied to the above embodiment.

[0098] like Figure 5 As shown, in another embodiment of the present application, a storage medium is further provided, storing a program, and when the program is executed by a processor, a security verification code generation method based on trajectory drawing interaction is implemented, specifically:

[0099] S1. Formulate security rules to resist verification code attacks;

[0100] S2. The client loads the JavaScript code to initialize the verification code component and requests identity authentication from the server.

[0101] S3, the server generates a data token, a verification code title and an image, and stores the relevant information in the database; adds interference to the generated image and transmits it to the client;

[0102] S4. The client uses a recovery algorithm to restore and display the disrupted verification code image;

[0103] S5, the client records the trajectory information drawn by the user, encrypts the trajectory information data and the data token together, and transmits them to the server;

[0104] S6. After decrypting the received data, the server reads the verification code-related information according to the data token, thereby determining the trajectory information submitted by the user and returning the result to the user.

[0105] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0106] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A secure verification code generation method based on trajectory drawing interaction. It is characterized in that The steps include: Develop security rules to resist CAPTCHA attacks; The client loads the JavaScript code to initialize the verification code component and requests identity authentication from the server; The server generates data tokens, verification code titles and pictures, and stores the relevant information in the database; adds interference to the generated pictures and transmits them to the client; the generation and processing of data tokens, verification code titles and pictures are as follows: A random string of letters and numbers is generated as a data token Challengetoken; Randomly select a word with two to four characters from the collected word library as the verification code question; A picture is randomly obtained as a background picture, and parameters of each word in the verification code title are randomly generated, including the position coordinates, font size, angle and color of the word; the color of the word is different from the value of the YUV color mode Y channel of the color of the word position on the background picture; the word is drawn on the background picture according to the parameters, and finally noise interference is added to the picture to obtain the verification code picture to be displayed to the user; Store the data token and verification code title information in the redis database; Use the shuffle algorithm to shuffle the image into small blocks of 16x16 and add interference, and then transmit it to the client; The client uses the recovery algorithm to restore and display the disrupted verification code image; The client records the trajectory information drawn by the user, encrypts the trajectory information data and the data token together and transmits them to the server; the trajectory information drawn by the user is specifically recorded as follows: When a desktop user presses the left mouse button on the verification code image, or a mobile user touches the verification code image, the user's drawn trajectory begins to be recorded; Every 25 milliseconds, record the time from the start of drawing to this time in milliseconds, and record the position of the mouse or touch point on the verification code image at this time; When the position of the mouse or touch point moves outside the verification code image display area, or the user releases the left mouse button and stops touching, or the number of recorded track points reaches the preset maximum number, the track drawn by the user is stopped from being recorded; The client encrypts the trajectory information data and data token using RC4 and transmits them to the server; After the server decrypts the received data, it reads the verification code-related information according to the data token, determines the trajectory information submitted by the user, and returns the result to the user; The process of determining trajectory information on the server is as follows: After the server obtains the trajectory information data and data token, it first decrypts the data to obtain the Challenge token, and then retrieves the question information from the redis database based on the Challenge token; Use the trajectory determination algorithm to determine whether it is a machine operation; If the verification is successful, a verification token Verifytoken is generated, the validity period is set, stored in the database and encrypted and transmitted to the client; if it fails, the work stops; The client transmits the received verification token Verifytoken and other business data to the server for verification; The server will query whether the Verifytoken exists in the redis database. If it exists, the verification is successful, and the Verifytoken in the database is destroyed, and a verification success message is returned to the client; if it does not exist, a verification failure message is returned to the client; The trajectory determination algorithm is specifically: Determine the starting point and the end point, specifically: determine whether the starting point and the end point of the trajectory of the point are within the position range of the question text given on the picture; Determine the connection time. Specifically, if the connection time exceeds 0.8s, the verification fails and is determined to be machine operation. Determine the slope, specifically: if there is a 95% probability that the slope from the subsequent point to the first point is the same, it is determined to be a straight line operated by the machine; Determine the distance from the discrete point to the standard straight line. Specifically, if the distance from the discrete point to the standard trajectory straight line is too large, it is determined to be a machine operation.

2. According to the method for generating a security verification code based on trajectory drawing interaction according to claim 1, It is characterized in that The safety rules are specifically: Use JavaScript to detect if the user is trying to load the captcha component using a headless browser, and if so, abort the loading and do not allow the verification; Use C language to rewrite part of the logic in JavaScript, compile it into WebAssembly bytecode using Emscripten, and provide relevant functions for JavaScript code to call.

3. A secure verification code generation system based on trajectory drawing interaction, It is characterized in that A security verification code generation method based on trajectory drawing interaction applied to any one of claims 1-2, comprising a security rule formulation module, an initialization module, a data token and verification code generation module, a verification code recovery module, a trajectory information recording module and an identity authentication module; The security rule formulation module is used to formulate security rules for resisting verification code attacks; The initialization module is used to load the JavaScript code to initialize the verification code component and request the server to perform identity authentication; The data token and verification code generation module is used to generate data tokens, verification code titles and pictures, and store the relevant information in a database; Add noise to the generated image and pass it to the client; The verification code recovery module uses a recovery algorithm to restore and display the disrupted verification code image; The track information recording module is used to record the track information drawn by the user, encrypt the track information data and the data token together and transmit them to the server; The identity authentication module is used to read the verification code related information according to the data token after decrypting the received data at the server end, thereby determining the trajectory information submitted by the user and returning the result to the user.

4. A storage medium storing a program, Features: When the program is executed by a processor, the method for generating a security verification code based on trajectory drawing interaction according to any one of claims 1 to 2 is implemented.