[Reprinted] Linux password cracking

Source: Internet
Author: User
Tags crypt

After the root permission is logged on, the/etc/shadow file is obtained and the text is opened.

Shadow file:

In Linux, the/etc/shadow file stores the user's password hash value.

The ciphertext format of the password stored in shadow is as follows:

$ ID $ salt $ encrypted

Id indicates the hash algorithm used:

The following values are recommended:

Id | Method

--------------------------

1 | MD5

2a | blowfish (not in mainline glibc; added in some

| Linux distributions)

5 | SHA-256 (since glibc 2.7)

6 | SHA-512 (since glibc 2.7)

Salt: it is an interference value that uses the hash algorithm above to hash the password.

Encrypted:

This value is the hash of the password, but it is not a direct Hash ("passwd"), but a hash ("passwd + salt") and then encoded.

Practical application:

1. brute-force cracking (only brute-force cracking) on the premise of shadow files

2. Implement your own passwd command. It is useful in some scenarios (in cloud computing, different passwords can be easily generated for Linux virtual machines using the same template)

Example:

This program uses the crypt function in Linux to generate a password hash that can replace the password hash in the password field in shadow.

# DEFINE _ xopen_source

# Include <stdio. h>

# Include <unistd. h>

// For more information about how to use crypt, see man crypt.

// Exemple:

//./Bin password $6 $ ffffffff

Int main (INT argc, char * argv [])

{

If (argc! = 3)

Return-1;

Char * Buf = crypt (const char *) argv [1], (const char *) argv [2]);

Printf ("salt: % s, crypt: % s \ n", argv [2], Buf );

Return 0;

}

Compilation Method: gcc a. C-lcrypt-O passwd

Use:./passwd 123 \ $6 \ $ abcdefgh

Output:

Salt: $6 $ abcdefgh, crypt: $6 $ abcdefgh $ Encrypt

Use $6 $ abcdefgh $ domains to replace the password domain of the user you want to modify in the shadow file, and the password is automatically changed to 123.

Shadow file format:

See here for details: http://www.tldp.org/HOWTO/Shadow-Password-HOWTO.html

Crypt usage:

See man crypt.

Source http://hi.baidu.com/gzlick/item/fdedea7b45517a2c5d1789e0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.