Password cracking method and system based on generative adversarial network with gradient penalty
Through the generative adversarial network based on gradient penalty, the password feature distribution is learned and a highly similar password set is generated, which solves the problem of low password cracking efficiency in the existing technology and achieves a more efficient password cracking effect.
Patent Information
- Application Number
- CN202010697341.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-20
- Publication Date
- 2024-10-15
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN111966997B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of password cracking, and in particular to a password cracking method and system based on a gradient penalty-based generative adversarial network. Background Art
[0002] In the digital age, no matter your age and gender, your life is closely related to passwords. The most commonly used passwords are text passwords, and users' passwords usually have certain rules, such as their birthdays, some common words such as apple, password, etc. The same is often true for the passwords of users in the same user community or website. Most of the existing password cracking methods are brute force cracking methods, such as the rainbow table method, which generally takes the method of exchanging time for space, and requires a large amount of storage devices. The amount of password data is at the TB level, and these methods do not classify passwords, and there is no difference for passwords in different websites or countries. However, passwords in different communities, countries and websites are often different, and they have their own characteristics. Based on this feature, this method uses a generative adversarial network to learn the password distribution characteristics of users in a community or a website, so that password cracking can be more efficient. Summary of the invention
[0003] In order to overcome the defects and shortcomings of the prior art, the present invention provides a password cracking method and system based on a generative adversarial network with gradient penalty. By using a generative adversarial network through game training between a generator and a discriminator, the generator learns the characteristic distribution of the training data password, so that the generator generates a password set with a high similarity to the training data, and cracks the passwords of specific websites or user communities.
[0004] In order to achieve the above object, the present invention adopts the following technical solutions:
[0005] The present invention provides a password cracking method based on a gradient penalty generative adversarial network, comprising the following steps:
[0006] Data preprocessing: determine the length of the longest password and the maximum number of characters allowed in a password, remove passwords that exceed the preset value and limit the number of characters in the password, use a character array to filter the original training passwords to obtain training data;
[0007] Network construction: construct the residual block structure, generator and discriminator, construct the residual block structure class, and construct the generator class and discriminator class based on the residual block structure class, and construct the gradient penalty class required in the discriminator loss function;
[0008] Conduct network training: Generate corresponding generator and constructor instances, initialize the corresponding optimizers of the generator and constructor, and perform iterative training on the training data;
[0009] The trained generator parameters are used to generate a cracking password set.
[0010] As a preferred technical solution, the specific steps of data preprocessing include:
[0011] Converting the original data training data: converting the original password file into a character array consisting of the characters contained in the password and a character dictionary consisting of the characters contained in the password, wherein the character dictionary uses the characters appearing in the password as keys and the positions of the characters in the character array as values;
[0012] Extract training data: Extract the final training data based on the character array. If the characters in a row of passwords in the original training data do not appear in the character array, the row of passwords is filtered.
[0013] As a preferred technical solution, the construction generator class includes the following specific steps:
[0014] Input random noise z of the latent space dimension size and forward propagate through the network to generate the password.
[0015] As a preferred technical solution, the input data dimension of the generator is [number of training samples each time, latent space dimension]. First, it needs to be linearly converted into a matrix of [number of training samples each time, (password length * middle layer dimension)] and then dimensionally split into a matrix of [number of training samples each time, password length, middle layer dimension], which is passed into the residual network. Through one-dimensional convolution, a matrix of [number of training samples each time, character type, password length] is obtained, and then the dimension order is transformed into a matrix of [number of training samples each time, password length, character type].
[0016] As a preferred technical solution, the discriminator class is constructed, and the output result of the final discriminator is a matrix of dimension [number of training samples each time, 1], which represents the score of each batch of training samples in the discriminator.
[0017] As a preferred technical solution, iterative training is performed on the training data. When training the generator network and the discriminator network, when training one of the network structures, the parameters in the other network structure remain unchanged;
[0018] Train the discriminator, use the real password data and the password data generated by the generator to train the generator, and freeze the model parameters of the generator during backpropagation and only update the model parameters of the discriminator;
[0019] Train the generator, use the generator to generate fake passwords, and input the generated passwords into the discriminator to generate labels for the passwords. Freeze the model parameters of the discriminator in the back-propagation parameter update and only update the model parameters of the generator.
[0020] As a preferred technical solution, the method of using trained generator parameters to generate a blast password set specifically includes: the generator takes randomly generated noise z of the latent space dimension size as input, and then performs forward propagation to obtain the blast password set.
[0021] As a preferred technical solution, the trained generator parameters are used to generate a blasting password set, and the training data is also digitized to convert the password characters in all the training data into values corresponding to the characters in the password dictionary. The generated blasting password set is a matrix of the following dimensions: [number of training samples each time, password length, character type]. First, the argmax function is used for conversion, and the subscript of the character with the highest probability is taken as the specific value to reduce the dimension. The intermediate result generated is a matrix [number of training samples each time, password length], where the password length dimension is the subscript of the position of the character in the character array, and the subscript conversion is performed according to the character data to obtain the generated specific password.
[0022] The present invention also provides a password cracking system based on a gradient penalty generative adversarial network, comprising: a data preprocessing module, a network construction module, a network training module and a blasting password set generation module;
[0023] The data preprocessing module is used to determine the length of the longest password and the maximum number of characters allowed in the password, remove characters exceeding a preset value and limit the number of character types in the password, and use a character array to filter the original training password to obtain training data;
[0024] The network construction module is used to construct a residual block structure, a generator and a discriminator. First, a residual block structure class is constructed, and a generator class and a discriminator class are constructed based on the residual block structure class, and then a gradient penalty class required in the discriminator loss function is constructed;
[0025] The network training module is used to generate corresponding generator and constructor instances, initialize the optimizers corresponding to the generator and constructor, and perform iterative training on the training data;
[0026] The blasting password set generation module is used to generate a blasting password set using trained generator parameters.
[0027] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0028] (1) This method adopts a network structure based on residual blocks, which solves the problem of poor training effect as the network depth increases and alleviates the gradient vanishing problem in deep neural networks.
[0029] (2) This method adopts WGAN (Wasserstein GAN) based on gradient penalty. The advantage of Wasserstein distance is that it can reflect the distance between the two distributions even if there is no overlap between the two distributions. The gradient penalty used satisfies the Lipschitz continuity condition and avoids the gradient vanishing or gradient exploding caused by weight clipping. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A flowchart of a password cracking method of a generative adversarial network based on gradient penalty of the present invention;
[0031] Figure 2 A schematic diagram of the discriminator structure framework of the password cracking method of the gradient-penalty-based generative adversarial network of the present invention;
[0032] Figure 3 This is a schematic diagram of the generator structure framework of the password cracking method of the generative adversarial network based on gradient penalty of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0034] Example
[0035] like Figure 1 As shown, this embodiment provides a password cracking method based on a gradient penalty generative adversarial network, comprising the following steps:
[0036] S1: Perform data preprocessing. The specific steps include:
[0037] S11: Determine the length of the longest password and the maximum number of characters allowed in the password;
[0038] Regarding the character types, this embodiment is set to 2048, which can include almost all characters that can appear in the password. In terms of length, passwords with a length of 10 or less are selected as experimental data. Passwords with a length of less than 10 will be padded with the character "`". The password array is an array containing all the password types in the training data. The dictionary uses the character as the key and the subscript of the character in the password array as the value;
[0039] S12: Converting the original data training data: converting the original password file into a character array composed of characters contained in the password and a character dictionary composed of characters contained in the password, the dictionary uses the characters appearing in the password as keys and the positions of the characters in the character array as values;
[0040] S13: Extracting training data: extracting final training data according to the character array. If the characters in a row of passwords in the original training data do not appear in the character array, the row of passwords is filtered.
[0041] In this embodiment, the purpose of data preprocessing is to remove passwords that are too long and limit the number of character types in the password. Since the read-in data set may contain these overlong passwords and other unnecessary character types, it is necessary to filter the original training passwords through a character array to obtain the final training data;
[0042] S2: Figure 2 , Figure 3 As shown, the network construction mainly includes a residual block structure, a generator and a discriminator based on the structure, a residual block structure class, and a generator class and a discriminator class based on the residual block structure class to implement the gradient penalty class, which includes:
[0043] S21: construct residual block structure class;
[0044] The main function of the residual block structure is to prevent the training effect from deteriorating as the depth of the network increases. The traditional convolutional layer or fully connected layer will have more or less information loss and other problems when transmitting information. The residual network with the residual block structure used in this embodiment solves this problem to some extent.
[0045] S22: Use the residual block structure class to construct a generator class;
[0046] This embodiment constructs a generator class, which needs to generate a password using randomly initialized vector noise z from the latent space;
[0047] In this embodiment, the main function of the generator is to generate a password by inputting a random noise z of the latent space dimension size and performing forward propagation through the network;
[0048] The input data dimension of the generator is [number of training samples each time, latent space dimension], and the input data of the residual block is a three-dimensional matrix. In order to finally generate the corresponding password data, it is first necessary to linearly transform it into a three-dimensional matrix of [number of training samples each time, (password length * middle layer dimension)] and then split the dimension into a matrix of [number of training samples each time, password length, middle layer dimension], and pass it into the residual network. Then, a one-dimensional convolution is performed to obtain a matrix of [number of training samples each time, character type, password length], and then the dimension order is transformed into a matrix of [number of training samples each time, password length, character type]; then softmax is performed to obtain the final output data. Note that the final output data is not the real password, but the probability distribution of each character in the password on all character types, so the argmax function is also required to obtain the final password;
[0049] S23: Use the residual block structure class to construct the discriminator class;
[0050] This embodiment constructs a discriminator class, and the final output result of the discriminator is a matrix with a dimension of [number of training samples each time, 1], which represents the score of each batch of training samples in the discriminator;
[0051] In this embodiment, the main task of the discriminator is to receive the one-hot encoded data of the password as input, and to determine whether the password is a fake password or a real password through a one-dimensional convolutional layer, a residual network layer, and a final linear layer;
[0052] S24: Construct the gradient penalty class required in the discriminator loss function;
[0053] In traditional GAN networks, the loss functions of the generator are generally the following two:
[0054]
[0055] Among them, Pg represents the sample distribution generated by the generator, and Pr represents the real sample distribution. The problem with Formula 1 is that under the optimal discriminator, the loss function of the generator can be equivalently transformed to minimize the JS divergence between the real distribution Pr and Pg;
[0056] That can be converted into:
[0057] 2JS(Pr‖Pg)-2log2 (Formula 3)
[0058] KL divergence:
[0059]
[0060] JS Divergence:
[0061]
[0062] However, the JS divergence is usually fixed to a constant log2, which means that the gradient is 0 for gradient descent;
[0063] If the generator uses formula 2 as the loss function, it will lead to two problems. One is the unstable gradient and the other is the lack of diversity in collapse mode. In this case, the generator would rather generate more repeated but "safe" samples than generate diverse samples:
[0064] The loss function of WGAN uses Wasserstein distance instead of JS divergence to solve the above problems.
[0065] The Wasserstein distance is defined as:
[0066]
[0067] The discriminator function D(x) needs to satisfy Lipschitz continuity, which is actually an additional restriction imposed on a continuous function, requiring the existence of a constant so that any two elements x1 and x2 in the domain satisfy:
[0068] |f(x1)-f(x2)|≤K|x1-x2|
[0069] The Lipschitz constant of a function is called k. When the function satisfies Lipschitz continuity, a set of parameters ω can be used to define a series of possible functions f ω , at this time, the solution of formula 4 can be approximated as follows:
[0070]
[0071] So far, we can construct a discriminator network f with parameter ω ω , while satisfying Lipschitz continuity, such that:
[0072] L=E x ~P r [f ω (x)]-E x ~P g [f ω (x)]
[0073] Get the maximum possible (the discriminator hopes that the distance between the real password and the fake password is as far as possible);
[0074] Next, the generator needs to approximately minimize the Wasserstein distance. The Wasserstein distance can be minimized. Due to the excellent properties of the Wasserstein distance, there is no need to worry about the vanishing gradient of the generator. Considering that the first term of L is independent of the generator, we get the two loss functions of WGAN.
[0075] WGAN generator loss function:
[0076] WGAN discriminator loss function:
[0077] In the network, the Lipschitz restriction is reflected in the requirement that the Lp-norm of the gradient of the discriminator function D(x) is no greater than a finite constant K in the entire sample space χ:
[0078]
[0079] The Lipschitz restriction requires that the gradient of the discriminator does not exceed K. Then an additional loss term can be set to highlight this restriction, which is the gradient penalty. At this time, the final version of the discriminator loss function is:
[0080]
[0081] The third term is the gradient penalty term;
[0082] In this embodiment, the loss function of the discriminator mainly includes three aspects:
[0083] 1) The discriminator scores the real password data
[0084] 2) Discriminator’s score for fake password data
[0085] 3) Gradient penalty part
[0086] The loss function of the generator is only the score of the discriminator on the fake password data.
[0087] S3: Perform network training;
[0088] S31: Generate corresponding generator and constructor instances;
[0089] S32: Initialize the optimizers corresponding to the generator and constructor. Both networks use the Adam optimizer, and the parameter betas is set to (0.5, 0.9);
[0090] S33: start iterative training on the final training data set;
[0091] In this embodiment, iterative training is performed on the final training data set. The training methods for the discriminator and the generator are different, and when training one of the network structures, the parameters in the other network structure must remain completely unchanged.
[0092] Train the discriminator, use the real password data and the password data generated by the generator to train the generator, and freeze the model parameters of the generator during back propagation;
[0093] Train the generator, use the generator to generate a fake password, and input the generated password into the discriminator. At this time, the label of the password should be 1, that is, you need to tell the discriminator that the generated fake password is the real password, and freeze the model parameters of the discriminator in the back-propagation parameter update, and only update the model parameters of the generator.
[0094] S4: Generate password data;
[0095] S41: Use the trained generator parameters to generate a blast password set. The generator needs to take the randomly generated noise z of the latent space dimension as input, and then perform forward propagation to obtain the blast password set;
[0096] In this embodiment, the training data also needs to be digitized to convert the password characters in all the training data into the values corresponding to the characters in the password dictionary (i.e., the subscripts of the characters in the password array). The trained generator is used to generate the blasting password set. The final result generated by the generator is not a specific password, but a matrix of the following dimensions: [number of training samples each time, password length, character type]. First, it is necessary to transform the dimension of "character type" and use the argmax function to convert it. The subscript of the character with the highest probability is taken as the specific value to reduce the dimension. The intermediate result generated is a matrix of the following dimensions [number of training samples each time, password length]. The password length dimension is not a specific password character, but the position subscript of the character in the character array in step S12. Then, the subscript conversion is performed according to the character data to obtain the generated specific password.
[0097] The training model process of this embodiment requires that the digitized password be subjected to one-hot encoding. For example, assuming that the original data is a matrix of (64, 10) dimensions, 64 is the number of training samples each time, 10 is the password length, and our character types are 80, then the data after one-hot encoding is data of (64, 10, 80) dimensions, and only one data in the third dimension is 1, and the other data are 0. The position of 1 is the value of the second dimension of the original data (64, 10);
[0098] This embodiment also provides a password cracking system based on a gradient penalty generative adversarial network, comprising: a data preprocessing module, a network construction module, a network training module and a blast password set generation module;
[0099] The data preprocessing module is used to determine the length of the longest password and the maximum number of characters allowed in the password, remove characters exceeding a preset value and limit the number of character types in the password, and use a character array to filter the original training password to obtain training data;
[0100] The network construction module is used to construct a residual block structure, a generator and a discriminator, construct a residual block structure class, and construct a generator class and a discriminator class based on the residual block structure class, and construct a gradient penalty class required in the discriminator loss function;
[0101] The network training module is used to generate corresponding generator and constructor instances, initialize the optimizers corresponding to the generator and constructor, and perform iterative training on the training data;
[0102] The blasting password set generation module is used to generate a blasting password set using trained generator parameters.
[0103] 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 password cracking method based on a gradient penalty generative adversarial network, characterized in that: The steps include: Data preprocessing: determine the length of the longest password and the maximum number of characters allowed in a password, remove passwords that exceed the preset value and limit the number of characters in the password, use a character array to filter the original training passwords to obtain training data; Network construction: construct the residual block structure, generator and discriminator. First, construct the residual block structure class, and then construct the generator class and discriminator class based on the residual block structure class, and then construct the gradient penalty class required in the discriminator loss function. The construction of the generator class includes the following specific steps: Input random noise z of latent space dimension size and generate password through forward propagation through the network; The input data dimension of the generator is [number of training samples each time, latent space dimension]. First, it needs to be linearly converted into a matrix of [number of training samples each time, (password length * middle layer dimension)] and then dimensionally split into a matrix of [number of training samples each time, password length, middle layer dimension], which is passed into the residual network. Through one-dimensional convolution, a matrix of [number of training samples each time, character type, password length] is obtained, and then the dimension order is transformed into a matrix of [number of training samples each time, password length, character type]; The discriminator class is constructed, and the output result of the final discriminator is a matrix of dimension [number of training samples each time, 1], which represents the score of each batch of training samples in the discriminator; Generator loss function: The discriminator loss function is: Among them, Pg represents the sample distribution generated by the generator, Pr represents the real sample distribution, and f ω represents the discriminator network with parameter ω, D(x) represents the discriminator function, χ represents the sample space, and K represents a constant; Conduct network training: Generate corresponding generator and constructor instances, initialize the corresponding optimizers of the generator and constructor, and perform iterative training on the training data; Use the trained generator parameters to generate a cracking password set; The method of using the trained generator parameters to generate a blast password set specifically includes: the generator takes the randomly generated noise z of the latent space dimension size as input, and then performs forward propagation to obtain the blast password set; The method uses the trained generator parameters to generate a blasting password set, and the training data is also digitized to convert the password characters in all the training data into values corresponding to the characters in the password dictionary. The generated blasting password set is a matrix of the following dimensions: [number of training samples each time, password length, character type]. First, the argmax function is used for conversion, and the subscript of the character with the highest probability is taken as the specific value to reduce the dimension. The intermediate result generated is a matrix [number of training samples each time, password length], where the password length dimension is the subscript of the position of the character in the character array, and the subscript conversion is performed according to the character data to obtain the generated specific password.
2. The password cracking method based on the gradient penalty generative adversarial network according to claim 1 is characterized in that: The specific steps of data preprocessing include: Converting the original data training data: converting the original password file into a character array consisting of the characters contained in the password and a character dictionary consisting of the characters contained in the password, wherein the character dictionary uses the characters appearing in the password as keys and the positions of the characters in the character array as values; Extract training data: Extract the final training data based on the character array. If the characters in a row of passwords in the original training data do not appear in the character array, the row of passwords is filtered.
3. The password cracking method based on the gradient penalty generative adversarial network according to claim 1 is characterized in that: Perform iterative training on the training data. When training the generator network and the discriminator network, when training one of the network structures, the parameters in the other network structure remain unchanged. Train the discriminator, use the real password data and the password data generated by the generator to train the generator, and freeze the model parameters of the generator during back propagation, and only update the model parameters of the discriminator; Train the generator, use the generator to generate fake passwords, and input the generated passwords into the discriminator to generate labels for the passwords. Freeze the model parameters of the discriminator in the back-propagation parameter update and only update the model parameters of the generator.
4. A password cracking system based on a gradient-penalized generative adversarial network, characterized in that: include: Data preprocessing module, network construction module, network training module and blasting code set generation module; The data preprocessing module is used to determine the length of the longest password and the maximum number of characters allowed in the password, remove passwords whose length exceeds a preset value and limit the number of character types in the password, and use a character array to filter the original training password to obtain training data; The network construction module is used to construct a residual block structure, a generator and a discriminator. First, a residual block structure class is constructed, and a generator class and a discriminator class are constructed based on the residual block structure class, and then a gradient penalty class required in the discriminator loss function is constructed; The construction generator class specifically includes: Input random noise z of latent space dimension size and generate password through forward propagation through the network; The input data dimension of the generator is [number of training samples each time, latent space dimension]. First, it needs to be linearly converted into a matrix of [number of training samples each time, (password length * middle layer dimension)] and then dimensionally split into a matrix of [number of training samples each time, password length, middle layer dimension], which is passed into the residual network. Through one-dimensional convolution, a matrix of [number of training samples each time, character type, password length] is obtained, and then the dimension order is transformed into a matrix of [number of training samples each time, password length, character type]; The discriminator class is constructed, and the output result of the final discriminator is a matrix of dimension [number of training samples each time, 1], which represents the score of each batch of training samples in the discriminator; Generator loss function: The discriminator loss function is: Among them, Pg represents the sample distribution generated by the generator, Pr represents the real sample distribution, and f ω represents the discriminator network with parameter ω, D(x) represents the discriminator function, X represents the sample space, and K represents a constant; The network training module is used to generate corresponding generator and constructor instances, initialize the optimizers corresponding to the generator and constructor, and perform iterative training on the training data; The blasting password set generation module is used to generate a blasting password set using trained generator parameters; The method of using the trained generator parameters to generate the blast password set specifically includes: the generator takes the randomly generated noise z of the latent space dimension size as input, and then performs forward propagation to obtain the blast password set; The method uses the trained generator parameters to generate a blasting password set, and the training data is also digitized to convert the password characters in all the training data into values corresponding to the characters in the password dictionary. The generated blasting password set is a matrix of the following dimensions: [number of training samples each time, password length, character type]. First, the argmax function is used for conversion, and the subscript of the character with the highest probability is taken as the specific value to reduce the dimension. The intermediate result generated is a matrix [number of training samples each time, password length], where the password length dimension is the subscript of the position of the character in the character array, and the subscript conversion is performed according to the character data to obtain the generated specific password.
Citation Information
Patent Citations
WGAN method based on text generation
CN107590531A
Automatic text generation method and device
CN108334497A
Image amplification method and system based on generative adversarial network
CN110070124A
Image super-resolution reconstruction method based on improved generative adversarial network
CN110189253A
Handwritten numeral generation method based on parameter optimization generative adversarial network
CN110598806A
