搜索引擎中 哪些网站可以获得更好的排名,廊坊优化网站排名,个人网站 备案 备注,html网页制作如何加入图片一、引用的python模块
Crypto#xff1a;
Python中一个强大的加密模块#xff0c;提供了许多常见的加密算法和工具。它建立在pyc.ypodome或pyc.ypto等底层加密库之上#xff0c;为Python程序员提供了简单易用的API#xff0c;使其可以轻松地实现各种加密功能。
commands…一、引用的python模块
Crypto
Python中一个强大的加密模块提供了许多常见的加密算法和工具。它建立在pyc.ypodome或pyc.ypto等底层加密库之上为Python程序员提供了简单易用的API使其可以轻松地实现各种加密功能。
commands
commands 模块是 Python 的内置模块它主要有三个函数 FUNCTIONS getoutput(cmd) Return output (stdout or stderr) of executing cmd in a shell.getstatus(file) Return output of ls -ld file in a string.getstatusoutput(cmd) Return (status, output) of executing cmd in a shell. SYS 基础系统模块
sys模块是与python解释器交互的一个接口。sys 模块提供了许多函数和变量来处理 Python 运行时环境的不同部分。
二、实现过程
python脚本如下 import crypt import commands import sys def testPass(user,cryptPass,ipaddr): #dictfileopen(dictionary.txt,r) start_indexcryptPass.find($) finish_indexcryptPass.rfind($) saltcryptPass[start_index:finish_index1] dictfileopen(/root/dict.txt,r) pwd_suffix [,.,..,!,!#,1,123,1234,12345,123456,888,666,999,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019] for sfx in pwd_suffix: #print usersfx for separator in [,,#,]: cryptWordcrypt.crypt(%s%s%s%(user,separator,sfx),salt) if cryptWordcryptPass: #print ipaddr [] Found Password: user/usersfx \n print %s [] Found Passwd: %s/%s%s%s \n%(ipaddr,user,user,separator,sfx) break cryptWordcrypt.crypt(%s%s%s%(user,sfx,separator),salt) if cryptWordcryptPass: #print ipaddr [] Found Password: user/usersfx \n print %s [] Found Passwd: %s/%s%s%s \n%(ipaddr,user,user,sfx,separator) break for word in dictfile.readlines(): #print word wordword.strip() cryptWordcrypt.crypt(word,salt) if cryptWordcryptPass: print ipaddr [] Found Password: user/word \n break print([-] Password not found!) def main(): cmd ifconfig|grep \inet addr\|grep -v 127.0.0.1|awk {print $2} ipaddr commands.getoutput(cmd).replace(addr:,).replace(\n,|) shadowfileopen(/etc/shadow) for line in shadowfile.readlines(): userline.split(:)[0] cryptPassline.split(:)[1].strip(\n) if not (cryptPass.startswith(*) or cryptPass.startswith(!)): print [*] Cracking Password For: user testPass(user,cryptPass,ipaddr) if __name____main__: main() 注破解密码有两种方式一种是通过脚本pwd_suffix定义的后缀另一种是调用密码字典库/root/dict.txt来破解。
三、演示效果
创建一个测试用户testuser密码设置成123456然后执行检测脚本。滴弱密码已被发现