Skip to content

Instantly share code, notes, and snippets.

@losfair
Created August 1, 2016 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save losfair/b032e6cb0479294051dc9f866f56c3b0 to your computer and use it in GitHub Desktop.
Save losfair/b032e6cb0479294051dc9f866f56c3b0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
static __attribute__((constructor)) void hook_init(void) {
int fd,len,i;
char *cmdline;
cmdline=malloc(65536);
fd=open("/proc/self/cmdline",O_RDONLY);
if(fd<0) {
fprintf(stderr,"[*] Error: Unable to get self/cmdline\n");
exit(-1);
}
len=read(fd,cmdline,65536);
for(i=0;i<len-1;i++) if(cmdline[i]==0) cmdline[i]=' ';
cmdline[len-1]='\0';
fprintf(stderr,"[*] %s\n",cmdline);
free(cmdline);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment