I have to write the c program that executes terminal commands which are in this order :
cd ../../etc
chmod a+x file
cd alice/password
more password
so if I have attack.c then by ./attack, all these should be implemented on the terminal. I tried using execvp()
but its just not happening.
You can run shell commands in C using the system() command (works in linux)
#include <stdio.h>
#include <stdlib.h>
int main() {
system("cd ../../etc; chmod a + x file; cd alice/password; cat password");
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.