Skip to content

Instantly share code, notes, and snippets.


rbocchinfuso/hello.c Secret

Last active Jun 1, 2018
What would you like to do?
Polymorphic Hello World
int main(void)
int i;
for(i=0; i<10; i++) {
char buffer[0];
// copy counter to buffer
sprintf(buffer, "%d", i);
char fname[20] = "hello";
// crate filename hello, appending counter and .com to the file name
// create file
FILE *myfile = fopen(fname, "wb");
//write to file
putc(0x0E, myfile);
putc(0x1f, myfile);
putc(0xba, myfile);
putc(0x0E, myfile);
putc(0x01, myfile);
putc(0xb4, myfile);
putc(0x09, myfile);
putc(0xcd, myfile);
putc(0x21, myfile);
putc(0xb8, myfile);
putc(0x01, myfile);
putc(0x4c, myfile);
putc(0xcd, myfile);
putc(0x21, myfile);
putc(0x48, myfile); //H
putc(0x65, myfile); //e
putc(0x6c, myfile); //l
putc(0x6c, myfile); //l
putc(0x6f, myfile); //o
putc(0x20, myfile); //space
putc(0x57, myfile); //W
putc(0x6f, myfile); //o
putc(0x72, myfile); //r
putc(0x6c, myfile); //l
putc(0x64, myfile); //d
putc(0x21, myfile); //!
putc(0x24, myfile);
// close file
// run newly created com files and produce output
printf("\n\nCreated file: %s \n", fname);
printf(" Executing: %s \n", fname);
printf(" Output: ");
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.