需要自备弱密码明文字典

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系统弱密码检测相关推荐

  1. linux服务器用centos还是ubuntu系统_Linux

    摘要: 本文讲的是linux服务器用centos还是ubuntu系统_Linux, linux服务器系统多使用CentOS.uBuntu.Gentoo.FreeBSD.Debian.服务器操作系统应该 ...

  2. linux服务器立即关机命令,Linux服务器重启/关机命令(shutdown/halt/reboot/init/poweroff)...

    Linux服务器重启命令有shutdown.halt.reboot.init和poweroff,Linux百科网分享各个重启命令参数及使用方法: 以下关于Linux服务器重启命令写的比较详细,如果你着 ...

  3. Linux 服务器(二)-linux安装方法之Centos安装介绍——Windows中制作USB启动盘 MacOS中制作USB启动盘

    Linux 服务器(二)-linux安装方法之Centos安装介绍--Windows中制作USB启动盘 & MacOS中制作USB启动盘 安装方法 Centos安装方法: 下载镜像 按需选择下 ...

  4. linux服务器备份软件下载,Linux服务器的常用备份方法 服务器系统备份方法

    文件备份无疑是企业重要的网络管理工作之一,尤其是很多单位的文件服务器上常常存储单位的无形资产和商业机密,如何保护这些文件的安全至关重要.数据备份是一项必不可少的管理工作. 系统备份是系统管理工作中十分 ...

  5. 【Linux服务器初上手】MobaXterm/系统版本/hostname/hosts/yum源配置/jdk/docker(不断完善)

    1.简单说明 这里对云服务器的购买.安全组设置等不做详细的说明,主要是描述连接上云服务器后要做的配置.开发环境搭建等操作,内容会不断进行完善. 服务器终端工具推荐使用MobaXterm优点是免费开源, ...

  6. linux服务器安全与配置,Linux系统服务器安装后的安全配置

    安装完成以后,应该马上采取哪些措施来增强服务器的安全性.对于其他的Linux发布或者版本,这些方法也是适用的. 一.关闭不必要的服务 Linux的服务分为两种,一种是由inetd超级服务器来启动的,如 ...

  7. linux服务器知识学习:linux系统的目录结构

    输入 ls / /bin:bin是Binary的缩写, 这个目录存放着最经常使用的命令. /boot:这里存放的是启动Linux时使用的一些核心文件,包括一些连接文件以及镜像文件. /dev :dev ...

  8. linux服务器怎么添加路由,linux系统中添加路由的方法

    linux系统中添加路由的方法 发布时间:2020-06-17 11:38:59 来源:亿速云 阅读:95 作者:Leah 这篇文章将为大家详细讲解有关linux系统中添加路由的方法,小编觉得挺实用的 ...

  9. 架设linux服务器下的samba,Linux 服务器搭建之Samba服务

    Linux服务器搭建之Samba服务 一.Samba服务基础 Samba是著名的开源软件项目之一,它在Linux/UNIX系统中实现了微软的SMB/CIFS网络协议,从而使得跨平台的文件共享变得更加容 ...

  10. linux服务器重启的步骤,linux服务器重启步骤_保护Linux服务器的7个步骤

    linux服务器重启步骤 本入门将向您介绍基本的Linux服务器安全性. 虽然它专注于Debian / Ubuntu,但是您可以将此处介绍的所有内容应用于其他Linux发行版. 我也鼓励您研究此材料并 ...

最新文章

  1. android studio 插件版本号和gradle版本号对应关系
  2. Openstack虚机实例状态错误手工恢复vm_state:error
  3. 如何实现在网页复制后加上网站的来源href
  4. GitHub之深入解析脚本·自定义与修改GitHub来更好地为特定的工作流程工作
  5. mysql不用left join_MySQL在右表数据不唯一的情况下使用left join的方法_MySQL - join
  6. C++中set和map的erase用法
  7. 【性能测试】Linux系统监控-CPU信息
  8. WordPress独立资源下载页面插件 基于美化Xydown插件
  9. iQOO 8系列即将登场:首发三星E5 AMOLED全面屏
  10. Log4j CVE-2021-44228 漏洞及Spring Boot解决方案
  11. 解三对角线性方程组的追赶法
  12. Hadoop入门到精通(不断更新中。。。。)
  13. 2019年linux云计算就业前景,云计算前景与网络前景
  14. java在上海就业_叩丁狼教育上海Java一期就业报道
  15. script脚本阻塞的探究、异步属性async和defer的区别
  16. Python Web开发技巧III
  17. 电脑上下载哔哩哔哩的视频?
  18. Windows操作系统各版本的历史
  19. 外汇期货股票 投资书籍下载
  20. 内部环境--SWOT分析法

热门文章

  1. 没了Ghost,系统也能“雨过天晴”了
  2. word使用 通配符替换中文汉字
  3. CPU基础---设计一个8位的并行加法器
  4. 百度网站打不开了,只有百度首页跟搜索页打不开其它能正常打开怎么解决?
  5. elk logstach收集交换机日志
  6. mw150um 驱动程序win10_水星MW150UM 1.0无线网卡驱动
  7. 如何解决数据流转「不可能三角」难题?
  8. c语言 error c2227,error C2227: left of '-first' must point to class/struct/union
  9. 7-Zip下载|7-Zip下载
  10. 理解“正反馈”和“负反馈”,学会系统性思考