Skip to content

Instantly share code, notes, and snippets.

@yarwelp
Created September 29, 2011 06:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yarwelp/1250117 to your computer and use it in GitHub Desktop.
Save yarwelp/1250117 to your computer and use it in GitHub Desktop.
A polyglot written in C and bash
#include <stdio.h>
#include <stdlib.h> /*
# Copyright (c) 2011, Erik Nordstroem <contact[at]erikano[dot]net>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
EXIT_SUCCESS=0 # */
#define F char *f
main ()
{
F="UMAD?";
printf /* | egrep -v ".*" #*/("");/*
F=$( echo $F | egrep -o "[A-Za-z]*" | sed "s/ //g" )
gcc $0 -o $F && ./$F || for i in 1 ; do echo lol; # */
printf /*$F? | sed "s/\/\*\([A-Za-z]\)/\1/g" ; echo #*/ ("lol\n%s\n", f);
return 0; printf /* >/dev/null # */ (""); //\
done;
}
//usr/bin/env false #\
main # PS joke was self made after reading about Polyglot_(computing) on WP
@yarwelp
Copy link
Author

yarwelp commented Sep 29, 2011

Download the program.
$ wget https://gist.github.com/gists/1250117/download -O polyglot.tgz

Extract the contents of the top level directory in the archive to the current directory.
$ tar xvf polyglot.tgz --strip 1

Open a bash shell (this step can be omitted if bash is your default shell).
$ bash

Make the file executable.
$ chmod 755 polyglot.c

Run it.
$ ./polyglot.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment