在Linux中隐藏C程序的命令行参数
发布时间:2020-12-13 18:50:42 所属栏目:Linux 来源:网络整理
导读:如何隐藏在 Linux中运行的C程序的命令行参数,以便其他用户通过“w”,“ps auxwww”或类似命令看不到它们? 解决方法 修改程序中argv的内容: #include stdio.h#include time.hvoid delay (long int msecs){ clock_t delay = msecs * CLOCKS_PER_SEC / 1000;
如何隐藏在
Linux中运行的C程序的命令行参数,以便其他用户通过“w”,“ps auxwww”或类似命令看不到它们?
解决方法
修改程序中argv的内容:
#include <stdio.h> #include <time.h> void delay (long int msecs) { clock_t delay = msecs * CLOCKS_PER_SEC / 1000; clock_t start = clock(); while (clock() - start < delay); } void main (int argc,char **argv) { if (argc == 2) { printf ("%sn",argv[1]); delay (6000); argv[1][0] = 'x'; argv[1][1] = '.'; argv[1][2] = 'x'; printf ("%sn",argv[1]); delay (5000); printf ("donen"); } else printf ("argc != 1: %dn",argc); } 调用: ./argumentClear foo foo x.x done 结果,按ps查看: asux:~ > ps auxwww | grep argu stefan 13439 75.5 0.0 1620 352 pts/5 R+ 17:15 0:01 ./argumentClear foo stefan 13443 0.0 0.0 3332 796 pts/3 S+ 17:15 0:00 grep argu asux:~ > ps auxwww | grep argu stefan 13439 69.6 0.0 1620 352 pts/5 R+ 17:15 0:02 ./argumentClear x.x stefan 13446 0.0 0.0 3332 796 pts/3 S+ 17:15 0:00 grep argu 备注:我的延迟功能无法正常工作.该程序运行时间约为2-3秒而不是11秒.我不是那个大C程序员. :)延迟功能需要改进. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |