-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2498d1d
commit b7402cf
Showing
4 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/mman.h> | ||
#include <sys/wait.h> | ||
#include <unistd.h> | ||
|
||
#define EXECVE_VAR 0 | ||
#define EXECV_VAR 1 | ||
#define ATTACH_TIME 10 | ||
|
||
extern char **environ; | ||
|
||
int main(int argc, char *argv[]) { | ||
int res; | ||
if (argc != 2) { | ||
return EXIT_FAILURE; | ||
} | ||
int sleep_time = 0; | ||
// provide a time to attach | ||
while(sleep_time < ATTACH_TIME) { | ||
sleep(1); | ||
sleep_time++; | ||
fprintf(stderr, "Waiting to attach %d sec.\n", sleep_time); | ||
} | ||
int variant = atoi(argv[1]); | ||
|
||
res = fork(); | ||
if (res < 0) { | ||
return EXIT_FAILURE; | ||
} else if (res == 0) { | ||
switch (variant) { | ||
case EXECVE_VAR: { | ||
char* args[] = {"/usr/bin/curl", "-I", "https://cribl.io", NULL}; | ||
return execve("/usr/bin/curl", args, environ); | ||
} | ||
case EXECV_VAR: { | ||
char* args[] = {"/usr/bin/wget", "-S", "--spider", "--no-check-certificate", "https://cribl.io", NULL}; | ||
return execv("/usr/bin/wget", args); | ||
} | ||
} | ||
} else { | ||
wait(&res); | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
return EXIT_FAILURE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters