Found examples for howto use exec()
, but failed on https://play.google.com/store/apps/details?id=com.termux
~/ $ cat << EOF > test.cxx
#include <unistd.h>
#include <stdio.h>
int main(int argc, char *const* _args) {
char *args[2];
printf("1");
args[0] = "/bin/ls";
args[1] = "-lh";
execve(args[0], args, NULL);
args[1] = "";
execve(args[0], args, NULL);
execve(args[0], NULL, NULL);
args[0] = "/bin/echo";
args[1] = "u";
execve(args[0], args, NULL);
printf("2");
return 0;
}
EOF
~/ $ g++ test.cxx && ./a.out
: unknown program '''
Try ' --help' for more information
~/ $ cat << EOF > test.cxx
#include <unistd.h>
#include <stdio.h>
int main(int argc, char *const* _args) {
char *args[2];
printf("1");
args[0] = "/bin/ls";
args[1] = "-lh";
execve(args[0], args, NULL);
args[1] = "";
execve(args[0], args, NULL);
args[0] = "/bin/echo";
args[1] = "u";
execve(args[0], args, NULL);
printf("2");
return 0;
}
EOF
~/ $ g++ test.cxx && ./a.out
12
~/ $
Want to use this for autonomous virus analysis:
https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/VirusAnalysis.cxx#L162
Thought would execute commands or give errors with enough information to fix this.
1