Merge pull request #1781 from xexyl/ciura19
This commit is contained in:
6 files changed
+118
-21
No files matched your search
@@ -31,7 +31,6 @@ For more detailed information see [2019 ciura in bugs.md](/bugs.md#2019-ciura).
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
./try.sh
|
./try.sh
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +42,6 @@ newline. See the Author's remarks for more information.
|
|||||||
|
|
||||||
### Alternate build:
|
### Alternate build:
|
||||||
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# sort with: sort -d -u
|
# sort with: sort -d -u
|
||||||
|
cppp
|
||||||
*.dSYM
|
*.dSYM
|
||||||
indent
|
indent
|
||||||
indent.c
|
indent.c
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ all: data ${TARGET}
|
|||||||
${PROG}: ${PROG}.c
|
${PROG}: ${PROG}.c
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||||
|
|
||||||
|
cppp: cppp.cc
|
||||||
|
${C_PLUSPLUS} -std=c++11 $< -o $@ ${LDFLAGS}
|
||||||
|
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
#
|
#
|
||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
|
|||||||
+17
-19
@@ -15,24 +15,20 @@ make
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo "International Obfuscated C Code Contest 2020" | ./prog 23209 > code.c
|
./try.sh
|
||||||
|
|
||||||
# compile without a PIN
|
|
||||||
cc code.c -o decode
|
|
||||||
# yes, you must compile with -DPIN=<number>
|
|
||||||
|
|
||||||
# compile with the wrong pin
|
|
||||||
cc -DPIN=555 code.c -o wrongcoded # wait for it ...
|
|
||||||
./wrongcoded | hexdump -C
|
|
||||||
# Use the wrong PIN: You're gonna have a bad time.
|
|
||||||
|
|
||||||
# compile with a PIN
|
|
||||||
cc -DPIN=23209 code.c -o decoded # wait for it ...
|
|
||||||
./decoded
|
|
||||||
# weeeeeeeeeeeeee! You are having a good time!
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
The author provided the file [cppp.cc](cppp.cc) which can preprocess the
|
||||||
|
generated output to make them more acceptable to typical compilers. To build:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make cppp
|
||||||
|
```
|
||||||
|
|
||||||
|
See the author's remarks for more details.
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
You might think of this entry as code obfuscater with a code.
|
You might think of this entry as code obfuscater with a code.
|
||||||
@@ -65,22 +61,22 @@ where [PIN] is an integer in the range of 1..65535
|
|||||||
```
|
```
|
||||||
|
|
||||||
When run with an encoding PIN (first command line argument), Mile will
|
When run with an encoding PIN (first command line argument), Mile will
|
||||||
read bytes from stdin and generate C code on stdout. Example:
|
read bytes from `stdin` and generate C code on `stdout`. Example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo "Hello, world!" | ./prog 56789 > encoded.c
|
echo "Hello, world!" | ./prog 56789 > encoded.c
|
||||||
```
|
```
|
||||||
|
|
||||||
This generated code will reproduce the same input bytes on stdout when
|
This generated code will reproduce the same input bytes on `stdout` when
|
||||||
executed, if it was compiled with the same encoding PIN.
|
executed, if it was compiled with the same encoding PIN.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
gcc -DPIN=56789 encode.c -o decoded
|
gcc -DPIN=56789 encoded.c -o decoded
|
||||||
```
|
```
|
||||||
|
|
||||||
The generated code reconstructs all data at compile time by seeding a
|
The generated code reconstructs all data at compile time by seeding a
|
||||||
random number generator with the given PIN to reproduce the input bytes,
|
random number generator with the given PIN to reproduce the input bytes,
|
||||||
and simply does one fwrite() call at run time to print those bytes. Not
|
and simply does one `fwrite(3)` call at run time to print those bytes. Not
|
||||||
specifying a PIN is a compile time error. Specify the wrong PIN and
|
specifying a PIN is a compile time error. Specify the wrong PIN and
|
||||||
output code will still compile, but will likely produce garbage instead of
|
output code will still compile, but will likely produce garbage instead of
|
||||||
the input bytes. If the original input was empty then any PIN works, but
|
the input bytes. If the original input was empty then any PIN works, but
|
||||||
@@ -99,6 +95,7 @@ with that by producing C code filled with at least 98% preprocessor lines
|
|||||||
for any input. Now you too can enjoy long compile times with minimal
|
for any input. Now you too can enjoy long compile times with minimal
|
||||||
effort.
|
effort.
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
+ Output is randomized using system clock, so if you wait a second between
|
+ Output is randomized using system clock, so if you wait a second between
|
||||||
@@ -115,6 +112,7 @@ effort.
|
|||||||
to nanomachines directly, which is exactly what programming in
|
to nanomachines directly, which is exactly what programming in
|
||||||
preprocessor feels like.
|
preprocessor feels like.
|
||||||
|
|
||||||
|
|
||||||
### Compatibility
|
### Compatibility
|
||||||
|
|
||||||
Mile has been verified to work in these environments (also, compiles
|
Mile has been verified to work in these environments (also, compiles
|
||||||
|
|||||||
Executable
+87
@@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2020/yang
|
||||||
|
#
|
||||||
|
|
||||||
|
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||||
|
# this way allows us to have the user specify a different compiler in an easy
|
||||||
|
# way.
|
||||||
|
if [[ -z "$CC" ]]; then
|
||||||
|
CC="cc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
make CC="$CC" all >/dev/null || exit 1
|
||||||
|
|
||||||
|
# clear screen after compilation so that only the entry is shown
|
||||||
|
clear
|
||||||
|
|
||||||
|
# we will use hexdump later if it's installed
|
||||||
|
HEXDUMP="$(type -P hexdump)"
|
||||||
|
|
||||||
|
echo "Getting usage:"
|
||||||
|
echo "$ ./prog" 1>&2
|
||||||
|
./prog
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to continue: "
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ echo \"International Obfuscated C Code Contest 2020\" | ./prog 23209 > code.c" 1>&2
|
||||||
|
echo "International Obfuscated C Code Contest 2020" | ./prog 23209 > code.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to show code.c (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
less -rEXF code.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
# compile without a PIN
|
||||||
|
echo "Trying to compile without a PIN:"
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ cc code.c -o decode" 1>&2
|
||||||
|
cc code.c -o decode
|
||||||
|
echo 1>&2
|
||||||
|
echo "As you can see, you must compile with -DPIN=<number>" 1>&2
|
||||||
|
|
||||||
|
if [[ -n "$HEXDUMP" ]]; then
|
||||||
|
# compile with the wrong pin if hexdump is installed
|
||||||
|
echo 1>&2
|
||||||
|
echo "Compiling with wrong PIN: cc -DPIN=555 code.c -o wrongcoded" 1>&2
|
||||||
|
cc -DPIN=555 code.c -o wrongcoded # wait for it ...
|
||||||
|
read -r -n 1 -p "Press any key to run wrongcoded: "
|
||||||
|
echo 1>&2
|
||||||
|
./wrongcoded | "$HEXDUMP" -C
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to compile with a good PIN: "
|
||||||
|
echo 1>&2
|
||||||
|
# compile with a PIN
|
||||||
|
echo "$ cc -DPIN=23209 code.c -o decoded" 1>&2
|
||||||
|
cc -DPIN=23209 code.c -o decoded
|
||||||
|
read -r -n 1 -p "Press any key to run: ./decoded: "
|
||||||
|
echo 1>&2
|
||||||
|
./decoded
|
||||||
|
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to continue: "
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ echo \"Hello, world!\" | ./prog 56789 > encoded.c" 1>&2
|
||||||
|
echo "Hello, world!" | ./prog 56789 > encoded.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to show encoded.c (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
less -rEXF encoded.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to compile with PIN 56789: "
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ cc -DPIN=56789 encoded.c -o decoded" 1>&2
|
||||||
|
cc -DPIN=56789 encoded.c -o decoded
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run decoded: "
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ ./decoded" 1>&2
|
||||||
|
./decoded
|
||||||
|
|
||||||
|
rm -f decoded code.c encoded.c
|
||||||
@@ -4459,6 +4459,15 @@ more at home for vi users. One might still end up cursing (see the README.md
|
|||||||
file) but probably a lot less :-)
|
file) but probably a lot less :-)
|
||||||
|
|
||||||
|
|
||||||
|
## <a name="2020_yang"></a>[2020/yang](/2020/yang/prog.c) ([README.md](/2020/yang/README.md))
|
||||||
|
|
||||||
|
[Cody](#cody) added the [try.sh](/2020/yang/try.sh) script.
|
||||||
|
|
||||||
|
Cody also added a make rule (`make cppp`) for the author's provided C++ code
|
||||||
|
that can preprocess the generated output to make them more acceptable to typical
|
||||||
|
compilers. See the README.md for more details.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# <a name="general_thanks"></a>General thanks
|
# <a name="general_thanks"></a>General thanks
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user