证人:
$ ps f
PID TTY STAT TIME COMMAND
31509 pts/3 Ss 0:01 -bash
27266 pts/3 S+ 0:00 \_ mysql -uroot -p
25210 pts/10 Ss+ 0:00 /bin/bash
24444 pts/4 Ss 0:00 -bash
29111 pts/4 S+ 0:00 \_ tmux attach
4833 pts/5 Ss+ 0:00 -bash
9046 pts/6 Ss 0:00 -bash
17749 pts/6 R+ 0:00 \_ ps f
4748 pts/0 Ss 0:00 -bash
14635 pts/0 T 0:02 \_ mysql -uroot -px xxxxxxxxxxxxxxxx
16210 pts/0 S+ 0:01 \_ mysql -uroot -px xxxxxxxxxxxxxxxx
ps如何知道隐藏mysql
密码?我可以将其合并到自己的脚本中以隐藏特定的CLI属性吗?
ps
不隐藏密码。像mysql这样的应用程序会覆盖它们获得的参数列表。请注意,这是一个很小的时间范围(可能会因系统负载高而扩展),在此之前,其他应用程序可以看到这些参数,直到它们被覆盖为止。将流程隐藏到其他用户可能会有所帮助。通常,通过文件传递密码比通过命令行传递密码要好得多。
在本文中,将针对C进行说明。下面的示例隐藏/删除所有命令行参数:
#include <string.h>
int main(int argc, char **argv)
{
// process command line arguments....
// hide command line arguments
if (argc > 1) {
char *arg_end;
arg_end = argv[argc-1] + strlen (argv[argc-1]);
*arg_end = ' ';
}
// ...
}
另请参阅https://stackoverflow.com/questions/724582/hide-arguments-from-ps和https://stackoverflow.com/questions/3830823/hiding-secret-from-command-line-parameter-on-unix。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句