─── Binary Golf Grand Prix 1 ───────────────────────────────────────────────//──

Welcome to the Binary Golf Grand Prix! This is a challenge for people who like
to craft tiny binaries.

There have been a few CTF challenges involving binary golf, but it is sadly a
dying art outside of the demoscene and some virus writing circles.

Binary Golf is similar to Code Golf, where the purpose is to program something
in as few instructions as possible. It takes it a step further and challenges 
people to create the smallest possible binary file as well.

The goal of the Binary Golf Grand Prix is to challenge programmers to make the
smallest possible binary that fits within certain constraints.

For more info on Binary Golf, here are some resources:

 - A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux
 - Elf Binary Mangling Parts 1, 2, and 3
 - Tiny PE
 - Modern PE Mangling
 - Tiny Mach-o 
 - Adventures in Binary Golf - AirGap2020
 - golf.so (136 bytes)
 - golf.so (163 bytes)
 - SizeCoding Wiki
 - small: Smallest possible syntactically valid files of different types
 - m8trix (8 byte COM file demo)

─── The Challenge ──────────────────────────────────────────────────────────//──

The inaugural challenge of the BGGP is to create an Ambigram binary. Ambigrams
are essentially calligraphy that is read differently or the same depending on
how you look at it. In particular, we'll be focusing on "rotational" ambigrams,
which are read the same when you rotate them 180 degrees.

This challenge was inspired by @0xdade

The binary you will craft will be the same executable when flipped backwards.

Example:

  $ xxd some.random.exe | head -n 1
  00000000: 4d5a 9000 0345 0000 0400 0000 ffff 0000  MZ...E..........

The entire binary will be reversed, and the first byte, will be the last byte.

  4d5a 9000 0345 .... <-- reversed --> .... 4503 0090 5a4d 

  Disassembly (x86):

    45     inc  ebp
    03 00  add  eax,DWORD PTR [eax]
    90     nop
    5a     pop  edx
    4d     dec  ebp

Scores will be calculated based on both the size of the executable, as well as
the percentage of bytes executed when it is run.

An easy solution would be to just have the binary end, and append the binary
backwards at the end of the original file. Because of this, in order to qualify
for entry, your binary must at a minimum execute > 50% of the bytes in your 
binary, and must execute past the halfway mark in your binary as well.

─── File Formats ───────────────────────────────────────────────────────────//──

Any executable format will be accepted, and must run on an operating system or
piece of hardware that can be physically or virtually run. Feel free to think
far beyond the typical PE/ELF/Mach-o binary types, and work with something you
feel you can express yourself best with. This includes ROMs, bootloaders, 
firmware or anything else that can execute on a processor.

For a list of binary formats, check here!

You must have a working copy that runs on your target system, and instructions
for running the binary must be provided with your submission!

─── tl;dr ──────────────────────────────────────────────────────────────────//──

Rules:

 - Any executable binary format
 - Any OS
 - Any architecture
 - Minimum should execute 50% of it's bytes
 - Must execute within the mirrored section
 - Must read the same forwards as it does backwards
 - Must actually run on the target system

Submissions:

 - Submit the binary, source and instructions to run (preferably in a Git repo)
 - Include a SHA256 hash of your file both forwards and backwards (should match)
 - Extra credit: Include a write up/blog link describing your process

Scoring:

 - Size
 - Percentage of bytes executed

The challenge will run until Friday, August 28th 2020 @ 8:00 PM America/New_York

Tweet or DM your submissions to @netspooky on Twitter, or alternatively email 
info [at] thugcrowd [dot] com 

We will do publish a blog and possibly do a live stream to review submissions
in the week following. We look forward to seeing what you come up with!