linux - 在其他交互式程序中禁用 Bash 命令
问题描述
我使用的是 Kali Linux,我不希望 bash 命令在其他交互式程序中运行,就像msfconsole
在 Meterpreter 中运行一样,你仍然可以这样做ls
,在 Metasploit 中这不是问题,但我正在尝试学习 PowerShell。当我这样做时,pwsh
我仍然可以使用 bash 命令——这有点奇怪。帮助我禁用 PowerShell 中的 bash 命令。
复制并粘贴我所做的:
root@kali:~# pwsh
PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /root/Documents/tmp> ls
chall john peda-session-chall.txt
在 Powershell 中,它不应该运行ls
命令。但是当我在 bash 中使用它时,我能够运行该命令,并且我想停止它
的内容$PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
我曾尝试寻找一些标志,--no-bash
但找不到任何东西。
解决方案
我认为您不能在 PowerShell 中禁用操作系统命令。
根据定义,PowerShell 首先尝试自己的命令或别名,如果找不到,它会在底层操作系统中搜索可执行文件。但是,我会说其他贝壳也是如此。甚至猛击。在您的示例中,命令ls
不是 bash 中的内置命令,而是位于您的$PATH
. 另一方面,times
是内置命令。
igor@pc:~$ which times
igor@pc:~$ which ls
/bin/ls
请注意,上面我指的是底层操作系统,而不是之前的 shell。PowerShell不会执行来自 bash 的内置命令。如果你尝试eval
, unset
,times
或其他, 你会得到错误CommandNotFoundException
PS /home/igor> times
times : The term 'times' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ times
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (times:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS /home/igor> exit
igor@pc:~$ times
0m0.078s 0m0.141s
0m36.063s 0m29.406s
推荐阅读
- java - JAX-WS 编组错误。SomeClassV1R5 无法转换为 SomeClass 的目标类型
- amazon-web-services - 需要从 API 公开 Amazon S3 存储桶
- jquery - Hide or show on window resize vuejs
- google-sheets - 实时按类别获取最新日期的计数和总和
- sql - 我在 sqlite 中收到双引号错误
- javascript - 如何使用 Expo 在 React-Native 应用程序上按顺序运行异步函数
- azure - SignalR 与 Azure 的连接不起作用(.net core 3.1)
- coq - coq 程序模块抛出了我的假设
- clojure - 在这个简单的 Clojure Ring 应用程序中获取默认 index.html 文件以获得正确的 Content-Type 的正确方法是什么?
- javascript - 上传一个大文件还是多个小文件更快?