在Linux中隐藏C程序的命令行参数
发布时间:2020-05-23 15:31:17 所属栏目: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程序员. :)延迟功能需要改进. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 用于电视(TV)视频的实时像素级分析的建议
- Linux的Ctrl-C(KeyboardInterrupt)为Windows cmd行?
- linux – mdadm raid5恢复双磁盘故障 – 扭曲(驱动顺序)
- 如何防止rsync用目标目录层次结构中的新目录替换符号链接?
- linux – Shell函数为特定时间的特定字符串拖尾一个日志文件
- Linux:放置交换文件的位置
- linux – 如何确定哪个文件/ inode占用给定扇区
- linux – gcc,icc或Microsoft的C/C++编译器是否支持或了解有
- 在C中的多个程序之间本地共享数据(如使用套接字)
- Linux Split Command Examples
