linux系统弱密码检测
需要自备弱密码明文字典
from _utils.patrol2 import data_format,report_format,run_cmd
import platform
import crypt with open(passwd[0],'r') as f:
content=f.readlines() def use_md5(password,salt):
global content
for i in content:
cmd="openssl passwd -1 -salt '{}' '{}'".format(salt,i)
code,res=run_cmd(cmd)
if res.split('$')[-1].strip()==password:
return True
return False def use_SHA512(id,password,salt):
global content
for i in content:
cry_password=crypt.crypt(i,'${}${}'.format(id,salt))
if cry_password==password:
return True
return False content=[i.strip('\r\n').strip('\n') for i in content] weak_passwd=[]
remove_users =remove_users.split(',') low_length_users=[]
cmd="awk -F: 'length($2)<={} {{print $1}}' /etc/shadow".format(passwd_length)
code,res=run_cmd(cmd)
for i in res.split('\n'):
if i.strip() not in remove_users:
low_length_users.append(i.strip())
blowfish=[]
nocrypt=[]
cmd="awk -F: '{print $1,$2}' /etc/shadow"
code,res=run_cmd(cmd) for i in res.split('\n'):
user_name=i.split()[0].strip()
if user_name in remove_users:
continue
passwd=i.split()[1].strip()
if passwd in ('!!','') and user_name not in low_length_users:
low_length_users.append(user_name)
elif passwd.startswith('$'):
_,id,salt,hashed=passwd.split('$')
if id=='1' and use_md5(hashed,salt):
weak_passwd.append(user_name)
elif id in ('6','5') and use_SHA512(id,hashed,salt):
weak_passwd.append(user_name)
elif id in ('2a','2y'):
blowfish.append(user_name)
elif id not in ('6','5','2a','2y','1'):
nocrypt.append(user_name) result=[]
if low_length_users:
result.append('密码长度不足或空密码:{}'.format(','.join(low_length_users)))
if weak_passwd:
result.append('密码强度不足:{}'.format(','.join(weak_passwd)))
if blowfish:
result.append('使用了blowfish加密方式,建议使用sha512方式:{}'.format(','.join(blowfish)))
if nocrypt:
result.append('无法识别加密类型:{}'.format(','.join(nocrypt)))
if not result:
report=data_format('检查结果','正常',0)
else:
report = data_format('检查结果', '\n'.join(result), 1)
reports=report_format(platform.node(),[report],is_json=True)
linux系统弱密码检测的更多相关文章
- [分享]运维分享一一阿里云linux系统mysql密码修改脚本
[分享]运维分享一一阿里云linux系统mysql密码修改脚本 大象吃豆子 级别: 小白 发帖 12 云币 27 加关注 写私信 只看楼主 更多操作楼主 发表于: 2014-09-3 ...
- linux系统mysql密码修改脚本
编写了一个适用于阿里云linux系统 mysql密码修改脚本,使用阿里云提供的一键安装包配置后,如果account.log文件删除,并且忘记mysql密码时,可以通过脚本来重置mysql密码. 附:一 ...
- 重设windows10中的sub linux系统用户密码
原文:重设windows10中的sub linux系统用户密码 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/haiyoung/article/detai ...
- 破解Linux系统开机密码
在我们使用Linux虚拟机的时候,经常会忘记自己设置的开机密码,无奈之下只有重新建一个虚拟机,然而新建往往会浪费掉我们很多时间,这时候,知道如何破解Linux系统密码就显得很重要了. 下面我们使用bo ...
- linux系统root密码忘了怎么办 三种方法快速找回root密码
linux root密码找回方法一 第1步:在系统进入单用户状态,直接用passwd root去更改. 第2步:用安装光盘引导系统,进行linux rescue状态,将原来/分区挂接上来,作法如下: ...
- linux系统破解密码。
Linux系统Centos7及RedHat7破解密码 步骤如下: 1.开机之后按"e"键 2.找到以linux16的开头的行在行尾添加 rd.break console=tty0 ...
- 弱密码检测JR!
1.JR(Joth the Ripper)简介·一款密码分析工具,支持字典式的暴力破解·通过对 shadow 文件的口令分析,可以检测密码·官方网站:http://www.openwall.com/j ...
- VMware安装的Linux系统忘记密码 怎么修改root密码
因为昨天新安装过虚拟机设置了新的密码,再加上我好长时间没有用自己旧的虚拟机,导致忘记了密码,原来虽然知道在单用模式下,找回密码,但是确实是自己从来都没有做过,还好我们组大手飞翔哥告诉了我,怎么找回ro ...
- 虚拟机Linux系统忘记密码的情况下,修改root或其他用户密码
使用场景 linux管理员忘记root密码,需要进行找回操作. 注意事项:本文基于centos7环境进行操作,由于centos的版本是有差异的,继续之前请确定好版本. 步骤 一.重启系统,在开机过程中 ...
随机推荐
- request模块的使用
安装方式 $ pip install requests 基本GET请求(headers参数 和 parmas参数) 1. 最基本的GET请求可以直接用get方法 response = requests ...
- vue表单校验提交报错TypeError: Cannot read property 'validate' of undefined
TypeError: Cannot read property 'validate' of undefined at VueComponent.submitForm (plat_users.html: ...
- Eclipse xml中自动提示,添加 dtd或xsd依赖
下载DTD或XSD文件 添加到Eclipse
- 【leetcode-125】 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 示例 1: 输入: "A man, a plan, a c ...
- 固定footer在底部
作者:李宇链接:https://www.zhihu.com/question/23220983/answer/25880123来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...
- Spring Boot - Error creating bean with name 'dataSource' defined in class path resource
看起来像最初的问题是与自动配置. 如果你不需要数据源,只需从自动配置过程中删除它: @EnableAutoConfiguration(exclude={DataSourceAutoConfigurat ...
- POI导出Excel 错误THE MAXIMUM COLUMN WIDTH FOR AN INDIVIDUAL CELL IS 255 CHARACTERS
int orgColWidth = (arrColWidth[column.Ordinal] + 1); if (liekuan > 255) liekuan = 255; //设置列宽 she ...
- 解决XP系统任务管理器显示不全
我们在使用电脑的时候有的时候打开任务管理器会发现任务管理器显示不全. 当碰到这种情况怎么解决呢?任务管理器显示不全的原因又是那些呢? 这里就来为大家分享下为什么任务管理器会显示不全以及如何解决这个问题 ...
- 破解修改 Electron 软件 | 游戏
Electron 是 Github 发布跨平台桌面应用开发工具,支持 Web 技术开发桌面应用开发,其本身是基于 C++ 开发的,GUI 核心来自于 Chrome,而 JavaScript 引擎使用 ...
- Linux C 编程
主题链接地址:https://www.cnblogs.com/kele-dad/category/1194627.html