执行 argc=0 的进程
是否可以执行 argc = 0 的进程?我需要执行一个程序,但它的 argc 等于 0 非常重要。有没有办法做到这一点? 我尝试在命令行中放入 2^32 个参数,这样看起来就好像 argc = 0 但参数数量有最大限制。
Is it possible to execute a process whose argc = 0? I need to execute a program but it is extremely important for its argc to be equal to 0. Is there a way to do that?
I tried to put 2^32 arguments in the command line so that it appears as if argc = 0 but there is a maximum limit to the number of arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以编写一个直接调用 exec 的程序;它允许您指定命令行参数(包括程序名称)和缺少命令行参数。
You can write a program that calls exec directly; that allows you to specify the command-line arguments (including the program name) and lack thereof.
您可以使用 Linux 系统调用execve()。
您可以传递可执行文件的文件名和一个空指针作为argv[]来执行二进制文件,并且argc将为零。
这是我的测试代码:
strace 结果是:
您可以使用 envp[] 来传递您定义的参数。
此外,您可以使用汇编语言来达到您的目标(argc == 0 但您仍然需要传递参数)。我假设您使用的是 32 位 x86 环境。
其概念是:
内存结构如下图所示
:我想知道你是否在做该课程的实验作业由 Taesoo Kim 教授(GATech)提供。
课程链接:https://tc.gtisc.gatech.edu/cs6265
或者是黑客CTF(接旗竞赛)问题?
You may use linux system call execve().
You may pass the filename of executable and a null pointer as the argv[] to execute the binary and the argc will be zero.
It is my test code:
And the strace result is:
You could use envp[] to pass the arguments you defined anyways.
Furthermore, you could use assembly language to reach your goal (argc == 0 but you still need to pass arguments). I assume that you are using a 32-bits x86 environment.
The concept is that:
The memory structure is shown below:
I am wondering that if you were doing the lab assignment of the course provided by Prof. Taesoo Kim (GATech).
Course Link: https://tc.gtisc.gatech.edu/cs6265
Or is it a hacker CTF (catch-the-flag contest) problem?
您可以编写一个 C 程序,在没有 argv 的情况下生成/执行另一个程序,例如:
You could write a C program that spawns/execs the other program with no argv, like: