需要自备弱密码明文字典

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系统弱密码检测的更多相关文章

  1. [分享]运维分享一一阿里云linux系统mysql密码修改脚本

    [分享]运维分享一一阿里云linux系统mysql密码修改脚本       大象吃豆子 级别: 小白 发帖 12 云币 27 加关注 写私信   只看楼主 更多操作楼主  发表于: 2014-09-3 ...

  2. linux系统mysql密码修改脚本

    编写了一个适用于阿里云linux系统 mysql密码修改脚本,使用阿里云提供的一键安装包配置后,如果account.log文件删除,并且忘记mysql密码时,可以通过脚本来重置mysql密码. 附:一 ...

  3. 重设windows10中的sub linux系统用户密码

    原文:重设windows10中的sub linux系统用户密码 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/haiyoung/article/detai ...

  4. 破解Linux系统开机密码

    在我们使用Linux虚拟机的时候,经常会忘记自己设置的开机密码,无奈之下只有重新建一个虚拟机,然而新建往往会浪费掉我们很多时间,这时候,知道如何破解Linux系统密码就显得很重要了. 下面我们使用bo ...

  5. linux系统root密码忘了怎么办 三种方法快速找回root密码

    linux root密码找回方法一 第1步:在系统进入单用户状态,直接用passwd root去更改. 第2步:用安装光盘引导系统,进行linux rescue状态,将原来/分区挂接上来,作法如下: ...

  6. linux系统破解密码。

    Linux系统Centos7及RedHat7破解密码 步骤如下: 1.开机之后按"e"键 2.找到以linux16的开头的行在行尾添加 rd.break console=tty0 ...

  7. 弱密码检测JR!

    1.JR(Joth the Ripper)简介·一款密码分析工具,支持字典式的暴力破解·通过对 shadow 文件的口令分析,可以检测密码·官方网站:http://www.openwall.com/j ...

  8. VMware安装的Linux系统忘记密码 怎么修改root密码

    因为昨天新安装过虚拟机设置了新的密码,再加上我好长时间没有用自己旧的虚拟机,导致忘记了密码,原来虽然知道在单用模式下,找回密码,但是确实是自己从来都没有做过,还好我们组大手飞翔哥告诉了我,怎么找回ro ...

  9. 虚拟机Linux系统忘记密码的情况下,修改root或其他用户密码

    使用场景 linux管理员忘记root密码,需要进行找回操作. 注意事项:本文基于centos7环境进行操作,由于centos的版本是有差异的,继续之前请确定好版本. 步骤 一.重启系统,在开机过程中 ...

随机推荐

  1. Tomcat记录-tomcat常用配置详解和优化方法(转载)

    常用配置详解 1 目录结构 /bin:脚本文件目录. /common/lib:存放所有web项目都可以访问的公共jar包(使用Common类加载器加载). /conf:存放配置文件,最重要的是serv ...

  2. angular,vue,react的父子通信

    父子通信 父传子 vue: 父组件:<child :msg="datamsg" ></child> //子组件的msg属性上加数据,datamsg是数据 子 ...

  3. eDEX-UI

    eDEX-UI A science fiction terminal emulator disigned for large touchscreen that runs on all major OS ...

  4. Java笔记——泛型擦除

    1. 泛型擦除 package cn.Douzi.T_Demo; import java.util.ArrayList; /** * @Auther: Douzi * @Date: 2019/3/8 ...

  5. PC机Win10声音问题两例处理办法

    1.PC电脑接HDMI显示器后无声的解决方案点击声音->播放,下面有一个是显示器,一个扬声器,选择扬声器即可.2.低音太重解决办法扬声器属性,增强,禁用所有声音效果.

  6. Slash and BackSlash 记忆法

    容易混淆的两兄弟 Slash https://en.wikipedia.org/wiki/Slash Slash (punctuation), the "/" punctuatio ...

  7. HACK入别人的游戏制作做MOD的几种技巧

    要让某个游戏(程序)加载我们的MOD,目前有想到的有三种方式: 静态注入:静态注入,即我们HACK入游戏的某个dll,然后修改里面的代码,让程序在运行后加载我们的ModDll,比如U3D的游戏可以直接 ...

  8. luogu 4180 严格次小生成树

    次小生成树,顾名思义和次短路的思路似乎很类似呀, 于是就先写了个kruskal(prim不会)跑出最小生成树,给所有路径打标记,再逐个跑最小生成树取大于最小生成树的最小值 50分 #include&l ...

  9. super 的用法

    通过用static来定义方法或成员,为我们编程提供了某种便利,从某种程度上可以说它类似于C语言中的全局函数和全局变量.但是,并不是说有了这种便利,你便可以随处使用,如果那样的话,你便需要认真考虑一下自 ...

  10. 利用PHP连接数据库——实现用户数据的增删改查的整体操作实例

    main页面(主页面) <table width="100%" border="1" cellpadding="0" cellspac ...