当前位置:网站首页>/Can etc / shadow be cracked?
/Can etc / shadow be cracked?
2022-04-23 10:23:00 【The goose is like a small drop of stone ~】
List of articles
Tips:
Hash ( The algorithm is also called hash ) Not encryption , It's not coding ; Hash is irreversible , Encryption is reversible ; No key is required for encoding and decoding , Encryption and decryption require a key
Common coding & Hash & The encryption and decryption algorithm is as follows
code :base64 Hex code Huffman code
Hash :md5 SHA-1 SHA-128 SHA-256 SHA-512 SM3
encryption :
- Symmetric encryption ( Add and remove the secret key ):DES AES SM4
- Asymmetric encryption ( The encryption and decryption keys are different ):RSA DSA SM2
scene
utilize GlassFish Arbitrary file reading Loophole , Read out /etc/shadow
file , But the password is hashed , How to crack it ?
/etc/shadow The file is introduced
First of all Linux shadow Document and passwd The little difference between files
file | User accessible ? |
---|---|
/etc/shadow | All users can read |
/etc/passwd | root Readable |
cat /etc/shadow # Take a look at my own shadow One line of the file
root:$6$C.nLBV0u$Ya4XCw1/jEiqx8/nnwE0r6tEtw/l1zt5iUr8GMrsdxTN1Omp2uPVtFNIZb0ZsNFRImJvvj0CSgNvAcsZo7i6d0:18002:0:99999:7:::
And /etc/passwd
equally ,shadow Each field in the file also uses “ : : :” Colon separated , As shown below :
-
user name : A valid account name exists on the system .
-
password : Your password is saved in hash format . Hash value length should be at least 15-20 Characters , Include special characters 、 Numbers 、 Small letters, etc . Here is the hash value of the password . at present Linux My password is SHA512 Hash algorithm , It used to be MD5 or DES Algorithm .SHA512 Hash algorithm is more secure .
Be careful , The garbled code generated by this password can't be modified manually , If you modify it manually , The system will not recognize the password , Cause the password to fail . A lot of software through this function , Add... Before the password string “!”、“*” or “x” Disable the password temporarily .
The passwords of all pseudo users are “!!” or “*”, You can't log in without a password . Of course , If the newly created user does not set a password , So its password entry is also “!!”, Represents that the user has no password , Can not login . The password format is set to $id$salt$hashed,$id Value and GNU/Linux The hash algorithm used on corresponds to the following :
-
$1$ is MD5
-
$2a$ is Blowfish
-
$2y$ is Blowfish
-
$5$ is SHA-256
-
$6$ is SHA-512
-
-
Last password change (last changed): Date of last password change , Expressed as from 1970 year 1 month 1 Japan (Unix Time ) Days since . value 0 Has a special meaning , That is, the user should change the password when logging in the system next time . An empty field indicates that the password aging function is disabled .
-
minimum value : Minimum number of days between password changes , That is, the number of days remaining before the user is allowed to change the password again . Empty fields and values 0 Indicates that there is no minimum password duration .
-
Maximum : The maximum number of days a password is valid , After the user was forced to change her password again .
-
Warning : The number of days before the password expires , Warn the user that he must change / Her code
-
Inactive: The number of days after the password expires that the account is disabled .
-
Expire: The expiration date of the account , Expressed as from 1970 year 1 month 1 Days since .
What is salt ?
The plaintext password is passwd,salt Is a random string
hypothesis id=1, Namely choice md5 The hash algorithm .
So the process of adding salt is Calculation h a s h e d = m d 5 ( s a l t + p a s s w d ) hashed=md5(salt+passwd) hashed=md5(salt+passwd)
After the calculation, we are shadow Read in the file $id$salt$hashed 了
Be careful , This is an example only ,Linux I didn't study how to add salt ,salt It can also be in passwd Back ~
Can you crack it ?
Due to hash When , Adopted salt Mechanism , So the traditional rainbow watch will not work .
Without salt, the common password now hash The value base is too big , It's too easy to leak the password ,cmd5 Teach to be a man
The cracking methods include dictionary cracking and violent cracking . I can't find a good dictionary :https://github.com/DrKadron/List.txt
The cracking script is as follows , stay Linux Up operation (crypt This library is Linux Upper )
import crypt ## Import Linux Password encryption library
def testPass(cryptPass):
salt=cryptPass[cryptPass.find("$"):cryptPass.rfind("$")] ## Obtain salt value , contain $id part
dictFile=open('key.txt','r')
for word in dictFile.readlines():
word=word.strip("\n")
cryptWord=crypt.crypt(word,salt) ## Encrypt the value in the password dictionary with the salt value
if (cryptWord==cryptPass): ## Judge whether the encrypted data and password fields are equal
print ("[+]Found Password:"+word+"\n" ) ## If equal, print out
return
print ("[-] Password Not Found.\n")
return
def main():
passFile=open('shadow.txt')
for line in passFile.readlines(): ## Read everything in the file
if ":" in line:
user=line.split(":")[0] ## Get username
cryptPass=line.split(":")[1].strip(' ') ## Get password field
print ("[*] Cracking Password for:"+user)
testPass(cryptPass)
main()
I happened to see that Guoguang boss mentioned the use of GPU A tool for cracking passwords Hashcat, In the future, I will learn again when I meet the goal I want to do !
References
版权声明
本文为[The goose is like a small drop of stone ~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231020529039.html
边栏推荐
- LeetCode-608. Tree node
- Zhengda international explains what the Dow Jones industrial index is?
- Realize data value through streaming data integration (3) - real-time continuous data collection
- Construction and traversal of binary tree
- 《Redis设计与实现》
- 通过流式数据集成实现数据价值(1)
- DBA常用SQL语句(6)- 日常管理
- 域名和IP地址的联系
- 142、环形链表||
- Arm debugging (1): two methods to redirect printf to serial port in keil
猜你喜欢
随机推荐
Yarn core parameter configuration
Art template template engine
Net start MySQL MySQL service is starting MySQL service failed to start. The service did not report any errors.
Realizing data value through streaming data integration (5) - stream processing
MapReduce core and foundation demo
2022 mobile crane driver test question bank simulation test platform operation
Common DBA SQL statements (4) - Top SQL
第二章 Oracle Database In-Memory 体系结构(上) (IM-2.1)
What are the system events of Jerry's [chapter]
Sim Api User Guide(5)
Chapter I Oracle database in memory related concepts (Continued) (im-1.2)
DBA常用SQL语句(6)- 日常管理
DBA common SQL statements (1) - overview information
19. Delete the penultimate node of the linked list (linked list)
Chapter II in memory architecture (im-2.2)
Turn: Maugham: reading is a portable refuge
Sim Api User Guide(8)
SQL调优系列文章之—SQL性能方法论
209. Subarray with the smallest length (array)
203、移出链表元素(链表)