Linux之用户密码管理

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/m0_37814112/article/details/102671385

Linux之用户密码管理

1.弱密码检查方法

1.1 使用john the ripper检查弱密码

1.下载安装
yum install gcc* -y
wget -c http://www.openwall.com/john/j/john-1.8.0.tar.gz && tar axf john-1.8.0.tar.gz
cd john-1.8.0/src/ && make clean linux-x86-64

2.进入安装后的目录
[root@docker src]# cd /root/john-1.8.0/run/

3.将系统中passw和shadow文件整合到mypassword.txt文件中
[root@docker run]# ./unshadow /etc/passwd /etc/shadow > mypassword.txt

4.使用密码字典password.lst尝试破解
[root@docker run]# ./john  --wordlist=password.lst mypassword.txt
Loaded 2 password hashes with 2 different salts (crypt, generic crypt(3) [?/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:30 100% 0g/s 115.4p/s 230.9c/s 230.9C/s !@#$%..sss
Session completed

5. 显示破解出的密码
[root@docker run]# ./john --show mypassword.txt 
[root@docker1 run]# ./john --show mypassword.txt 
root:111111:0:0:root:/root:/bin/bash
1 password hash cracked, 0 left

1.2 使用Hydra检查弱密码

yum install git -y
git clone https://github.com/vanhauser-thc/thc-hydra.git
cd /root/thc-hydra
./configure && make && make install
执行报错
bfg.c: 在函数‘accu’中:
bfg.c:196:3: 错误:只允许在 C99 模式下使用‘for’循环初始化声明
   for(int a=1; a<=value; ++a)
   ^
bfg.c:196:3: 附注:使用 -std=c99 或 -std=gnu99 来编译您的代码
make: *** [bfg.o] 错误 1

不是很懂,果断放弃!!!

1.3 使用腾讯云弱密码检测工具

https://cloud.tencent.com/document/product/296/2226

注意:只能从腾讯云的主机下载。在这里我找了一台腾讯云主机下载,然后拷贝到非腾讯云主机上。

wget -c mirrors.tencentyun.com/install/sec/qcloud-checkpassword.zip
unzip qcloud-checkpassword.zip
cd qcloud-checkpassword

[root@docker1 qcloud-checkpassword]# ./check.sh 
	There is 23 users and 1 users can logon the system.
	Now compute the time,wait for seconds.
	Process need 30s.
	[PID=6689] : Now start to process.
	[PID=6690] : Now start to process.
	[PID=6691] : Now start to process.
	[PID=6687] : Now start to process.
	[PID=6688] : Now start to process.
	Cost time is 0s.
	You can get detail info from report.txt.

[root@docker1 qcloud-checkpassword]# cat report.txt 
[root have simple passwd(111111)]

2.复杂密码生成方法

2.1 keepasss手动生成复杂密码

在不需要批量生成复杂密码的时候,我们可以使用keepass手动生成几个复杂密码。

2.2 使用openssl生成复杂密码

openssl rand -base64 20

2.3 使用pwgen生成复杂密码

yum install pwgen -y
pwgen -c -n -y 12 1

参数

pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]

-c or –capitalize //密码中至少包含一个大写字母
-A or –no-capitalize //密码中不包含大写字母
-n or –numerals //密码中至少包含一个数字
-0 or –no-numerals //密码中不包含数字
-y or –symbols //密码中至少包含一个特殊符号
-s or –secure  //生成完全随机密码
-B or –ambiguous //密码中不包含歧义字符(例如1,l,O,0)

2.4 通过系统环境变量($RANDOM)实现

[root@i-1pbhgm8j ~]# echo $RANDOM | md5sum | cut -c 5-11
3edb8e2

2.5 通过时间data产生随机数

[root@i-1pbhgm8j ~]# date +%s%N
1507534201869428907

2.6 通过/dev/urandom配合chksum生成随机数

[root@i-1pbhgm8j ~]# head /dev/urandom | cksum
3529852297 1731

2.7 通过UUID生成产生随机数

[root@i-1pbhgm8j ~]# cat /proc/sys/kernel/random/uuid
1a2f4db2-5ec6-46b1-8c08-f0fdf17e76eb
[root@i-1pbhgm8j ~]# cat /proc/sys/kernel/random/uuid
6c2be32b-6f8c-4cdc-9f6f-224a3d966f7a
[root@i-1pbhgm8j ~]# cat /proc/sys/kernel/random/uuid
4a11c9e6-0b42-4401-bad3-f492dcb28baa

2.8 使用expect附带的mkpasswd生成随机数

[root@i-1pbhgm8j ~]# yum install expect -y
[root@i-1pbhgm8j ~]# mkpasswd -l 10 -d 4 -c 2 -C 2 -s 1
y78UF/o93b
[root@i-1pbhgm8j ~]# mkpasswd -l 10 -d 4 -c 2 -C 2 -s 1
hELs1(n297
[root@i-1pbhgm8j ~]# mkpasswd -l 10 -d 4 -c 2 -C 2 -s 1
gWC$s1239z

-l 指定密码长度
-d 指定密码中数字的数量
-c 指定密码中小写字母的数量

猜你喜欢

转载自blog.csdn.net/m0_37814112/article/details/102671385