Skip to content

Instantly share code, notes, and snippets.

@rubenhortas
Last active May 10, 2025 18:19
Show Gist options
  • Select an option

  • Save rubenhortas/1bfe50673297c975d979060e0af97d49 to your computer and use it in GitHub Desktop.

Select an option

Save rubenhortas/1bfe50673297c975d979060e0af97d49 to your computer and use it in GitHub Desktop.
Process arguments spoofing in GNU/Linux
/*
* Process arguments spoofing in GNU/Linux.
*
* Hide program arguments by overwriting them with null.
*
* You can read my full post here: https://rubenhortas.github.io/posts/process-argument-spoofing-gnu-linux/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
char *argv0 = argv[0];
char *argvi;
int i;
printf("PID: %d\n", getpid());
printf("argv[0] '%s', address '%p'\n", argv[0], argv);
for (i = 1; i < argc; i++) {
printf("argv[%d] '%s', address '%p'\n", i, argv[i], argv[i]);
memset(argv[i], 0, strlen(argv[i])); // Overwrite everything with null
}
strcpy(argv0, "[kworker fake/1:1-events]"); // Overwrite the program name
while(1) { // Do some stuff
}
free(argv0);
free(argvi);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment