samedi 28 février 2015

Append Source To Binary

Is their a way to append the source code of an executable to the file itself such that the file is still executable?


For example let's take a simple program like yes from busybox. How might I append the code in a way to the binary. Again this is a simple example, I would like to be able to do such for for a multiple file example that allows you to retrieve the code.



#include "libbb.h"

int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int yes_main(int argc UNUSED_PARAM, char **argv)
{
char **pp;

argv[0] = (char*)"y";
if (argv[1])
++argv;

do {
pp = argv;
while (1) {
fputs(*pp, stdout);
if (!*++pp)
break;
putchar(' ');
}
} while (putchar('\n') != EOF);

bb_perror_nomsg_and_die();
}

Aucun commentaire:

Enregistrer un commentaire