Password guessing method based on multi semantic fusion probability context-free grammar
By employing a probabilistic context-free grammar method that integrates multiple semantics, this method automatically extracts and fuses various semantic patterns from passwords, solving the problem of insufficient semantic pattern fusion in existing technologies and improving the efficiency and accuracy of password guessing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-08
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies struggle to automatically extract multiple semantic patterns from passwords and integrate them into the password generation process, resulting in insufficient efficiency and accuracy in password guessing.
We adopt a probabilistic context-free grammar method based on multi-semantic fusion. Through multi-semantic segmentation preprocessing, training a multi-semantic fusion PCFG model, generating a candidate password dictionary, we integrate multiple semantic patterns and control the degree of semantic enhancement through adjustable parameters to improve guessing efficiency.
It improves the efficiency and accuracy of password guessing, has good scalability and fine-grained control over the degree of semantic enhancement, and new semantic patterns can be quickly integrated.
Smart Images

Figure CN121479754B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information security technology, and in particular to a password guessing method based on probabilistic context-free grammars with multi-semantic fusion. Background Technology
[0002] Passwords remain the most widely used authentication method. Although various alternatives have been proposed (such as single sign-on, hardware security keys, and behavioral biometrics), none can completely replace passwords. This is because passwords offer numerous advantages: they are easy to modify, consume few resources, and are convenient to use. Furthermore, alternatives also have significant drawbacks. For example, biometric authentication methods (such as fingerprint recognition and iris scanning) are irreversible and may lead to the leakage of sensitive user biometric information. Therefore, passwords will remain the mainstream method for the foreseeable future. Password guessing algorithms, as a crucial means of assessing password strength, directly impact the reliability of security defenses.
[0003] The development of password guessing algorithms can be divided into the following stages. Early password guessing relied on heuristic methods. For example, the paper "RHM Sr. and K. Thompson, “Password security - A case history,” Commun. ACM 1979, vol. 22, no. 11, pp. 594–597" applied various heuristic transformation rules to dictionary words to generate their variants and perform password guessing. Later, password guessing entered a new stage based on probabilistic statistics. The paper "A. Narayanan and V. Shmatikov, “Fast dictionary attacks on passwords using time-space tradeoff,” in Proc. ACM CCS 2005, pp. 364–372" introduced the Markov model into password guessing. This algorithm recovered 67.6% of passwords in the guess space. The paper "M. Weir, S. Aggarwal, B. deMedeiros, and B. Glodek, “Password cracking using probabilistic context-free grammars,” in Proc. IEEE S&P The paper "Password guessing based on context-free grammars" (2009, pp.391-405) proposed a password guessing algorithm that cracked 28% to 129% more passwords than traditional software tools, but it did not consider semantics. With the development of deep learning technology, password guessing methods incorporating deep learning have also achieved good results. For example, the paper "B. Pal, T. Daniel, R. Chatterjee, and T. Ristenpart, “Beyond credential stuffing: Password similarity models using neural networks,” in Proc. IEEE S&P 2019, pp. 417–434)" trained a deep learning-based password guessing model. Attack results showed that the model could crack 16% of passwords in 1,000 guesses. However, all of the above guessing algorithms have a limitation: they fail to fully model and utilize the semantic behavior habits of users when constructing passwords, such as using the sequential sequence f@sj123 in the password.
[0004] The paper "R. Veras, C. Collins, and J. Thorpe, “On semantic patterns of passwords and their security impact,” in Proc. NDSS 2014. proposes a semantic-based password generator, but the semantics in the paper are represented by part-of-speech (POS) tags. The paper "D. Wang, P. Wang, D. He, and Y. Tian, “Birthday, name and bifacialsecurity: Understanding passwords of Chinese web users,” in Proc. USENIX SEC 2019, pp. 1537-1555. introduces external dictionaries of names and dates into the PCFG to improve guessing efficiency instead of learning from the password itself. While these methods all consider semantics based on PCFG, none systematically consider common semantic patterns, such as repetition patterns and sequential patterns, which can effectively improve password cracking efficiency.
[0005] Therefore, there is a need to develop an algorithm that can automatically extract multiple semantic patterns from passwords and integrate them into the password generation process to improve guessing efficiency. To this end, this invention aims to propose a password guessing method that can automatically and systematically extract and integrate multiple semantic patterns from passwords and control the degree of semantic enhancement through adjustable parameters, so as to improve guessing efficiency and accuracy. Summary of the Invention
[0006] The technical problem solved by this invention is that existing technologies have difficulty automatically extracting multiple semantic patterns from passwords and integrating them into the password generation process.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0008] The password guessing method based on probabilistic context-free grammars with multi-semantic fusion includes the following steps:
[0009] Step S1: Perform multi-semantic segmentation preprocessing on the training set passwords to obtain a password segmentation result set, wherein the multi-semantic segmentation preprocessing includes:
[0010] Each training password substring is enumerated and matched and identified in a preset semantic pattern set to obtain a semantic segment. The semantic pattern set includes simple pattern, date pattern, word pattern, and name pattern. If the same semantic segment matches multiple semantic patterns at the same time, a unique semantic pattern label is determined according to the preset semantic pattern priority. Based on the segmentation principle of maximizing semantic coverage and minimizing the number of semantic segments, dynamic programming is used to select the optimal segmentation scheme between semantic segments and non-semantic segments to form the password segmentation result set.
[0011] Step S2: Based on the password segmentation result set, train a probabilistic context-free grammar model for multi-semantic fusion. Encode non-semantic segments as structural identifiers according to character type, encode semantic segments as semantic identifiers according to their semantic patterns, count the password structure and substructure filling segments, configure semantic enhancement parameters β for each semantic pattern, and normalize the corresponding counts of semantic segments by weighting β to obtain the password structure probability distribution and the conditional probability distribution of substructure filling segments.
[0012] Step S3: Based on the password structure probability distribution and conditional probability distribution, a priority queue is used to generate candidate passwords in descending order of generation probability, forming a generated password dictionary;
[0013] Step S4: Output a preset number of guessed passwords from the generated password dictionary as password guessing results.
[0014] Preferably, step S1 includes the following sub-steps:
[0015] Step S101: For each password in the training set, enumerate all substrings of the password, identify whether each substring belongs to any semantic pattern in the preset semantic pattern set, and add the substrings identified as semantic patterns as semantic segments to the semantic segment set S.
[0016] Step S102: For the same semantic segment in the semantic segment set S that matches multiple semantic patterns simultaneously, select a unique semantic pattern to mark the semantic segment according to the preset semantic pattern priority.
[0017] Step S103: Based on the segmentation principle, the optimal segmentation scheme consisting of semantic segments and non-semantic segments is selected for each password using dynamic programming. The optimal segmentation scheme is recorded as the password segmentation result. All password segmentation results are summarized to obtain the password segmentation result set. The segmentation principle is the maximum semantic coverage and the minimum number of semantic segments.
[0018] Preferred:
[0019] Simple modes include single character repeat mode, string repeat mode, sequential mode, keyboard mode, and palindrome mode;
[0020] Date modes include YYYYMMDD mode, YYMMDD mode, MMDD mode, and YYYY mode;
[0021] Vocabulary patterns include website name-related vocabulary patterns and common English word patterns;
[0022] Name patterns include last name pattern, first name pattern, and full name pattern;
[0023] The priority of the preset semantic patterns satisfies the following: in the simple patterns, the sequential pattern has a higher priority than the single character repetition pattern, the single character repetition pattern has a higher priority than the string repetition pattern, the string repetition pattern has a higher priority than the keyboard pattern, and the keyboard pattern has a higher priority than the palindrome pattern.
[0024] In vocabulary patterns, common English word patterns take precedence over website name-related vocabulary patterns.
[0025] In the name pattern, the full name pattern has higher priority than the last name pattern, and the last name pattern has higher priority than the first name pattern.
[0026] The overall priority is as follows: simple mode is higher than vocabulary mode, vocabulary mode is higher than name mode, and simple mode is higher than date mode.
[0027] Preferably, the semantic pattern recognition method in step S101 is as follows:
[0028] Single character repetition pattern, string repetition pattern, sequential pattern and palindrome pattern are identified by pattern matching, while keyboard pattern is identified by keyboard layout sequence matching.
[0029] Date pattern, vocabulary pattern, and name pattern are identified by dictionary matching using a preset external dictionary;
[0030] To avoid pseudo-semantic segments caused by excessively short matches, the semantic segment length for single-character repetition pattern, string repetition pattern, and sequential pattern is specified to be greater than or equal to 3 characters, the semantic segment length for palindrome pattern is greater than or equal to 4 characters, and the semantic segment length for other semantic patterns is greater than or equal to their respective preset minimum length threshold.
[0031] Preferably, the process of determining the optimal segmentation scheme through dynamic programming in step S103 includes:
[0032] Maintain a first state array, a second state array, and a third state array with the same length as the password. The first state array is used to record the maximum semantic coverage length among all candidate segmentation schemes before the current position. The second state array is used to record the minimum number of semantic segments under the maximum semantic coverage length. The third state array is used to record the ending position of the semantic segment starting from the current position or to identify the current character as belonging to a non-semantic segment.
[0033] Iterate through each character from the end of the password backwards. When the position of the character is regarded as the starting position of the semantic segment, enumerate all semantic segment candidates that start at that position and exist in the semantic segment set S. Compare the semantic coverage length and number of semantic segments obtained by expanding the semantic segment with the current recorded state. If the semantic coverage length is larger or the semantic coverage length is the same and the number of semantic segments is smaller, then update the first state array, the second state array and the third state array.
[0034] Treat the character position as a non-semantic segment start position, inherit the state of the next position, and maintain the existing record when the semantic coverage length is the same and the number of semantic segments does not increase;
[0035] After the traversal is completed, starting from the password start position, based on the semantic segment end position and non-semantic segment marker recorded in the third state array, the segment list containing semantic segments and non-semantic segments is reconstructed in sequence. The segment list is the final password segmentation result that satisfies the segmentation principle.
[0036] Preferably, step S2 includes the following sub-steps:
[0037] Step S201: Encode each password segment in the password segmentation result set. Non-semantic segments are divided into letter segments, number segments, and symbol segments according to character type, and L, D, and S are used as structural identifiers respectively. Semantic segments are encoded into corresponding semantic pattern type identifiers according to their semantic pattern.
[0038] Step S202: Extract the encoded segmented sequence into a password structure and its substructure filling segments. The password structure is used to describe the combination order of L, D, S and each semantic pattern identifier. The substructure filling segments are used to record the specific string corresponding to each structure position.
[0039] Step S203: Count the number of times each password structure appears in the training set and the number of times each substructure filling segment appears in its structural position. Configure a semantic enhancement parameter β for each semantic pattern. Weight the count of the filling segment corresponding to the semantic segment according to β to obtain the password structure count and substructure filling segment count after semantic enhancement.
[0040] Step S204: Normalize the weighted count to obtain the password structure probability distribution and the conditional probability distribution of each substructure filling segment under a given password structure. The semantic enhancement parameter β is set to 1 by default, but can also be adjusted according to actual needs to change the weight contribution of different semantic patterns in the password generation process.
[0041] Preferably, the encoding method for the semantic segment in step S201 is as follows:
[0042] Encode the single-character repetition pattern as the identifier single_character_repetition;
[0043] Encode the string repetition pattern as the identifier segment_repetition;
[0044] Encode the sequence pattern as the identifier sequence_up or sequence_down;
[0045] Encode the keyboard pattern as the identifier keyboard;
[0046] Encode the palindrome pattern as the identifier palindrome;
[0047] Encode the YYYYMMDD date pattern into the identifier YYYYMMDD;
[0048] Encode the YYMMDD date pattern into the identifier YYMMDD;
[0049] Encode the MMDD date pattern into the identifier MMDD;
[0050] Encode the YYYY date pattern into the identifier YYYY;
[0051] Encode the website name-related vocabulary pattern into the identifier website_related;
[0052] Encode common English word patterns as the identifier common_English_word;
[0053] Encode the last name pattern as the identifier lastname;
[0054] Encode the name pattern into the identifier firstname;
[0055] Encode the full name pattern as the identifier fullname;
[0056] The encoded semantic pattern identifier has the same status as L, D, and S in the password structure.
[0057] Preferably, step S3 includes the following sub-steps:
[0058] Step S301: Create a max-heap sorted by password generation probability as a priority queue. The generated password pw, the corresponding generation probability pro, and the password filling substructure index pivot are stored in the heap nodes.
[0059] Step S302: For each password structure obtained in step S2, prioritize selecting the filling string combination with the highest probability of filling segments in each substructure under the structure to form the initial password. Calculate the generation probability of each initial password. The generation probability is the product of the password structure probability and the probability of filling segments in each substructure. Push the generated password pw, generation probability pro, and initial filling substructure index pivot into the priority queue.
[0060] Step S303: Pop the node with the highest generation probability from the priority queue and record the generation password pw in it into the generation password dictionary;
[0061] For each substructure position after pivot in this node, the original padding string is replaced with the padding string with the next highest probability at that position to form a new generated password, and the corresponding generation probability is recalculated. The newly generated password, generation probability and updated padding substructure index are pushed into the priority queue.
[0062] Step S304: Repeat step S303 until the priority queue is empty or the number of candidate passwords recorded in the generated password dictionary reaches a preset upper limit. The passwords arranged in the order of recording in the generated password dictionary are the guessed password sequence sorted from largest to smallest generation probability.
[0063] An electronic device includes a processor and a memory, the memory storing computer-readable instructions that, when executed by the processor, perform steps in a password guessing method based on a probabilistic context-free grammar with multi-semantic fusion.
[0064] A storage medium storing a computer program that, when executed by a processor, performs steps in a password guessing method based on a probabilistic context-free grammar with multi-semantic fusion.
[0065] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention integrates multiple semantic patterns to guide the generation of semantically enhanced passwords, introduces semantic enhancement parameters to finely control the degree of semantic enhancement while retaining the original structural statistical features, has good scalability, and new semantic patterns can be quickly integrated into the present invention without modifying the core results. Attached Figure Description
[0066] Figure 1 A flowchart illustrating the steps of a password guessing method based on a probabilistic context-free grammar with multi-semantic fusion, as provided in an embodiment of the present invention.
[0067] Figure 2 The flowchart shows the data preprocessing stage of a password guessing method based on probabilistic context-free grammar with multi-semantic fusion, as provided in an embodiment of the present invention.
[0068] Figure 3 The training phase program execution diagram of a password guessing method based on probabilistic context-free grammar with multi-semantic fusion provided in an embodiment of the present invention is shown below.
[0069] Figure 4 The diagram shows the program execution of the generation stage of a password guessing method based on a probabilistic context-free grammar with multi-semantic fusion, as provided in an embodiment of the present invention. Detailed Implementation
[0070] Specific embodiments of the present invention are given below. These specific embodiments are only used to further illustrate the present invention in detail and do not limit the scope of protection of the present invention.
[0071] Example, refer to Figure 1 This paper provides a password guessing method based on probabilistic context-free grammars with multi-semantic fusion, including the following steps:
[0072] Step S1: Perform multi-semantic segmentation preprocessing on the training set passwords to obtain a password segmentation result set, wherein the multi-semantic segmentation preprocessing includes:
[0073] Each training password substring is enumerated and matched and identified in a preset semantic pattern set to obtain a semantic segment. The semantic pattern set includes simple pattern, date pattern, word pattern, and name pattern. If the same semantic segment matches multiple semantic patterns, a unique semantic pattern label is determined according to the preset semantic pattern priority. Based on the segmentation principle of maximizing semantic coverage and minimizing the number of semantic segments, dynamic programming is used to select the optimal segmentation scheme between semantic segments and non-semantic segments to form the password segmentation result set.
[0074] Step S2: Based on the password segmentation result set, train a probabilistic context-free grammar model for multi-semantic fusion. Encode non-semantic segments as structural identifiers according to character type, encode semantic segments as semantic identifiers according to their semantic patterns, count the password structure and substructure filling segments, configure semantic enhancement parameters β for each semantic pattern, and normalize the corresponding counts of semantic segments by weighting β to obtain the password structure probability distribution and the conditional probability distribution of substructure filling segments.
[0075] Step S3: Based on the password structure probability distribution and conditional probability distribution, a priority queue is used to generate candidate passwords in descending order of generation probability, forming a generated password dictionary.
[0076] Step S4: Output a preset number of guessed passwords from the generated password dictionary as password guessing results.
[0077] Step S1 is the data preprocessing stage, such as... Figure 2 As shown, it includes the following sub-steps:
[0078] Step S101: For each password in the training set, enumerate all substrings of the password, identify whether each substring belongs to any semantic pattern in the preset semantic pattern set, and add the substrings identified as semantic patterns as semantic segments to the semantic segment set S.
[0079] The semantic pattern recognition method in step S101 is as follows:
[0080] Single character repetition pattern, string repetition pattern, sequential pattern and palindrome pattern are identified by pattern matching, while keyboard pattern is identified by keyboard layout sequence matching.
[0081] Date pattern, vocabulary pattern, and name pattern are identified by dictionary matching using a preset external dictionary.
[0082] To avoid pseudo-semantic segments caused by excessively short matches, the semantic segment length for single-character repetition pattern, string repetition pattern, and sequential pattern is specified to be greater than or equal to 3 characters, the semantic segment length for palindrome pattern is greater than or equal to 4 characters, and the semantic segment length for other semantic patterns is greater than or equal to their respective preset minimum length threshold.
[0083] Step S102: For the same semantic segment in the semantic segment set S that matches multiple semantic patterns simultaneously, select a unique semantic pattern to mark the semantic segment according to the preset semantic pattern priority.
[0084] Step S103: Based on the segmentation principle, use dynamic programming to select the optimal segmentation scheme consisting of semantic segments and non-semantic segments for each password, record the optimal segmentation scheme as the password segmentation result, and summarize all password segmentation results to obtain the password segmentation result set. The segmentation principle is the maximum semantic coverage and the minimum number of semantic segments.
[0085] Simple modes include single character repeat mode, string repeat mode, sequential mode, keyboard mode, and palindrome mode.
[0086] Date modes include YYYYMMDD, YYMMDD, MMDD, and YYYY.
[0087] The vocabulary patterns include website name-related vocabulary patterns and common English word patterns.
[0088] Name patterns include last name pattern, first name pattern, and full name pattern.
[0089] The preset semantic pattern priority satisfies the following: in simple patterns, sequential patterns have higher priority than single-character repetition patterns, single-character repetition patterns have higher priority than string repetition patterns, string repetition patterns have higher priority than keyboard patterns, and keyboard patterns have higher priority than palindrome patterns.
[0090] In vocabulary patterns, common English word patterns take precedence over website name-related vocabulary patterns.
[0091] In the name pattern, the full name pattern has higher priority than the last name pattern, and the last name pattern has higher priority than the first name pattern.
[0092] The overall priority is as follows: simple mode is higher than vocabulary mode, vocabulary mode is higher than name mode, and simple mode is higher than date mode.
[0093] Step S103 determines the optimal password segmentation based on dynamic programming, as follows:
[0094] For length of The password is pw. This represents the substring from the i-th character to the j-th character in pw (where the index of pw starts from 0). Maintain three substrings of length i. +1 arrays maxSemLen, minSemCount, and semantics (array indices start from 0). express The longest semantic segment among all segments express The length of all semantic segments is equal to The minimum number of semantic segments in the segmentation. express The semantic segment starting from the i-th character of pw in the segment that satisfies the maximum semantic segment length and the minimum number of semantic segments is then initialized. and .
[0095] from i= Starting from -2, state transitions are performed according to the following rules:
[0096] Considering that position i of pw is the starting point of the semantic segment, we enumerate all possible positions j as the ending position of the semantic segment (j∈[i+2, ..., ...). -1]), for each j satisfying Its semantic segment length is j-i+1. Selecting this semantic segment yields... and .
[0097] Ignoring the fact that the position of pw is i, which is the starting point of the semantic segment, we can obtain and .
[0098] For j∈[i+1, -1], first record based on "maximum semantic segment length" The largest j is j'. If there is only one j', then let index = j', and record it. and If there is more than one j', then select one from the multiple j' based on the "minimum number of semantic segments". Let j' be the smallest j' that is greater than 0, and let index = j''. Record and If index = i + 1, then record Otherwise, record .
[0099] Decrement the count of i by one. If i ≥ 0, return to step (1); otherwise, end the loop.
[0100] Maintain a list `segments` to store the segments of `pw`, and an empty string `str` to represent non-semantic segments. Then, starting from `i=0`, iterate through the segments according to the following rules:
[0101] If i= If str is not empty, add str to the segment list segments; otherwise, do nothing and stop iterating.
[0102] like If empty, add pw i When str reaches the end, increment the count of i by 1.
[0103] like If str is not empty, add str to the segment list segments; otherwise, do nothing, and then... Add to the segment list `segments`, reset `str` to an empty string, and increment the `i` counter. The length.
[0104] The segment list is the final password segmentation.
[0105] Step S2 is the training phase, such as... Figure 3 As shown, based on the password segmentation results of the training set in step S1, a PCFG model based on multi-semantic fusion is trained to obtain the probability distribution of password structure and substructure filling segments.
[0106] The semantic enhancement parameter β=1 is set by default for each semantic mode, but it can be adjusted according to actual needs.
[0107] For each password and its segment in the training set, train according to the following steps:
[0108] Non-semantic segments in the segmentation are extracted using L, D, and S to obtain the structure and corresponding padding segments. Semantic segments are converted into semantic pattern type identifiers and then their structure and corresponding padding segments are extracted.
[0109] The password structure count is incremented by 1, and the corresponding substructure fill segment count is incremented by 1.
[0110] After training, the probability distribution of the password structure and substructure filling segments is obtained;
[0111] Return to train the next password. Continue training all passwords until the password structure and substructure filling segment probability distribution are obtained.
[0112] The encoding method for the semantic segment in step S2 is as follows:
[0113] The single-character repetition pattern is encoded as the identifier single_character_repetition.
[0114] The string repetition pattern is encoded as the identifier segment_repetition.
[0115] Encode the sequence pattern as the identifier sequence_up or sequence_down.
[0116] Encode the keyboard pattern as the identifier "keyboard".
[0117] The palindrome pattern is encoded as the identifier palindrome.
[0118] The YYYYMMDD date pattern is encoded as the identifier YYYYMMDD.
[0119] Encode the YYMMDD date pattern into the identifier YYMMDD.
[0120] Encode the MMDD date pattern into the identifier MMDD.
[0121] Encode the YYYY date pattern into the identifier YYYY.
[0122] Encode the website name-related vocabulary pattern as the identifier website_related.
[0123] Common English word patterns are encoded as the identifier common_English_word.
[0124] Encode the last name pattern as the identifier lastname.
[0125] Encode the name pattern as the identifier firstname.
[0126] Encode the full name pattern as the identifier fullname.
[0127] The encoded semantic pattern identifier has the same status as L, D, and S in the password structure.
[0128] Steps S1 and S2 are explained in the following manner during implementation:
[0129] The training dataset {111111, watermelon, smith@123, ojcsdr#5056} is selected. In step S101, substrings are enumerated and semantic segments are identified for each password. Password 111111 contains multiple single-character repetitive semantic segments of varying lengths; password watermelon contains semantic segments of common English words such as "water," "melon," and "watermelon"; password smith@123 contains semantic segments with the surname pattern "smith" and the sequential pattern "123"; password ojcsdr#5056 does not contain any semantic segments. In step S103, when segmenting the password watermelon using dynamic programming, segments are obtained by comparing the substrings starting with "watermelon." Candidate schemes starting from different semantic segments such as "n", "water", and "melon" were selected. Ultimately, [watermelon] was found to be the optimal segmentation that satisfies the maximum semantic coverage and the minimum number of semantic segments. Similarly, for other passwords, the optimal segmentation results [111111], [smith,@,123], and [ojcsdr#5056] were obtained. In steps S201 to S204, taking the [smith,@,123] segment as an example, "smith" was encoded as the lastname semantic pattern, "@" was encoded as the symbol structure S, and "123" was encoded as the sequence pattern identifier. The structure and filling segment frequencies of these segments were statistically analyzed and normalized along with those of other password segments to obtain the password structure probability distribution and substructure filling segment probability distribution on the example dataset.
[0130] Step S3 is the generation stage, such as... Figure 4 As shown, based on the probability distribution of the password structure and substructure filling segments obtained in step S2, semantically enhanced guessed passwords are generated in descending order of probability according to the following steps.
[0131] Create a max-heap as an optimization queue. The heap nodes store the generated password (pw), the password generation probability (pro), and the password filling substructure index (pivot). The max-heap is sorted by the password generation probability.
[0132] Initialize the priority queue. For each password structure obtained in step S2, first fill each substructure with the filling segment with the highest probability, then calculate the password generation probability. The password generation probability is the product of the probability of the password structure and the filling segment of each substructure. Finally, form a tuple according to the generated password, the password generation probability, and the password filling substructure index (set to 0), and push it into the priority queue.
[0133] Get the first element (pw, pro, pivot) of the priority queue and record it in the generated dictionary. Then, for pivot ≤ i < j, where j is the number of substructures of pw, the i-th substructure of pw is filled as the next highest probability filling segment. Then, generate a new password pw', calculate the generation probability of pw' as pro', form a tuple (pw', pro', i+1), and push it into the priority queue.
[0134] Pop the first element of the priority queue and continue execution until the priority queue is empty or a dictionary contains a specified number of guessed passwords.
[0135] Take the dataset {111111, watermelon, smith@123, ojcsdr#5056} as an example.
[0136] During the data preprocessing stage, for each password in the training set, the following two steps are performed:
[0137] Extract semantic segments from the passwords, enumerate the substrings in the passwords, and identify all semantic segments. Except for single-character repetition patterns, string repetition patterns, sequential patterns, and palindromic patterns, which are identified using pattern matching, other semantic patterns are identified using dictionary matching. Note that the string length for single-character repetition patterns, string repetition patterns, and sequential patterns is greater than or equal to 3, and the length for palindromic patterns is greater than or equal to 4. The final extracted semantic segments for each password in the dataset are as follows: password 111111 contains the semantic segments 111 (single-character repetition pattern), 1111 (single-character repetition pattern), 11111 (single-character repetition pattern), 111111 (single-character repetition pattern); password watermelon contains the semantic segments water (common English word), melon (common English word), watermelon (common English word); password smith@123 contains the semantic segments smith (surname pattern) and 123 (sequential pattern); password ojcsdr#5056 has no semantic segments.
[0138] The optimal password segmentation is determined using dynamic programming. Taking watermelon as an example, two arrays of length 11, maxSemLen and minSemCount, are created and initialized... and Starting from the 8th character, iterate through each character in watermelon in reverse order.
[0139] Iterate through the 8th, 7th, and 6th characters 'o'. The string starting from these positions is not a semantic segment, therefore... , .
[0140] When we reach the 5th character 'm', the melon starting from this position is a semantic segment, which we will discuss in two cases:
[0141] If we add the semantic meaning of melon, then... , ;
[0142] Without semantics, then , Based on the principle of "maximum semantic coverage and minimum number of semantic segments", the first case is selected.
[0143] When traversing to the 4th, 3rd, 2nd, and 1st characters, the strings starting from these positions are not semantic segments, therefore... , .
[0144] When we reach the 0th character 'w', the characters 'water' and 'watermelon' starting from this position form a semantic segment, which we will discuss in three cases:
[0145] Adding the semantics of "water" would then , .
[0146] Add watermelon semantics, , .
[0147] Without semantics, then , .
[0148] Based on the principle of "maximum semantic coverage and minimum number of semantic segments", the second option is selected.
[0149] Finally, by traversing through the data, the optimal segment for the password "watermelon" is [watermelon]. Similarly, the optimal segment for the password "111111" is [111111], the optimal segment for the password "smith@123" is [smith, @, 123], and the optimal segment for the password "ojcsdr@5056" is [ojcsdr@5056].
[0150] The semantic enhancement parameter β is set to a default value of 1. During training, non-semantic segments are trained using L, D, S structures, and semantic segments are trained using their corresponding semantic patterns. Taking the password smith@123 as an example, its optimal segmentation is [smith, @, 123], and the corresponding password structure is as follows: , , , Similarly, train other commands, and after normalization, obtain... , , , , , , , , , , .
[0151] Generate semantically enhanced passwords. Based on the probability distribution of the obtained password structure and the probability distribution of the structure padding segments, and combined with a priority queue, generate passwords sorted from highest to lowest probability as follows:
[0152] ;
[0153] ;
[0154] ;
[0155] ;
[0156] ;
[0157] .
[0158] This invention categorizes password semantic patterns into 4 types, totaling 14: simple patterns, date patterns, vocabulary patterns, and name patterns. Simple patterns include single-character repetition patterns, string repetition patterns, sequential patterns, keyboard patterns, and palindrome patterns. Date patterns include YYYYMMDD, YYMMDD, MMDD, and YYYY. Vocabulary patterns are divided into website name-related words and common English words. Name patterns include surname patterns, given name patterns, and full name patterns. Furthermore, to address the issue of matching multiple semantic patterns within the same semantic segment, different priorities are assigned to different semantic patterns: Simple patterns (sequential patterns > single-character repetition patterns > string repetition patterns > keyboard patterns > palindrome patterns) > Vocabulary patterns (common English words > website name-related words) > Name patterns (full name patterns > surname patterns > given name patterns) and Simple patterns (sequential patterns > single-character repetition patterns > string repetition patterns > keyboard patterns > palindrome patterns) > Date patterns. The rationale for this priority setting is that the higher the prevalence of a pattern in the password, the higher its priority. This classification and priority definition method provides a foundation for multi-semantic fusion password guessing methods.
[0159] This invention first extracts all semantic segments from the password, and then segments the password based on the principle of "maximum semantic segment length and minimum number of semantic segments". In this process, dynamic programming is used to optimize the time complexity of selecting the optimal segmentation. Specifically, two state arrays of the same length as the password are maintained to store the current maximum semantic coverage and minimum number of semantic segments, respectively. The transitions between states rely on predefined state transition equations. The password segmentation method based on dynamic programming reduces the time complexity from O(2^3) to O(2^3). n Reduced to O(n) 2 ), where n is the password length.
[0160] This invention integrates semantic patterns into a probabilistic context-free grammar (PCFG) to guide the generation of semantically enhanced passwords. Specifically, semantic patterns are treated as having the same status as L, D, and S in PCFG. During the training phase, not only are the probabilities of L, D, S and their corresponding padding strings calculated, but also the probabilities of semantic patterns such as repetition patterns and sequential patterns and their corresponding padding strings are calculated. During the generation phase, in addition to common L, D, S structures, multiple semantic patterns are combined to generate semantically enhanced passwords. Using this invention to guess "Rockyou," under 1014 guesses, this invention guesses 10.18% more passwords than PCFG.
[0161] This invention provides semantic enhancement parameters for each semantic pattern. By setting different enhancement parameters during the training phase, the weight contribution of different semantic patterns in the password generation process can be adjusted, thereby achieving fine-grained control over the degree of semantic enhancement while preserving the original structural statistical features. The enhancement parameter is represented by β, which serves as an adjustment factor for the counting in the statistical template and the padding field. Any aspects not described in this invention are applicable to existing technologies.
[0162] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0163] Any aspects not covered in this invention are applicable to existing technologies.
Claims
1. A password guessing method based on a multi-semantic fusion probability context-free grammar, characterized in that, The method comprises the following steps: Step S1, performing multi-semantics segmentation preprocessing on the training set of passwords to obtain a password segmentation result set, wherein the multi-semantics segmentation preprocessing comprises: enumerating the substrings of each training password and performing matching recognition in a preset semantic mode set to obtain semantic segments, the semantic mode set comprising simple mode, date mode, vocabulary mode and name mode; for the same semantic segment that matches multiple semantic modes simultaneously, determining a unique semantic mode label according to a preset semantic mode priority, and selecting an optimal segmentation scheme between semantic segments and non-semantic segments based on the principle of maximum semantic coverage and least number of semantic segments by using dynamic programming to form the password segmentation result set; Step S2, training a multi-semantics fusion probability context-free grammar model based on the password segmentation result set, encoding non-semantic segments into structure identifiers according to character types and encoding semantic segments into semantic identifiers according to their semantic modes, counting password structure and substructure filling segment counts, and configuring semantic enhancement parameters β for each semantic mode, normalizing the counts corresponding to semantic segments after weighting by β, obtaining password structure probability distribution and conditional probability distribution of substructure filling segments; Step S3, generating candidate passwords in descending order of generation probability by using a priority queue based on the password structure probability distribution and conditional probability distribution, and forming a generated password dictionary; Step S4, outputting a preset number of guessed passwords from the generated password dictionary as password guessing results; The step S1 comprises the following sub-steps: Step S101, enumerating all substrings of each password in the training set, identifying whether each substring belongs to any semantic mode in the preset semantic mode set, and adding the substrings identified as semantic modes to a semantic segment set S as semantic segments; Step S102, for the same semantic segment that matches multiple semantic modes simultaneously in the semantic segment set S, selecting a unique semantic mode to mark the semantic segment according to a preset semantic mode priority; Step S103, selecting an optimal segmentation scheme composed of semantic segments and non-semantic segments on each password based on the segmentation principle by using a dynamic programming method, recording the optimal segmentation scheme as a password segmentation result, and obtaining the password segmentation result set by aggregating all password segmentation results, wherein the segmentation principle is maximum semantic coverage and least number of semantic segments; The process of determining the optimal segmentation scheme by dynamic programming in step S103 comprises: maintaining a first state array, a second state array and a third state array with the same length as the password, the first state array being used to record the maximum semantic coverage length in all candidate segmentation schemes before the current position, the second state array being used to record the least number of semantic segments under the maximum semantic coverage length, and the third state array being used to record the semantic segment end position or mark the current character as belonging to a non-semantic segment; Enumerate all semantic segment candidates with the position as the start position in the semantic segment set S, and compare the semantic coverage length and the number of semantic segments extended by the semantic segment with the current recorded state. If the semantic coverage length is larger or the semantic coverage length is the same and the number of semantic segments is smaller, update the first state array, the second state array, and the third state array; Inherit the state of the previous position and keep the existing record when the semantic coverage length is the same and the number of semantic segments does not increase; After the traversal is completed, start from the password start position, and according to the semantic segment end position and the non-semantic segment mark recorded in the third state array, sequentially reconstruct the segmented list segments containing semantic segments and non-semantic segments. The segmented list segments is the final password segmentation result that meets the segmentation principle.
2. The password guessing method based on the multi-semantic fusion probability context-free grammar according to claim 1, wherein: The simple mode includes a single character repetition mode, a string repetition mode, a sequential mode, a keyboard mode, and a palindrome mode; The date mode includes a YYYYMMDD mode, a YYMMDD mode, a MMDD mode, and a YYYY mode; The vocabulary mode includes a website name related vocabulary mode and a common English word mode; The name mode includes a surname mode, a given name mode, and a full name mode; The preset semantic mode priority satisfies: the sequential mode in the simple mode has a higher priority than the single character repetition mode, the single character repetition mode has a higher priority than the string repetition mode, the string repetition mode has a higher priority than the keyboard mode, the keyboard mode has a higher priority than the palindrome mode; The common English word mode in the vocabulary mode has a higher priority than the website name related vocabulary mode; The full name mode in the name mode has a higher priority than the surname mode, and the surname mode has a higher priority than the given name mode; The overall priority satisfies: the simple mode has a higher priority than the vocabulary mode, the vocabulary mode has a higher priority than the name mode, and the simple mode has a higher priority than the date mode.
3. The password guessing method based on multi-semantic fusion based probabilistic context-free grammar as claimed in claim 2, wherein, The semantic mode recognition method in the step S101 is: The single character repetition mode, the string repetition mode, the sequential mode, and the palindrome mode use pattern matching recognition, and the keyboard mode uses keyboard layout sequence matching recognition; The date mode, the vocabulary mode, and the name mode use a preset external dictionary for dictionary matching recognition; The semantic segment length of the single character repetition mode, the string repetition mode, and the sequential mode is greater than or equal to 3 characters, the semantic segment length of the palindrome mode is greater than or equal to 4 characters, and the semantic segment length of other semantic modes is greater than or equal to a preset minimum length threshold.
4. The password guessing method based on multi-semantic fusion based probabilistic context-free grammar as claimed in claim 3, wherein, The step S2 includes the following sub-steps: Step S201, encode the segmentation of each password in the password segmentation result set, wherein the non-semantic segment is divided into a letter sub-segment, a number sub-segment, and a symbol sub-segment according to the character type, and L, D, and S are used as structure identifiers; and the semantic segment is encoded as a corresponding semantic mode type identifier according to the semantic mode to which it belongs. Step S202, extracting the encoded segmented sequence into password structures and substructure filling segments, the password structure is used to describe the combination order of L, D, S and each semantic mode identifier, and the substructure filling segment is used to record the specific string corresponding to each structure position; Step S203, counting the number of occurrences of each password structure in the training set and the number of occurrences of each substructure filling segment in its structure position, and configuring a semantic enhancement parameter β for each semantic mode, weighting the count of the semantic segment corresponding filling segment according to its β, thereby obtaining the password structure count and the substructure filling segment count after semantic enhancement; Step S204, normalizing the weighted count to obtain the password structure probability distribution and the conditional probability distribution of each substructure filling segment under a given password structure, and the semantic enhancement parameter β is set to 1 by default.
5. The password guessing method based on multi-semantic fusion based probabilistic context-free grammar as claimed in claim 4, wherein, The encoding mode of the semantic segment in step S201 is as follows: Encode the single character repetition mode as the identifier single_character_repetition; Encode the string repetition mode as the identifier segment_repetition; Encode the sequence mode as the identifier sequence_up or sequence_down; Encode the keyboard mode as the identifier keyboard; Encode the palindrome mode as the identifier palindrome; Encode the YYYYMMDD date mode as the identifier YYYYMMDD; Encode the YYMMDD date mode as the identifier YYMMDD; Encode the MMDD date mode as the identifier MMDD; Encode the YYYY date mode as the identifier YYYY; Encode the website name related vocabulary mode as the identifier website_related; Encode the common English word mode as the identifier common_English_word; Encode the last name mode as the identifier lastname; Encode the first name mode as the identifier firstname; Encode the full name mode as the identifier fullname; The encoded semantic mode identifier has the same status as L, D and S in the password structure.
6. The password guessing method based on multi-semantic fusion based probabilistic context-free grammar as claimed in claim 5, wherein, The step S3 includes the following substeps: Step S301, creating a maximum heap sorted by password generation probability as a priority queue, the heap node stores the generated password pw, the corresponding generation probability pro and the password filling substructure index pivot; Step S302, for each password structure obtained in step S2, preferentially selecting the filling string combination with the highest probability of each substructure filling segment under the structure to form an initial password, calculating the generation probability of each initial password, the generation probability is the product of the password structure probability and the substructure filling segment probability, and pushing the generated password pw, the generation probability pro and the initial filling substructure index pivot into the priority queue; Step S303, popping out the node with the maximum generation probability from the priority queue, and recording the generated password pw in the generated password dictionary; For each substructure position after the pivot in the node, the original fill-in string is replaced by the fill-in string with the next highest probability at the position to form a new generated password, and the corresponding generation probability is recalculated, and the newly generated password, the generation probability and the updated fill-in substructure index are pushed into the priority queue; Step S304, repeat step S303 until the priority queue is empty or the number of candidate passwords recorded in the generated password dictionary reaches the preset upper limit, the passwords arranged in the record order in the generated password dictionary are the guessing password sequence sorted from large to small according to the generation probability.
7. An electronic device, comprising: The computer readable instructions, when executed by the processor, perform the steps of the password guessing method based on the multi-semantics fusion probability context-free grammar according to any one of claims 1-6.
8. A storage medium having stored thereon a computer program, characterized in that The computer program, when executed by the processor, performs the steps of the password guessing method based on the multi-semantics fusion probability context-free grammar according to any one of claims 1-6.
Citation Information
Patent Citations
Legal document paragraphing method and apparatus
CN108427667A
Code peculiar smell detection method and system based on AST code measurement and code semantics
CN119248277A