Skip to content

Instantly share code, notes, and snippets.

@Zekfad
Created May 15, 2021 13:49
Show Gist options
  • Save Zekfad/3ca40ee45e7019d559f195cf13a1932b to your computer and use it in GitHub Desktop.
Save Zekfad/3ca40ee45e7019d559f195cf13a1932b to your computer and use it in GitHub Desktop.
Simple command line arguments spoofer
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char * str_concat(char *s1, const char *s2) {
const size_t a = strlen(s1);
const size_t b = strlen(s2);
const size_t size_ab = a + b + 1;
s1 = realloc(s1, size_ab);
memcpy(s1 + a, s2, b + 1);
return s1;
}
int main(int argc, char *argv[]){
char *str = malloc(0);
memset(str, 0, sizeof(char));
str_concat(str, argv[0]);
str_concat(str, "-real ");
for(int i = 1; i <= argc - 1; i++) {
str_concat(str, argv[i]);
str_concat(str, " ");
}
return system(str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment